Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Running a Series of FFmpeg Commands in a Batch File  (Read 27592 times)

0 Members and 1 Guest are viewing this topic.

raywood

    Topic Starter


    Greenhorn

    • Experience: Experienced
    • OS: Windows 10
    Running a Series of FFmpeg Commands in a Batch File
    « 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?

    1957classic



      Rookie
    • Thanked: 1
      • Experience: Experienced
      • OS: Windows 7
      Re: Running a Series of FFmpeg Commands in a Batch File
      « Reply #1 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"

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Running a Series of FFmpeg Commands in a Batch File
      « Reply #2 on: July 16, 2021, 12:54:46 PM »
      Do you perhaps name your batch file FFMPEG?