Home > Software design >  ffmpeg batch frame extraction to .png
ffmpeg batch frame extraction to .png

Time:07-22

I'm attempting to extract stacks of .png files from short 20-second videos of zebrafish hearts for ImageJ heartbeat analysis.

So far, this code,

ffmpeg -i C:\example_directory\filename.movS -r 30/1 C:\example_directory\filename_d.png

works quite well. However, this can only be run for one video file at a time, and outputs to one folder at a time.

I have a bit of code that converts multiple .mp4 videos into .mov:

for i in *.mp4; do ffmpeg -i "$i" -qscale 0 "$(basename"$i" .mp4)".mov ; done

is there a way to use a for loop or some kind of batch or .sh file to automate the .png extraction from a large group of short videos, say, a twenty or so videos?

I'm trying to write instructions to streamline the video and image processing for future lab students, so it might be helpful to know if there are differences in automating this for macOS, linux, or Windows 10

any advice is welcome!

thanks

CodePudding user response:

For /R C:\example_directory %%A in (*.mov) do (
    ffmpeg -i C:\example_directory\filename.movS -r 30/1 C:\example_directory\filename_d.png
)

I think this should work.

CodePudding user response:

For /R C:\example_directory %%A in (*.mov) do (
    ffmpeg -i "%%A"S -r 30/1 C:\example_directory\filename_d.png
)

I hope this works for you. The only part of this that I am not sure of is how you are going to use the code in between the ( ). Since it is not batch you are going to have to figure out how to use ffmpeg in batch or how to rewrite the code in a way that you know will work with batch. Since I am unaware of what ffmpeg does, I am not able to recreate that string of code. I would suggest learning about batch's for command for better help on how to make this possible.

  • Related