Thursday, April 5, 2012

chunk splice mp4 video

To non-destructively extract a splice (chunk, subportion) from an .mp4 video file, I use mp4box from the command line. But the syntax is a bit wordy and hard to remember, mp4box takes START_SEC and END_SEC and a command line switch as arguments. So I created a basic wrapper batch script dedicated to splicing mp4 using mp4box that takes minutes and seconds as START_MIN START_SEC END_MIN END_SEC. You can also use total (absolute) sec by (obviously) setting MIN value to 0 and SEC to the total secs.

USAGE EXAMPLE:
mp4chunk_minsec 10 0 10 30 myvid.mp4
@rem mp4chunk_minsec.bat (4/2012)

@rem extracts mp4 chunk by min.sec

@rem mp4box -split-chunk S:E
@rem            extracts a new file from Start to End (in seconds)

@rem fontend wrapper:
@rem mp4chunk_minsec <start_min> <start_sec> <end_min> <end_sec> <file.mp4>

@echo off
set STARTM=%1
set STARTS=%2
set ENDM=%3
set ENDS=%4

if "%5"=="" goto USAGE

SET /a STARTS=%STARTM%*60+%STARTS%
SET /a ENDS=%ENDM%*60+%ENDS%
echo STARTS=%STARTS%
echo ENDS=%ENDS%
mp4box -split-chunk %STARTS%:%ENDS% %5


goto END
:USAGE
echo usage: mp4chunk_minsec ^<start_min^> ^<start_sec^> ^<end_min^> ^<end_sec^> ^<file.mp4^>
echo.

:END

No comments:

Post a Comment