View Full Version : Extracting frames from mp4 clip using ffmpeg
Nozdrum
10th February 2014, 16:17
Hi, I'm using ffmpeg to extract all frames contained in a 10 seconds mp4 file (avc/no audio), this is the syntax of the bat file (name: "extract-frames.bat"):
ffmpeg -i input.mp4 -r 1 output%05d.png
pause
But only the first frame is extracted correctly, then it returns this error:
[image2 @ 022fcce0] Could not open file : outputC:\Jan2014\01\extract-frames.bat5d.png
av_interleaved_write_frame(): Input/output error
I think the batch syntax "%0" causes the conflict within the output file name, do you know an alternative to this syntax that could work correctly for ffmpeg?
I was following this example:
http://www.alecjacobson.com/weblog/?p=2102
LoRd_MuldeR
10th February 2014, 16:33
Found this with a quick Google search:
FFMPEG - Making an Image Sequence from a video (http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence#Making_an_Image_Sequence_from_a_video)
ffmpeg -i "input.mov" -an -f image2 "output_%05d.jpg"
Nozdrum
10th February 2014, 17:28
The problem is that %0 in batch always causes the same issue, even with that command line:
[image2 @ 024ad520] Could not open file : output_C:\Jan2014\01\extract-frames.bat5d.jpg
av_interleaved_write_frame(): Input/output error
Maybe I need to get an updated ffmpeg.exe, I'll try again with a different version.
Edit: tried with latest build from here (http://ffmpeg.zeranoe.com/builds/) but the problem is the same, probably %0 shouldn't be used.
Nozdrum
10th February 2014, 17:58
Found this with a quick Google search:
FFMPEG - Making an Image Sequence from a video (http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence#Making_an_Image_Sequence_from_a_video)
ffmpeg -i "input.mov" -an -f image2 "output_%05d.jpg"
Thanks it works, I just needed to escape the "%" symbol, it should be:
ffmpeg -i "input.mov" -an -f image2 "output_%%05d.jpg"
poisondeathray
10th February 2014, 18:19
Does anyone know how to get ffmpeg to start numbering at frame "zero" instead of frame "one" for exporting image sequences ?
nevcairiel
10th February 2014, 18:28
Try adding a "-start_number 0" parameter.
poisondeathray
10th February 2014, 18:32
Try adding a "-start_number 0" parameter.
It works, thanks!
Selur
13th February 2014, 09:26
Nice, didn't know that there is a '-start_number' parameter :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.