Ffmpeg
使用 avconv 或 ffmpeg 從 png 製作電影時出錯
我想使用以下命令從一堆 png 中創建電影:
avconv -i pics/*.png out.mp4
或者
ffmpeg -r 1/1 -start_number 1 -i pics/*.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
但是,在這兩種情況下,我都得到:
Error while opening encoder for output stream #18:0 - maybe incorrect parameters such as bit_rate, rate, width or height
第二個命令的完整日誌消息是:
ffmpeg version 1.0.10 Copyright (c) 2000-2014 the FFmpeg developers built on Jul 25 2014 07:50:40 with gcc 4.7 (Debian 4.7.2-5) configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis libavutil 51. 73.101 / 51. 73.101 libavcodec 54. 59.100 / 54. 59.100 libavformat 54. 29.104 / 54. 29.104 libavdevice 54. 2.101 / 54. 2.101 libavfilter 3. 17.100 / 3. 17.100 libswscale 2. 1.101 / 2. 1.101 libswresample 0. 15.100 / 0. 15.100 libpostproc 52. 0.100 / 52. 0.100 Input #0, image2, from 'pics/1.png': Duration: 00:00:00.04, start: 0.000000, bitrate: N/A Stream #0:0: Video: png, rgba, 594x557, 25 tbr, 25 tbn, 25 tbc File 'output.mp4' already exists. Overwrite ? [y/N] y height not divisible by 2 (594x557) Output #0, image2, to 'pics/10.png': Stream #0:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #1, image2, to 'pics/11.png': Stream #1:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #2, image2, to 'pics/12.png': Stream #2:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #3, image2, to 'pics/13.png': Stream #3:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #4, image2, to 'pics/14.png': Stream #4:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #5, image2, to 'pics/15.png': Stream #5:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #6, image2, to 'pics/16.png': Stream #6:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #7, image2, to 'pics/17.png': Stream #7:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #8, image2, to 'pics/18.png': Stream #8:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #9, image2, to 'pics/19.png': Stream #9:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #10, image2, to 'pics/2.png': Stream #10:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #11, image2, to 'pics/3.png': Stream #11:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #12, image2, to 'pics/4.png': Stream #12:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #13, image2, to 'pics/5.png': Stream #13:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #14, image2, to 'pics/6.png': Stream #14:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #15, image2, to 'pics/7.png': Stream #15:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #16, image2, to 'pics/8.png': Stream #16:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #17, image2, to 'pics/9.png': Stream #17:0: Video: png, rgba, 594x557, q=2-31, 200 kb/s, 90k tbn, 1 tbc Output #18, mp4, to 'output.mp4': Stream #18:0: Video: h264, yuv420p, 594x557, q=-1--1, 90k tbn, 30 tbc Stream mapping: Stream #0:0 -> #0:0 (png -> png) Stream #0:0 -> #1:0 (png -> png) Stream #0:0 -> #2:0 (png -> png) Stream #0:0 -> #3:0 (png -> png) Stream #0:0 -> #4:0 (png -> png) Stream #0:0 -> #5:0 (png -> png) Stream #0:0 -> #6:0 (png -> png) Stream #0:0 -> #7:0 (png -> png) Stream #0:0 -> #8:0 (png -> png) Stream #0:0 -> #9:0 (png -> png) Stream #0:0 -> #10:0 (png -> png) Stream #0:0 -> #11:0 (png -> png) Stream #0:0 -> #12:0 (png -> png) Stream #0:0 -> #13:0 (png -> png) Stream #0:0 -> #14:0 (png -> png) Stream #0:0 -> #15:0 (png -> png) Stream #0:0 -> #16:0 (png -> png) Stream #0:0 -> #17:0 (png -> png) Stream #0:0 -> #18:0 (png -> libx264) Error while opening encoder for output stream #18:0 - maybe incorrect parameters such as bit_rate, rate, width or height
我怎樣才能使這項工作?
我認為帶有星號的文本需要連續數字指示符 %d :
avconv -i 'pics/%d.png' out.mp4 ffmpeg -r 1/1 -start_number 1 -i 'pics/%d.png' -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
引用 avconv 手冊頁:
The pattern may contain the string "%d" or "%0Nd", which specifies the position of the characters representing a sequential number in each filename matched by the pattern. If the form "%d0Nd" is used, the string representing the number in each filename is 0-padded and N is the total number of 0-padded digits representing the number. The literal character '%' can be specified in the pattern with the string "%%". If the pattern contains "%d" or "%0Nd", the first filename of the file list specified by the pattern must contain a number inclusively contained between 0 and 4, all the following numbers must be sequential. This limitation may be hopefully fixed. The pattern may contain a suffix which is used to automatically determine the format of the images contained in the files. For example the pattern "img-%03d.bmp" will match a sequence of filenames of the form img-001.bmp, img-002.bmp, ..., img-010.bmp, etc.; the pattern "i%%m%%g-%d.jpg" will match a sequence of filenames of the form i%m%g-1.jpg, i%m%g-2.jpg, ..., i%m%g-10.jpg, etc. The size, the pixel format, and the format of each image must be the same for all the files in the sequence. The following example shows how to use avconv for creating a video from the images in the file sequence img-001.jpeg, img-002.jpeg, ..., assuming an input framerate of 10 frames per second: avconv -i 'img-%03d.jpeg' -r 10 out.mkv