[SOLVED]How do I Batch Trim the First X seconds of Multiple Videos?(FFMPEG)

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
colourgreen
Level 1
Level 1
Posts: 14
Joined: Fri Mar 05, 2021 2:12 pm

[SOLVED]How do I Batch Trim the First X seconds of Multiple Videos?(FFMPEG)

Post by colourgreen »

I've got lots of videos, mp4 and wmv, in a directory that I need to remove the first 30 seconds from.

I'm using FFMPEG in the Terminal at the moment but I only know how to do them one at a time.

What I've been doing is

Code: Select all

ffmpeg -i untrimmedvideo  -ss 00:00:30  -c:v copy -c:a copy trimmedvideo



How do I just do this for all the files in the directory? And ideally have the trimmed video have the same name and replace the original untrimmed video?

The directory only has videos that I need trimmed so I've been trying to understand how to make a batch file I can use to do it but I'm not really sure how to do it.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
mikeflan
Level 17
Level 17
Posts: 7154
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: How do I Batch Trim the First X seconds of Multiple Videos?(FFMPEG)

Post by mikeflan »

You can probably do it with a script that looks like this:
viewtopic.php?p=2028803#p2028803

Another option is to build up hundreds of commands to do each file and then run them all together.
Commands like this:

Code: Select all

xlscat -s '\t' -S 2 '/home/mike/Documents/DB/USA Files/MP1.xls' > /home/mike/Documents/copy2/MP1.txt
xlscat -s '\t' -S 2 '/home/mike/Documents/DB/USA Files/MP2.xls' > /home/mike/Documents/copy2/MP2.txt
xlscat -s '\t' -S 2 '/home/mike/Documents/DB/USA Files/MP3.xls' > /home/mike/Documents/copy2/MP3.txt
xlscat -s '\t' -S 2 '/home/mike/Documents/DB/USA Files/MP4.xls' > /home/mike/Documents/copy2/MP4.txt
xlscat -s '\t' -S 2 '/home/mike/Documents/DB/USA Files/MP5.xls' > /home/mike/Documents/copy2/MP5.txt
can be created by first doing ls -1 (or ls -1 *.*) on the directory and then use your text editor and regular expressions to build up the commands. It's a little tricky, but if you don't know regular expressions it might be time to learn them.
colourgreen
Level 1
Level 1
Posts: 14
Joined: Fri Mar 05, 2021 2:12 pm

Re: How do I Batch Trim the First X seconds of Multiple Videos?(FFMPEG)

Post by colourgreen »

Thanks this worked.
Another option is to build up hundreds of commands to do each file and then run them all together.
Commands like this:
.
but if you don't know regular expressions it might be time to learn them.
Definitely, I've still got a lot to learn. It took me a while to work out how to compile the list and commands using nano but I managed to figure it out.
Locked

Return to “Software & Applications”