简体   繁体   English

如何使用ffmpeg从硬盘上的一批图像压缩和创建mp4视频文件?

[英]How can I compress and create mp4 video file from batch of images on hard disk using ffmpeg?

In my directory I copied ffmpeg.exe to the same directory where all the images are. 在我的目录中,我将ffmpeg.exe复制到了所有图像所在的目录中。 All images are bitmaps. 所有图像都是位图。

Then in the command prompt windows I typed: 然后在命令提示符窗口中键入:

ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v mpeg4 -r  out.mp4

But I get error that there is no a directory name: 但是我得到一个错误,即没有目录名称:

\\.\\pipe\\mytestpipe \\。\\管\\ mytestpipe

So I removed it and typed the same line without the pipe part. 因此,我将其删除并键入了没有管道部分的同一行。

ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -map 0 -c:v mpeg4 -r  out.mp4

Now there is no a directory name -map 现在没有目录名称-map

So I moved the -map 0 所以我移动了-map 0

ffmpeg -f rawvideo -pix_fmt yuv420p -video_size 1920x1080 -i -c:v mpeg4 -r  out.mp4

Now I'm getting error: 现在我得到了错误:

-c:v: Protocol not found -c:v:找不到协议

I used this line with the pipe in my c# program as arguments to ffmpeg using ProcessStartInfo but now I don't want to use pipes only in the command prompt to type it and compress and create mp4 video file. 我使用c#程序中的管道将此行作为使用ProcessStartInfo ffmpeg的参数,但现在我不想仅在命令提示符下使用管道来键入它并压缩和创建mp4视频文件。

Edit I tried this now: 编辑我现在尝试了这个:

ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

And what I get is some errors: 我得到的是一些错误:

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

For those who can see. 对于那些可以看到的人。 When i'm doing it on a single file for example: ffmpeg -framerate 1/5 -i screenshot000002.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out1.mp4 or screenshot000003.bmp or screenshot000122.bmp it will work fine and create the video file. 例如,当我在单个文件上执行操作时: ffmpeg -framerate 1/5 -i screenshot000002.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out1.mp4screenshot000003.bmpscreenshot000122.bmp它将正常工作并创建视频文件。 But when i'm doing this for all images i'm getting all the errors: ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 here is the results when i did on screenshot000002.bmp and it worked fine. 但是当我对所有图像执行此操作时,我得到了所有错误: ffmpeg -framerate 1/5 -i screenshot%06d.bmp -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 是结果,当我在screenshot000002.bmp做了,工作正常。

When i'm doing it on a single image file it's working fine like screenshot000002.bmp but when doing it on all the images screenshot%06d.bmp it's giving me all the errors i mentioned above. 当我在单个图像文件上执行此操作时,它可以像screenshot000002.bmp一样正常工作,但是在所有图像上执行此操作时, screenshot%06d.bmp了我上面提到的所有错误。

You have a fundamental issue. 您有一个基本问题。 You need to read the documentation first. 您需要先阅读文档 -i is for input. -i用于输入。 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 . 最好看看这里

To clarify further -map 0 is for mapping first input to the output. 为了进一步说明, -map 0用于将第一个输入映射到输出。 And -c:v is for specifying the video codec for encoding. -c:v用于指定要编码的视频编解码器。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM