合并时在视频的特定时间添加音频

合并时在视频的特定时间添加音频

我有一段时长为 6 秒的音频(REC00006.wav)。我有一个时长为 17 秒的视频(SUNP.avi)。

我需要合并这两个文件,但音频应该来自视频的第 11 秒到第 17 秒。

我在此处附上代码。合并成功。但音频来自视频开头

ffmpeg -y -i SUNP.AVI -itsoffset 00:00:11 -i REC00006.wav -acodec copy -vcodec copy -map 0:0 -map 1:0 C:\Users\admin\Desktop\HH3C01650\SUNP_REC00006.avi

这是控制台输出。

E:\abc>ffmpeg -y -i SUNP.AVI -itsoffset 00:00:11 -i REC00006.wav -acodec copy
 -vcodec copy -map 0:0 -map 1:0 C:\Users\admin\Desktop\HH3C01650\SUNP_REC00006.a
vi
ffmpeg version N-59036-g5d8e4f6 Copyright (c) 2000-2013 the FFmpeg developers
  built on Dec 12 2013 22:01:01 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 58.100 / 52. 58.100
  libavcodec     55. 45.101 / 55. 45.101
  libavformat    55. 22.100 / 55. 22.100
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     3. 92.100 /  3. 92.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 0284f6a0] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'SUNP.AVI':
  Duration: 00:00:17.55, start: 0.000000, bitrate: 19000 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1280x720, 30.02
 tbr, 30.02 tbn, 30.02 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, mono, s16,
176 kb/s
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, wav, from 'REC00006.wav':
  Duration: 00:00:06.02, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16
, 1536 kb/s
Output #0, avi, to 'C:\Users\admin\Desktop\HH3C01650\SUNP_REC00006.avi':
  Metadata:
    ISFT            : Lavf55.22.100
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 1280x720, q=2-31, 3
0.02 tbn, 30.02 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, 153
6 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  136 fps=0.0 q=-1.0 size=   15435kB time=00:00:06.32 bitrate=19979.3kbits
frame=  253 fps=0.0 q=-1.0 size=   27039kB time=00:00:11.62 bitrate=19054.4kbits
frame=  324 fps=216 q=-1.0 size=   34804kB time=00:00:14.68 bitrate=19409.4kbits
frame=  386 fps=221 q=-1.0 Lsize=   41424kB time=00:00:17.55 bitrate=19331.3kbit
s/s
video:40267kB audio:1128kB subtitle:0 global headers:0kB muxing overhead 0.06923
6%

E:\abc>ffmpeg -y -i SUNP.AVI -itsoffset 00:00:11 -i REC00006.wav -acodec copy
 -vcodec copy -map 0:0 -map 1:0 C:\Users\admin\Desktop\HH3C01650\SUNP_REC00006.a
vi

答案1

用这个:

ffmpeg -y -i F:\DCIM\100MEDIA\SUNP.AVI -itsoffset 00:00:11 -i F:\RECORD\REC00006.wav -acodec copy -vcodec copy -map 0:0 -map 1:0 C:\Users\admin\Desktop\HH3C01650\SUNP_REC00006.avi

您只需-y在开头使用一次即可覆盖具有相同输出名称的现有文件。itsoffset参数必须是HH:MM:SS格式或HH:MM:SS.DECIMAL格式。

相关内容