Question

I have 320 jpg(320x574) images which I have recorded them with 2004 fps. I want to make a .mp4 video of them. I have run below codes in cmd (win7) and it just make a video of jpg number 320 and if I go for this ('*.jpg') insted of 320 it does not work. I really appreciate any help.

ffmpeg -r 1/5 -i C:\data-Sam\320.jpg -c:v libx264 -r 30 -pix_fmt yuv420p C:\data-Sam\out.mp4
Was it helpful?

Solution

Depending on your file names you'll want:

ffmpeg -f image2 -i /path/to/file/image%3d.jpg test.avi

The image%3d would be for files named: image000.jpg, image001.jpg, image002.jpg, etc.

If your files are named image0.jpg, image1.jpg, image2.jpg, etc. then you'd use /path/to/file/image%d.jpg.

See FFmpeg image2 demuxer examples

OTHER TIPS

I can show you an example here,

ffmpeg -f image2 -r 60 -i path/filename%03d.jpg -vcodec libx264 -crf 18  -pix_fmt yuv420p test.mp4
  • f: force format
  • r: frame rate
  • i: input files assuming your files are filename001.jpg, filename002.jpg, ...
  • vcodec: video codec
  • crf: constant rate factor (0-51). 17-18 is (nearly) visually lossless. See Encode/H.264
  • pix_fmt: pixel format

You have other option like :

  • framerate = Set the frame rate for the video stream. It defaults to 25
  • -r = set frame rate

    ffmpeg -framerate 10 -i Path/To/File/filename%3d.jpg -r 5 -y Path/To/File/test.mp4
    

The main folder in it is ffmpeg.exe, the Your_files folder and the Result folder.
In the Your_files folder, upload a series of images.
Bat file will sort them in the order of the queue by name.
The finished video will be in the Result folder.

echo off
color a
set a="Your_files\*.jpg"
set b="Result\video.mp4"
set c=ffmpeg
set f=-c:v libx264 -pix_fmt yuv420p -r 30 -crf 20
set tmp="Result\list.tmp"
for %%f in (%a%) do (@echo file 'file:%cd%\%%f' >> %tmp%)
%c% -y -f concat -safe 0 -i %tmp% %f% %b%
cd /d Result
del /f /q list.tmp
exit

-c:v libx264 - We will encode in the MP4 format with the x264 codec.
-loglevel 16 – Show all errors, including ones which can be recovered from.
-r 30 – FPS frame rate. It takes effect after all filtering, but before encoding the video stream.
-crf 20 – Constant Rate Factor (CRF) is a quality setting (and rate control). values from 0 to 51, where lower values will result in better quality at the expense of higher file sizes. Higher values mean more compression, but at some point you will notice quality degradation. The default is 23.

Use cat

finally, I came up with a solution, it is using cat to get a .mkv and then convert it to .mp4

navigate to the folder that contains the .jpg files

cat *.jpg | ffmpeg -f image2pipe -i - output.mkv

and then

ffmpeg -i output.mkv -codec copy output.mp4

I am using ffmpeg binary on windows it doesn't take %d in option.

You are using cmd.exe, Right? Then do it like:

"file%d.jpg"

cmd.exe uses %PATH% to imitate $PATH used in real shells, so gets confused with file%d.jpg.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top