I have a folder with 80 .mp4 files (AVC + AAC). They're all about 2-8 minutes long. I want to trim the first minute from all of them without re-encoding while keeping the filenames.
I read somewhere that in order to accomplish this I need to use a "loop". I tried this just to test:
Unfortunately, I'm getting "i was unexpected at this time".Code:for i in *.mp4; do ffmpeg -i "$i" -c copy \ -f segment -segment_time 600 \ -reset_timestamps 1 \ "${i/%.mp4/_part%02d.mp4}"; done
+ Reply to Thread
Results 1 to 7 of 7
-
-
windows batch file:
Code:for %%i IN (*.mp4) do ( ffmpeg -ss 60 -i "%%i" -c copy "%%~ni.cut.mp4 )
-
-
is putting the whole path to ffmpeg.exe in the script a thing of the past? Is it enough to just have the file in the same folder as the input files?
If the operating system (os) does not know the location of the executable, then the os will not be able to run the executable. The os, by default, will search the pwd (present working directory) for the executable.
You have to inform the os the location of the executable via (a) the path environment variable or (b) place the executable within the pwd or (c) write the whole path explicitly within the command call.
Having the executable within the pwd runs the risk of having multiple copies of the file present on your system -
Would be nice to put in thread script that works for you.
Depends on usage context but it is always better to properly initialize your environment as at some point you may have various ffmpeg versions and they may or not support for example filters you are trying to use. Then you are forced to investigate why something worked previously suddenly not works.
I use such script so i can easily point to desired ffmpeg folder
Code:@setlocal @REM Where to Find ffmpeg @rem set FFMPG=C:\FF @set FFMPG=%CD% @set PATH=%FFMPG%;%PATH% ---your script here--- @endlocal @pause
-
-
Hi, thx, something working for you may work for someone else in future.
And you can add to script automatic folder generation, just add this before your main line:
Code:@REM Where to place output file, No terminating Backslash. "." would be same as .bat file @set OUTDIR="trimmed" @if not exist %cd%\%OUTDIR% (mkdir %OUTDIR%)
Similar Threads
-
Batch trim out first 5 seconds of multiple videos
By giggioman00 in forum Newbie / General discussionsReplies: 4Last Post: 19th Oct 2022, 10:53 -
Ffmpeg Download Batch Files
By gufoli in forum Video Streaming DownloadingReplies: 1Last Post: 26th Mar 2022, 10:22 -
ffmpeg cut off first 10 seconds of video then add intro 15 seconds in
By PeterWall in forum Newbie / General discussionsReplies: 2Last Post: 30th Jul 2020, 06:18 -
ffmpeg - How to batch screen grab from multiple video files?
By Gameshow Host in forum Newbie / General discussionsReplies: 4Last Post: 2nd May 2019, 07:04 -
Batch combining multiple audio files with same picture to create mp4 files
By MD_89 in forum AudioReplies: 25Last Post: 1st Dec 2018, 22:29