我想在 ubuntu 12.04 LTS 下使用 ffmpeg 制作短缩时视频。我有一个文件夹,其中包含所有名为 DSC_0000.jpg DSC_0001.jpg 等的图像。我发现了这个问题ffmpeg:从图像创建视频我尝试运行那里提到的相同命令:
ffmpeg -i DSC_%d.jpg -vcodec mpeg4 timelapse.avi
并且失败了
DSC_%d.jpg:没有此文件或目录
我也尝试过
ffmpeg -i DSC_%04d.jpg -vcodec mpeg4 timelapse.avi
并因同样的错误而失败
而且由于某种原因,我的 ffmpeg 不理解选项-起始编号,如果我跑
ffmpeg -start_number 0 -i DSC_%d.jpg -vcodec mpeg4 timelapse.avi
我收到此错误:
无法识别的选项‘start_number’
无法将选项“start_number”的值设置为“0”
我将不胜感激任何帮助
更新1:我再次尝试了第二个命令,现在不知为何它起作用了。但输出的视频文件有点奇怪:它开始正常,但随后每一帧的质量都越来越差。视频结束时变得很糟糕。结果,视频文件非常小(只有 1.2 Mb,而 46 帧中的每一帧都是 900 kb)但选项-起始编号仍然不起作用。以下是完整输出:
$ ffmpeg -i DSC_%04d.jpg -vcodec mpeg4 timelapse.avi
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, image2, from 'DSC_%04d.jpg':
Duration: 00:00:01.84, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p, 2304x1536 [SAR 300:300 DAR 3:2], 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'timelapse.avi' already exists. Overwrite ? [y/N] y
Incompatible pixel format 'yuvj422p' for codec 'mpeg4', auto-selecting format 'yuv420p'
[buffer @ 0x7134e0] w:2304 h:1536 pixfmt:yuvj422p tb:1/1000000 sar:300/300 sws_param:
[buffersink @ 0x70bbe0] auto-inserting filter 'auto-inserted scale 0' between the filter 'src' and the filter 'out'
[scale @ 0x6f7a20] w:2304 h:1536 fmt:yuvj422p -> w:2304 h:1536 fmt:yuv420p flags:0x4
Output #0, avi, to 'timelapse.avi':
Metadata:
ISFT : Lavf53.32.100
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 2304x1536 [SAR 1:1 DAR 3:2], q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> mpeg4)
Press [q] to stop, [?] for help
frame= 46 fps= 17 q=31.0 Lsize= 1143kB time=00:00:01.84 bitrate=5090.2kbits/s
video:1137kB audio:0kB global headers:0kB muxing overhead 0.591912%
roman@Z500i5:~/Camera/Thunder/video$ ffmpeg -start_number 0 -i DSC_%04d.jpg -vcodec mpeg4 timelapse.avi
ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Unrecognized option 'start_number'
Failed to set value '0' for option 'start_number'
我的 ffmpeg 是从这个 ppa 安装的:https://launchpad.net/~jon-severinsson/+archive/ffmpeg
标准 ubuntu 存储库中的 ffmpeg 输出只有最后两行:
Unrecognized option 'start_number'
Failed to set value '0' for option 'start_number'
更新2: 请参阅下面的答案
答案1
最后我找到了一个解决方案,但没有 ffmpeg。这个命令可以完成我想要的操作:
mencoder "mf://*.jpg" -mf fps=20:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:vbitrate=7000 -oac copy -o timelapse.avi
看起来有点过于复杂,但它确实能完成工作:)