VideoHelp Forum
+ Reply to Thread
Results 1 to 15 of 15
Thread
  1. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    I have several hundred one minute long mp4 files that I would like to split/crop to make them 30 seconds long (or perhaps less) without re-encoding.

    I've spent hours looking for software that can do this without any luck.

    *Is* there software that can do this? I have no experience writing scripts, so I'd prefer something with a GUI.

    Any ideas?
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I don't think you will find any gui. But with some help should you be able to make a bat script using ffmpeg. You just have to click on the bat to run it then.

    Do you want to split them in two pieces? Or just keep the first 30 seconds?
    Quote Quote  
  3. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    I was afraid of that. But if it isn't too difficult, I'll give it a shot.

    I'd like to keep the last 30 seconds (possibly 20) of each file. If splitting every file in half (and then deleting the first half) is easier, I have no problem with that either.

    Thanks so much for your help.
    Quote Quote  
  4. Usually keeping the end is problematic to do in a batch script (it's easier to keep the beginning), but if all the files are approx 1min each, you can set the start time to 30 sec and it will copy from 30 sec to end, giving you the last 30 sec if they are 1min in duration. These will just be approximate times (you can't split precisely with most compression schemes anyways, because of long GOP encoding - you can only cut on keyframe boundaries, unless you use "smart editing" software which re-encodes a few frame around the cutsite, but you lose quality on those frames. With this method, there is no quality loss, but the cuts will not be precise, just approximate)

    1) To do this with ffmpeg, you download ffmpeg, and it's easier to place a copy of ffmpeg.exe in the same directory as files to be copied if you're not familar with paths or environment variables

    2) Open a file in notepad, in the same directory, copy & paste the following, save it, then rename the extention from .txt to .bat (e.g. it might be "batch.txt" to "batch.bat"

    Code:
    for %%a in ("*.mp4") do ffmpeg -i "%%a" -c:v copy -c:a copy -ss 00:00:30 "%%~na.cut.mp4"
    pause
    3) double click the .bat file

    The original files won't be overwritten. Each will be stream copied (audio & video only, not accessory streams, like subtitles because you never mentioned that) and have "cut" appended

    e.g
    file1.mp4 will produce file1.cut.mp4
    file7.mp4 will produce file7.cut.mp4
    .
    .
    .


    Try it out on a few test files first before committing to the large batch
    Quote Quote  
  5. Tencoder is a GUI that might be able to do this. It's a ffmpeg / mencoder GUI. You do basically the same thing, import a folder or list of files, set the start time to 30 seconds, set video & audio to "copy" and container to "mp4"
    Quote Quote  
  6. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    Tencoder is exactly what I was looking for other than one critical problem: Each file has to be trimmed manually. Thanks for the suggestion.

    poisondeathray, your script works beautifully. Is there a parameter that can be added to keep the timestamp the same as the original file?

    Thanks again for the help.
    Quote Quote  
  7. Is there a parameter that can be added to keep the timestamp the same as the original file?
    Can you clarify what you mean by that ? Exactly what do you mean by "timestamp"?
    Quote Quote  
  8. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    Meaning I'd like the newly trimmed files to keep their original Date Created.
    Quote Quote  
  9. Not possible with ffmpeg, because it cannot do "in-place editing" when used in this fashion - ie. it's non destructive (original file isn't over written) . It has to stream copy (write) a new file, thus a new date created on the new file

    There are other utilities to patch the date created/ date modified etc... and fill in various other fields, but I haven't really used them. There are some threads at videohelp about that. So you might be able to do a 2step batch, 1st to stream copy with ffmpeg, then the other utility to patch the date
    Quote Quote  
  10. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    Great, I'll look into that.

    Thanks for everything. It was exactly what I was looking for.
    Quote Quote  
  11. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    Hold on, poison.

    Tencoder works as well as your script (and keeps the original time codes), but it won't do batch operations with trimming. Is there a piece of your code I can enter in the custom video options to apply the 30 second trim to my files?

    Click image for larger version

Name:	ten.jpg
Views:	508
Size:	67.4 KB
ID:	31571
    Quote Quote  
  12. Try adding the start time of 30 sec

    --ss 00:00:30


    To re-iterate, this only works because your files are about 1 min long. If they were variable in length, some hour long, some 30 min, etc.... this wouldn't work
    Quote Quote  
  13. Member
    Join Date
    May 2015
    Location
    Canada
    Search Comp PM
    That's it. Perfect.

    Thanks x4.
    Quote Quote  
  14. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I was just going to start help you...but it seems to be solved. And I now know that Tencoder suppports batch cutting (with ffmpeg).
    Quote Quote  
  15. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Fleat, Did you find a way to keep created date? I wrote a short GUI a while back that does a folder full and altered it to match files with added text like PoisonDeathRay suggested. You did mean Windows created date or di you mean the Medi Info information?

    PHP Code:
    General
    Complete name                    
    C:\Users\Bud\Desktop\Mia_all.wmv
    Format                                 
    Windows Media
    File size                                
    93.0 MiB
    Duration                               
    18mn 41s
    Overall bit rate mode            
    Constant
    Overall bit rate                     
    696 Kbps
    Maximum Overall bit rate      
    700 Kbps
    Encoded date                        
    UTC 2005-05-05 12:03:21.265 

    The original files won't be overwritten. Each will be stream copied (audio & video only, not accessory streams, like subtitles because you never mentioned that) and have "cut" appended

    Just wondering and the last accessed is being a bear to change since Microsoft's last update to Microsoft Studios.

    Click image for larger version

Name:	ScreenHunter_140 May. 09 13.04.jpg
Views:	490
Size:	74.8 KB
ID:	31598
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!