VideoHelp Forum




+ Reply to Thread
Results 1 to 12 of 12
  1. Hi I have hundreds and hundreds of video files from TV series with intro's and outro's. I want to cut these off and it will take me days to cut one file at a time. Is there a program that allows me to say cut 2 mins lots of video files at once?
    Quote Quote  
  2. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    FFmpeg should be able to do it. You'll need to make a .bat file to process all files with a given extension in a folder.
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  3. Thanks for the quick reply. I am downloading FFmpeg now but can you explain what you mean about the bat file? I do not know how to write computer code if that is what you mean.
    Quote Quote  
  4. Member ricardouk's Avatar
    Join Date
    Mar 2005
    Location
    Portugal
    Search Comp PM
    FFmpeg will recompress them, use avidemux if you dont want to recompress (loose quality)

    http://www.howtogeek.com/howto/42107/how-to-quickly-cut-a-clip-from-a-video-file-with-avidemux/
    I love it when a plan comes together!
    Quote Quote  
  5. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by ricardouk View Post
    FFmpeg will recompress them, use avidemux if you dont want to recompress (loose quality)

    http://www.howtogeek.com/howto/42107/how-to-quickly-cut-a-clip-from-a-video-file-with-avidemux/
    Not if you use copy:
    for %%a in ("*.mp4") do ffmpeg -i %%a -t 2:00 -c:v copy -c:a copy -y output.mkv

    pause
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  6. Hi I used that code and I got the 2 minutes of intros. How do I keep everything but the 2 minute of intros? I am playing about with the ffmpeg help .bat but stuck.
    Quote Quote  
  7. Hey I figured it out. here is my code

    for %%a in ("*.mp4") do ffmpeg -i %%a -ss 2:00 -c:v copy -c:a copy -y output.mkv

    pause

    However I am still figuring how to cut off the last 2 minutes
    Quote Quote  
  8. mkvmerge can be used also, splitting feature can be used,
    put this BAT into directory where videos are
    Code:
    @echo off
    SET mkv_path=C:\My Programs\MeGUI\tools\mkvmerge\mkvmerge.exe
    SET destination_folder=E:\cut_off_videos
    SET renaming_indicator=
    SET intro_length=00:02:00
    rem feature_video_finish = intro length  + video feature length
    SET feature_video_finish=00:47:00
    
    if not exist "%destination_folder%" ( MD "%destination_folder%" )
    for %%a in ("*.mp4","*.mkv") DO ( call :cut_off_intro "%%a" )
    echo done
    pause
    exit
    
    :cut_off_intro
    rem %%a becomes %1 after calling this function
    "%mkv_path%" -o "%destination_folder%\%~n1.mkv" "--no-global-tags"  "--split" "timecodes:%intro_length%" "%~n1%~x1"
    rem deleting intro video part
    DEL /Q "%destination_folder%\%~n1-001.mkv
    REN "%destination_folder%\%~n1-002.mkv" "%~n1%renaming_indicator%.mkv"
    goto :eof
    
    :cut_off_intro_and_outro
    "%mkv_path%" -o "%destination_folder%\%~n1.mkv" "--no-global-tags"  "--split" "timecodes:%intro_length%,%feature_video_finish%" "%~n1%~x1"
    DEL /Q "%destination_folder%\%~n1-001.mkv
    DEL /Q "%destination_folder%\%~n1-003.mkv
    REN "%destination_folder%\%~n1-002.mkv" "%~n1%renaming_indicator%.mkv"
    goto :eof
    you use cut_off_intro function to cut off intro, or you can call :cut_off_intro_and_outro function if video feature has always the same length
    Last edited by _Al_; 29th Jun 2014 at 11:10.
    Quote Quote  
  9. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Originally Posted by theunderdome View Post
    Hey I figured it out. here is my code

    for %%a in ("*.mp4") do ffmpeg -i %%a -ss 2:00 -c:v copy -c:a copy -y output.mkv

    pause

    However I am still figuring how to cut off the last 2 minutes
    This script seems to work: Assuming your clip is exactly 20 min long and you want to cut out the first and last 2 min:

    for %%a in ("*.mp4") do ffmpeg -i %%a -ss 2:00 -t 16:00 -c:v copy -c:a copy -y output.mkv
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  10. Member ricardouk's Avatar
    Join Date
    Mar 2005
    Location
    Portugal
    Search Comp PM
    Originally Posted by racer-x View Post
    Not if you use copy:
    with the exception of AVI i thought they could only be cut at keyframes, does ffmpeg do that on its own?
    I love it when a plan comes together!
    Quote Quote  
  11. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    It may very well default to nearest keyframe, I don't know. This is something I have zero interest in, I only suggested it because I thought the OP only wanted to save the first couple of minutes of all videos for whatever reason. ffmpeg can trim anything, even hevc.

    If and when I want to trim mp4's, I use MpegStreamClip. Those are very rare occasions anyway..........
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  12. Member ricardouk's Avatar
    Join Date
    Mar 2005
    Location
    Portugal
    Search Comp PM
    Thanks Racer, i digged a bit further ....

    Originally Posted by mark4o
    @ http://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-...e-using-ffmpeg

    With the mp4 container it is possible to cut at a non-keyframe without re-encoding using an edit list. In other words, if the closest keyframe before 3s is at 0s then it will copy the video starting at 0s and use an edit list to tell the player to start playing 3 seconds in.

    If you are using the latest ffmpeg from git master it will do this using an edit list when invoked using the command that you provided. If this is not working for you then you are probably either using an older version of ffmpeg, or your player does not support edit lists. Some players will ignore the edit list and always play all of the media in the file from beginning to end.

    If you want to cut precisely starting at a non-keyframe and want it to play starting at the desired point on a player that does not support edit lists, or want to ensure that the cut portion is not actually in the output file (for example if it contains confidential information), then you can do that by re-encoding so that there will be a keyframe precisely at the desired start time. Re-encoding is the default if you do not specify copy. For example:.
    I love it when a plan comes together!
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!