Computer Hope

Microsoft => Microsoft DOS => Topic started by: raywood on June 15, 2021, 09:26:55 PM

Title: Running a Series of FFmpeg Commands in a Batch File
Post by: raywood on June 15, 2021, 09:26:55 PM
I have a batch file containing lines like these:

Code: [Select]
ffmpeg -i "D:\input.mpg" -ss 00:00:00 -to 00:00:26 -c:v copy -c:a copy "D:\output 001.mp4"
ffmpeg -i "D:\input.mpg" -ss 00:00:24 -to 00:01:30 -c:v copy -c:a copy "D:\output 002.mp4"

The purpose of these lines is to extract specified excerpts from input.mpg. For instance, the first command is supposed to extract the first 26 seconds from input.mpg and place that excerpt in a file called output1.mp4.

When I run that batch file, the command window just keeps repeating the first command, as if I had typed ECHO in front of it and ran it inside a FOR loop. Why isn't CMD running the FFmpeg command?
Title: Re: Running a Series of FFmpeg Commands in a Batch File
Post by: 1957classic on June 16, 2021, 11:04:25 AM
Try running this instead.

Code: [Select]
ffmpeg -ss 00:00:00 -to 00:00:26 -i "D:\input.mpg" -pix_fmt yuv420p "D:\output 001.mp4"
timeout /t 2
ffmpeg -ss 00:00:24 -to 00:01:30 -i "D:\input.mpg" -pix_fmt yuv420p "D:\output 002.mp4"
Title: Re: Running a Series of FFmpeg Commands in a Batch File
Post by: Squashman on July 16, 2021, 12:54:46 PM
Do you perhaps name your batch file FFMPEG?