如何使用 ffmpeg 从硬盘上的一批图像压缩和创建 mp4 视频文件?
How can I compress and create mp4 video file from batch of images on hard disk using ffmpeg?
在我的目录中,我将 ffmpeg.exe 复制到所有图像所在的同一目录。
所有图片均为位图。
然后在命令提示符 windows 中输入:
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i \.\pipe\mytestpipe -map 0 -c:v mpeg4 -r out.mp4
但我收到错误消息,提示没有目录名称:
\.\pipe\mytestpipe
所以我删除了它并在没有管道部分的情况下键入了同一行。
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -map 0 -c:v mpeg4 -r out.mp4
现在没有目录名-map
所以我移动了 -map 0
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -c:v mpeg4 -r out.mp4
现在出现错误:
-c:v: Protocol not found
我在我的 c# 程序中使用这一行和管道作为使用 ProcessStartInfo
的 ffmpeg 的参数,但现在我不想只在命令提示符下使用管道来键入它并压缩和创建 mp4 视频文件。
编辑我现在试过了:
ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
我得到的是一些错误:
E:\screenshots>ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -p
ix_fmt yuv420p out.mp4
ffmpeg version N-73165-gf1e1730 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.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-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 45.100 / 56. 45.100
libavformat 56. 38.102 / 56. 38.102
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 18.100 / 5. 18.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
[bmp @ 0000000002eb7f80] bad magic number
Last message repeated 2 times
[image2 @ 0000000002eb64e0] decoding for stream 0 failed
[image2 @ 0000000002eb64e0] Could not find codec parameters for stream 0 (Video:
bmp, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
screenshot%06d.bmp: could not find codec parameters
Input #0, image2, from 'screenshot%06d.bmp':
Duration: 00:07:35.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: bmp, none, 0.20 fps, 0.20 tbr, 0.20 tbn, 0.20 tbc
Output #0, mp4, to 'out.mp4':
Output file #0 does not contain any stream
对于那些能看到的人。例如,当我在单个文件上执行此操作时:ffmpeg -framerate 1/5 -i screenshot000002.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out1.mp4
或 screenshot000003.bmp
或 screenshot000122.bmp
它将正常工作并创建视频文件。但是当我对所有图像执行此操作时,我遇到了所有错误:ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
here 是我在 screenshot000002.bmp
上执行的结果,并且工作正常。
当我在单个图像文件上执行此操作时,它像 screenshot000002.bmp
一样工作正常,但在所有图像上执行此操作时 screenshot%06d.bmp
它会出现我上面提到的所有错误。
你有一个基本问题。您需要阅读 documentation first. -i
is for input. So you need to specify the input images here. You can find many resources for creating a video out of a given images. Better look here.
进一步说明 -map 0
用于将第一个输入映射到输出。 -c:v
用于指定编码的视频编解码器。
希望对您有所帮助!
在我的目录中,我将 ffmpeg.exe 复制到所有图像所在的同一目录。 所有图片均为位图。
然后在命令提示符 windows 中输入:
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i \.\pipe\mytestpipe -map 0 -c:v mpeg4 -r out.mp4
但我收到错误消息,提示没有目录名称:
\.\pipe\mytestpipe
所以我删除了它并在没有管道部分的情况下键入了同一行。
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -map 0 -c:v mpeg4 -r out.mp4
现在没有目录名-map
所以我移动了 -map 0
ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -c:v mpeg4 -r out.mp4
现在出现错误:
-c:v: Protocol not found
我在我的 c# 程序中使用这一行和管道作为使用 ProcessStartInfo
的 ffmpeg 的参数,但现在我不想只在命令提示符下使用管道来键入它并压缩和创建 mp4 视频文件。
编辑我现在试过了:
ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
我得到的是一些错误:
E:\screenshots>ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -p
ix_fmt yuv420p out.mp4
ffmpeg version N-73165-gf1e1730 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.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-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 45.100 / 56. 45.100
libavformat 56. 38.102 / 56. 38.102
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 18.100 / 5. 18.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
[bmp @ 0000000002eb7f80] bad magic number
Last message repeated 2 times
[image2 @ 0000000002eb64e0] decoding for stream 0 failed
[image2 @ 0000000002eb64e0] Could not find codec parameters for stream 0 (Video:
bmp, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
screenshot%06d.bmp: could not find codec parameters
Input #0, image2, from 'screenshot%06d.bmp':
Duration: 00:07:35.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: bmp, none, 0.20 fps, 0.20 tbr, 0.20 tbn, 0.20 tbc
Output #0, mp4, to 'out.mp4':
Output file #0 does not contain any stream
对于那些能看到的人。例如,当我在单个文件上执行此操作时:ffmpeg -framerate 1/5 -i screenshot000002.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out1.mp4
或 screenshot000003.bmp
或 screenshot000122.bmp
它将正常工作并创建视频文件。但是当我对所有图像执行此操作时,我遇到了所有错误:ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
here 是我在 screenshot000002.bmp
上执行的结果,并且工作正常。
当我在单个图像文件上执行此操作时,它像 screenshot000002.bmp
一样工作正常,但在所有图像上执行此操作时 screenshot%06d.bmp
它会出现我上面提到的所有错误。
你有一个基本问题。您需要阅读 documentation first. -i
is for input. So you need to specify the input images here. You can find many resources for creating a video out of a given images. Better look here.
进一步说明 -map 0
用于将第一个输入映射到输出。 -c:v
用于指定编码的视频编解码器。
希望对您有所帮助!