Brubaker Haim
Brubaker Haim

Reputation: 55

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. 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

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

So I moved the -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

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.

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. 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.

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.

Upvotes: 1

Views: 1732

Answers (1)

Chamath
Chamath

Reputation: 2044

You have a fundamental issue. You need to read the 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.

To clarify further -map 0 is for mapping first input to the output. And -c:v is for specifying the video codec for encoding.

Hope this helps!

Upvotes: 1

Related Questions