I want to extract frames as images from video
and I want each image to be named
as InputFileName_number.bmp
.
How can I do this?
I tried the following command:
ffmpeg -i clip.mp4 fr1/$filename%d.jpg -hide_banner
but it is not working as I want.
I want to get, for example, clip_1.bmp
, but what I get is 1.bmp
.
I am trying to use it with GNU parallel to extract images of multiple videos and I am new to both so I want some king of dynamic file naming input
-> input_number.bmp
.
1 Answer 1
$filename
is handled as a shell variable.
What about
ffmpeg -i clip.mp4 fr1/clip_%d.jpg -hide_banner
or
$mp4filename=clip
ffmpeg -i ${mp4filename}.mp4 fr1/${mp4filename}_%d.jpg -hide_banner
?
Update: For use with gnu parallel, you can use parallel's -i
option:
-i
Normally the command is passed the argument at the end of its command line. With this option, any instances of "{}" in the command are replaced with the argument.
The resulting command line could be as simple as
parallel -i ffmpeg -i {} fr1/{}_%d.jpg -hide_banner -- *.mp4
if you can live with the extension in the output files.
Be aware that you may not actually want to run this in parallel on a traditional hard-disk as the concurrent i/o will slow it down.
Edit: Fixed variable reference as pointed out by @DonHolgo.
-
I am trying to use it with gnu parallel to extract images of multiple videos and I am new to both so I want some king of dynamic file naming inpu -> input_number.bmpmark– mark2019年04月28日 17:14:52 +00:00Commented Apr 28, 2019 at 17:14
-
That should be
fr1/${mp4filename}_%d.jpg
in the second example so that the underscore is not considered part of the variable name.DonHolgo– DonHolgo2019年04月28日 18:11:45 +00:00Commented Apr 28, 2019 at 18:11 -
@mark I extended my answer. In the future, please mention the full details in your question right from the beginning.Hermann– Hermann2019年04月28日 21:42:24 +00:00Commented Apr 28, 2019 at 21:42
You must log in to answer this question.
Explore related questions
See similar questions with these tags.