VideoHelp Forum
+ Reply to Thread
Results 1 to 20 of 20
Thread
  1. I have a few thousand files from my conversion of Super 8 tapes to digital. The files are now presently all in M4V format. When the videos were shot, each clip in the video has a Fade In and a Fade Out applied. I want to trim the Fade In (0 to 6 seconds in every file) and the Fade Out (End-6 to End). I've looked into many options including searching on this forum, but just can't figure out what I need. I have access to both Mac and Windows, thus either option would work.

    Thoughts?
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Probably easiest with ffmpeg

    Code:
    for %%a in ("*.mv4") do ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
    To trim 6 seconds from the beginning in all mv4 files and creates new mp4 files.

    But it's seems to be much more difficult to trim the end. See https://forum.videohelp.com/threads/348879-Trimming-video-from-it-s-end-using-FFMpeg-or-Mencoder


    ffmpeg batch guide
    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg
    Quote Quote  
  3. I'm trying your approach for the front of the video first. I have the .bat file setup, ffmpeg.exe in the same folder, newfiles folder set. When i run the bat, it just flashes and nothing happens.
    Quote Quote  
  4. are you sure they are ".mv4", not ".m4v" ? It says mv4 in the title and the batch file, but the 1st post says M4V . Typo ?

    add "pause" (without quotes) to the end of the batch file to see error messages
    Quote Quote  
  5. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    add pause to the end of the bat file like
    Code:
    for %%a in ("*.mv4") do ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
    pause

    and you will see the error message
    Quote Quote  
  6. The files are M4V as mentioned previously. ??
    Quote Quote  
  7. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Then change to m4v

    Code:
    for %%a in ("*.m4v") do ffmpeg -i "%%a" -ss 6 -vcodec copy -acodec copy "newfiles\%%~na.mp4"
    pause
    Quote Quote  
  8. Oh. I see in your code you put MV4. My current files are M4V. With ffmpeg, can this be done without reencoding everything? Instead of writing to an mp4 file, just keep it M4V?
    Quote Quote  
  9. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Nothing is reencoded when you use -vcodec copy and -acodec copy.

    mp4 = m4v.
    Quote Quote  
  10. OK thanks. I'll try it out. Then, work on the end portion. Thanks.
    Quote Quote  
  11. That worked incredibly well. Thanks so much. Testing out the end portion now.
    Quote Quote  
  12. Based on what i have read, you have to use ffprobe to determine the duration. Then, subtract the end point from the duration to get the end point.

    I tried this, but no dice.


    for %%a in ("*.m4v") do ffmpeg -i "%%a" -t ffprobe "filename" -6 vcodec copy -acodec copy "newfiles\%%~na.mp4"
    Quote Quote  
  13. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    It's complex. You should use ffprobe to read the length and then use it in the bat....I can try later tonight.
    Quote Quote  
  14. Any help you can lend is certainly appreciated. As you can imagine, I'm not even close to a coder. I'm just Googling and trying things to see what works.

    I found this code that is supposed to give you the Duration in seconds. But I can't figure out how to get it into the BAT loop.


    Code:
    $(ffprobe  "$INPUT_FILE" 2>&1 | grep Duration: |  \
            cut -f3,4 -d: | cut -f1 -d,);
    Quote Quote  
  15. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    grep and cut wont work in windows.
    Quote Quote  
  16. Originally Posted by Baldrick View Post
    It's complex. You should use ffprobe to read the length and then use it in the bat....I can try later tonight.
    Hi there. Was wondering if you have ever tried this or you could take a look? I would be very grateful. I cannot figure out the batch trim on the end.
    Quote Quote  
  17. The other thing is...it doesn't have to be a trim. It could be a split of files 6 seconds from the end of each file. Then, I'll just delete the small files. Thoughts?
    Quote Quote  
  18. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I tried and gave up. .
    Quote Quote  
  19. The effort is still appreciated!!!

    I did find this code online for Mac. Problem is, it doesn't work under Mavericks. If there is anyone that knows anything about it...I'd love to figure this out!!!


    Code:
    set secondsFromStart to 6
    set secondsFromEnd to 6
    set shortMoviesList to {}
    
    set srcFolder to choose folder
    
    tell application "Finder"
    set fileList to files of folder srcFolder
    repeatwith f in fileList
    tell application "QuickTime Player"
               open f
    tell document 1
    -- Check to make sure we're not trimming more time than the movie contains
    set timeScale to timescale
    set trimmedTime to (timeScale * (secondsFromStart + secondsFromEnd))
    if trimmedTime isgreater than duration then
    -- Not enough content to trim, add file name to a list
    setendof shortMoviesList to (the name of f as string) & return
    else
    -- We have enough content, proceed to trimming
    set selection start to (timeScale * secondsFromStart)
    set selection endto (duration - (timeScale * secondsFromEnd))
                       trim
                       save
    endif
                   close
    endtell
    endtell
    endrepeat
    if length of shortMoviesList isgreater than 0 then
    tell application "Finder"
    -- bring Finder to front so dialog is not hidden
               activate
    endtell
           display dialog "The following movies could not be trimmed because they do not contain enough content: " & return& return & shortMoviesList with icon caution
    endif
    endtell
    Quote Quote  
  20. OK, I got it. It only works on a Mac. And it only works with MP4 files. I struggled with this for the longest time. I kept receiving permission issues. Turns out, for some reason the Quicktime / Applescript would NOT work with an M4V. I converted my files to MP4 and voila, the code to trim works out perfectly. It is below.

    Code:
    set secondsFromStart to 3.5
    set secondsFromEnd to 3.5
    set srcFolder to choose folder
    set dstFolder to choose folder with prompt "Choose the destination folder for the trimmed files." default location srcFolder
    
    
    tell application "Finder"
        set fileList to files of folder srcFolder
    end tell
    
    
    
    
    repeat with f in fileList
        tell application "QuickTime Player"
            open f
            set documentName to name of f
            delay (1.0)
            tell document 1
                if duration > 7 then
                    trim from secondsFromStart to (duration - secondsFromEnd)
                                
                    export in file ((dstFolder as text) & documentName) using settings preset "480p..."
                    close saving no
                    delay (1.0)
                else
                    close saving no
                    delay (1.0)
                end if
            end tell
        end tell
    end repeat
    Quote Quote  



Similar Threads

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