我有两个文件,rec.avi 和 audio_edited.wav,我想做的是取出每个文件的 00:30:50–01:42:56 和 02:16:55–04:03:10 部分,将它们连接起来并编码为 WebM 文件。我当前的命令部分是从此处的其他问题复制粘贴的,如下所示:
ffmpeg -i rec.avi -i audio_edited.wav -filter_complex \
"[0:v]trim=start=1805:end=6176,setpts=PTS-STARTPTS[bv];\
[1:a]atrim=start=1805:end=6176,asetpts=PTS-STARTPTS[ba];\
[0:v]trim=start=8215:end=14590,setpts=PTS-STARTPTS[dv];\
[1:a]atrim=start=8215:end=14590,asetpts=PTS-STARTPTS[da];\
[bv][ba][dv][da]concat=n=2:v=1:a=1[outv][outa]" \
-map [outv] -map [outa] -c:v libvpx -crf 10 -b:v 5M -c:a libvorbis out.webm
但是当我尝试运行它时,ffmpeg 就停在
frame= 0 fps=0.0 q=0.0 Lsize= 4kB time=00:00:00.00 bitrate=35808.0kbits/s
当我退出命令时,我收到以下消息:
[libvorbis @ 0x2549a60] Trying to remove 128 samples, but the queue is empty
[webm @ 0x243c820] Encoder did not produce proper pts, making some up.
有人能指点我一下吗?我已经束手无策了。
完整输出:
$ ./convert.sh
ffmpeg version 2.1.7 Copyright (c) 2000-2014 the FFmpeg developers
built on Jan 3 2015 22:57:36 with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-7)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcdio --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
[avi @ 0x23ff400] non-interleaved AVI
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from 'rec.avi':
Duration: 04:05:14.04, start: 0.000000, bitrate: 104136 kb/s
Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1920x1080, 102584 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'audio_edited.wav':
Metadata:
encoder : Lavf55.19.104 (libsndfile-1.0.24)
Duration: 04:05:14.04, bitrate: 1536 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
File 'out.webm' already exists. Overwrite ? [y/N] y
[swscaler @ 0x2422680] deprecated pixel format used, make sure you did set range correctly
[libvpx @ 0x243a800] v1.3.0
Output #0, webm, to 'out.webm':
Metadata:
encoder : Lavf55.19.104
Stream #0:0: Video: vp8 (libvpx), yuv420p, 1920x1080, q=-1--1, 5000 kb/s, 1k tbn, 25 tbc (default)
Stream #0:1: Audio: vorbis (libvorbis), 48000 Hz, stereo, fltp (default)
Stream mapping:
Stream #0:0 (mjpeg) -> trim
Stream #0:0 (mjpeg) -> trim
Stream #1:0 (pcm_s16le) -> atrim
Stream #1:0 (pcm_s16le) -> atrim
concat:out:v0 -> Stream #0:0 (libvpx)
concat:out:a0 -> Stream #0:1 (libvorbis)
Press [q] to stop, [?] for help
[libvorbis @ 0x2549a60] Trying to remove 128 samples, but the queue is empty
[webm @ 0x243c820] Encoder did not produce proper pts, making some up.
frame= 0 fps=0.0 q=0.0 Lsize= 4kB time=00:00:00.00 bitrate=35808.0kbits/s
video:0kB audio:0kB subtitle:0 global headers:4kB muxing overhead 13.201821%
答案1
我解决了:该命令完全没有问题。显然,ffmpeg 只是需要花一些时间才能搜索我的 AVI,直到找到我想要的开始位置。