I'm trying to cut 10 sec from the begging and from end of videos. I have 150 short videos in mp4 and I want to do this in batch. I have downloaded ffmpeg (x64) and installed. When I type the command "ffmpeg –version" in cmd then I get the listing and installation was successful, correct? Then I found this on your site:

for f in *.mp4; do
    duration=$(ffmpeg -i "$f" 2>&1 | grep "Duration"| cut -d ' ' -f 4 | sed s/,//)
    length=$(echo "$duration" | awk '{ split($1, A, ":"); print 3600*A[1] + 60*A[2] + A[3] }' )
    trim_end=$(echo "$length" - 10 - "$trim_start" | bc)
    echo ffmpeg -ss "$trim_start" -i "$f" -c copy -map 0 -t "$trim_end" "${f%.mp4}-trimmed.mp4"

I was created bat file with that code and placed in folder with videos, and when I start .bat it's just blink and disappears. Folder with videos is on c:, on the same drive where is path for ffmpeg (just to add if is important).

  • 1
    That code is a unix shell script not a batch file. – DavidPostill Jun 16 '16 at 14:56
  • If you want this to work, you're going to have to setup a virtual machine and Ubuntu with Oracle: Virtual Box(Free) or VMware Player(free last I checked). Windows doesn't have command tools for this to my knowledge. – Steve Kline Jun 16 '16 at 15:45
  • Thanks for answers, I found another code that I thing is more suitable for my needs but I cant make it to work. When I click on _trim.bat it's create folder but nothing inside. Here is link to code:superuser.com/questions/657492/… – Robert Jun 16 '16 at 16:44
  • I created 2 bat files _trim.bat and _trim2.bat and I was placed files in C:\ffmpeg\bin, with 2 videos, for test and won't work, just create empty folder. What i'm doing wrong? – Robert Jun 16 '16 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.