Results 1 to 7 of 7
  1. #1
    HAMLESS Ninjabear's Avatar
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    2,533

    Default Video Editing Tool for Multiple File at once?

    Hi

    Can anyone please recommend a software that can help me trim 5 seconds off the beginning and 10 seconds at the end of multiple video files.
    I use handbrake but you can only do one video at a time where the video will be encoded again which seems like a waste of time.

    Does anyone have any recommendation?

    Thanks
    Corsair Carbide Series® 500R,Intel i5 2500k,P8Z77V-Pro, 12GB DDR-1333MHZ ram, Asus DVD writer, Radeon Sapphire r9 270X 3GB , Windows 8 -64 Bit

  2. #2
    Senior Member
    Join Date
    Dec 2004
    Posts
    1,164

    Default Re: Video Editing Tool for Multiple File at once?

    You can do this with ffmpeg or avconv, I'm not sure what your handbrake is using behind the scenes but I believe you would already have one of these being used, so you just need to do it from commandline/terminal since it sounds like handbrake does not batch video files.

  3. #3
    HAMLESS Ninjabear's Avatar
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    2,533

    Default Re: Video Editing Tool for Multiple File at once?

    Quote Originally Posted by Kame View Post
    You can do this with ffmpeg or avconv, I'm not sure what your handbrake is using behind the scenes but I believe you would already have one of these being used, so you just need to do it from commandline/terminal since it sounds like handbrake does not batch video files.

    I really want to use ffmpeg but I spent an hour looking it up how to use but at the end I gave up as instructions weren't clear
    Corsair Carbide Series® 500R,Intel i5 2500k,P8Z77V-Pro, 12GB DDR-1333MHZ ram, Asus DVD writer, Radeon Sapphire r9 270X 3GB , Windows 8 -64 Bit

  4. #4
    Senior Member
    Join Date
    Dec 2004
    Posts
    1,164

    Default Re: Video Editing Tool for Multiple File at once?

    what OS do you use?

    It is simple to remove 5 seconds from the start. The end of each video of varying durations would require command substitution and arithmetic expansion to get us the duration and to take 10 seconds off that to give us the end (maybe? I am just thinking how i may do it in a 1 line command)

    I am not behind my computer to try the commands but you would need ffmpeg and ffprobe

    Depending on your OS we probably create a cmd or bash script file that will either accept your files you hand to it, or to do all the videos inside a directory.

  5. #5
    Senior Member
    Join Date
    Dec 2004
    Posts
    1,164

    Default Re: Video Editing Tool for Multiple File at once?

    This was not easy at a lower level scripting language and may not be the best way to go about it.

    I am using bash on Linux.
    I use these programs ls, bc, ffprobe and ffmpeg.
    I use these techniques variables, command substitution, variable substitution, for loop, here string and variable disambiguation mechanism.

    I am not impressed with my script because it is not easy to understand and explaining it will not be easy.

    Code:
    #!/bin/bash
    # clip.sh
    # basic video clipper
    
    EXT=mp4
    VIDEOS=$(ls *.${EXT})
    START=5
    CUT=10
    
    for VIDEO in $VIDEOS
    do
    	END_TIME=$(bc <<< "$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $VIDEO)/1-$CUT")
    	ffmpeg -i $VIDEO -ss $START -t $END_TIME -c copy clipped_${VIDEO}
    done
    This script needs to be in the directory where you want to clip/trim your videos.

    The variable EXT is the extension for the videos, it takes only 1 extension type (could make it work with multiple extensions). In this case mp4, in Linux case matters so MP4 is not the same as mp4. For Windows I believe case does not matter.

    The variable VIDEOS does a command subsitution, in other words calls a command and returns it's output. In this case we are calling the program ls (list directory) to get all the files with the EXT in the current working directory (where we placed this script)

    START and CUT are the seconds of where you would clip the video, so start after 5 seconds and end approximately 10 seconds earlier from the end. I am not certain about the accuracy of this and whether video and sound would be in sync. You will have to test this out first.

    We then loop over all the videos in our directory.

    We have to calculate the actual end time because there is no easy way to just say go back 10 seconds from the end in a video. So we need to grab how long a video is, then subtract the end time off it. This is the most complicated piece.

    bc is a calculator and we send it a here string to compute. To simplify what it is doing END_TIME = bc <<< "VIDEO_DURATION / 1 - CUT", so we are basically sending that equation to bc to get the result we need for the end time. The reason I divide VIDEO_DURATION by 1 is a hack for bc to truncate the microseconds off. E.g. a video could be 78.6 seconds long. I just want 78 seconds, no rounding.

    To get the video duration, I use ffprobe to grab the duration information from the current video we are doing on our loop, the options passed are necessary to return only the duration time in seconds without all the other information you could get with it. Basically things that can't be used in an equation.

    We then use ffmpeg to create a new video called clipped_* where * is the original name of the video, so if it was great.mp4, the new created clip will be called clipped_great.mp4

    I know I would not have explained this properly, but I hope it is useful for you to understand how you could do similar. I would rather do this in a higher level language with libraries that can understand videos and doing it in a way that is easier to understand.
    Last edited by Kame; 05-06-2020 at 04:53 AM.

  6. #6
    HAMLESS Ninjabear's Avatar
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    2,533

    Default Re: Video Editing Tool for Multiple File at once?

    I have downloaded the ffmpeg setup files

    I saw on youtube how go to control panel -- system -- advanced system settings then environment variables


    I opened CMD and I navigate to the folder where the video is.

    Now the question is how do I use ffmpeg to tell it to cut the video ?

    I am on Windows 10

    The videos are in D:\Videos\Mountain\25.mp4
    I launched CMD , I type ffmpeg and it runs
    I use cmd command to navigate to D:\Video\Mountains\

    Now how do I use the code?
    Last edited by Ninjabear; 07-06-2020 at 02:05 AM.
    Corsair Carbide Series® 500R,Intel i5 2500k,P8Z77V-Pro, 12GB DDR-1333MHZ ram, Asus DVD writer, Radeon Sapphire r9 270X 3GB , Windows 8 -64 Bit

  7. #7
    Junior Member
    Join Date
    Jun 2020
    Posts
    1

    Default Re: Video Editing Tool for Multiple File at once?

    launch cmd, go to D:\Videos\Mountain dir
    run a command:
    ffmpeg -ss 00:00:05 -t 01:23:45 -i 25.mp4 -sameq out_25.mp4

    your finish file is out_25.mp4

    ffmpeg -ss <start_time> -t <duration_time> -i 25.mp4 -sameq out_25.mp4

    I usually use yt videos cutter to trim YouTube videos

Similar Threads

  1. Replies: 2
    Last Post: 04-04-2012, 03:11 PM
  2. Motherboard and video card for video editing?
    By stuffed in forum PressF1
    Replies: 23
    Last Post: 08-11-2009, 10:57 AM
  3. Replies: 5
    Last Post: 27-12-2004, 08:03 AM
  4. Photo Editing Tool
    By willbry in forum PressF1
    Replies: 6
    Last Post: 10-09-2004, 07:06 PM
  5. Tool for undeleting file in Win 98??
    By robo in forum PressF1
    Replies: 10
    Last Post: 24-05-2004, 11:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •