Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
Created April 23, 2022 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidruhmann/b0c0bec98bd1b63944a1f6cf294f4ca1 to your computer and use it in GitHub Desktop.
Save davidruhmann/b0c0bec98bd1b63944a1f6cf294f4ca1 to your computer and use it in GitHub Desktop.
avidemux script - trim first and last keyframes for MP4 (see docs to use MKV container if needed)
@echo off
set "avidemux=C:\Program Files\Avidemux 2.7 VC++ 64bits\avidemux.exe"
: %%~nf returns the filename without the extension
for /F "tokens=*" %%f in ('dir /a-d /b *.mp4') do (
"%avidemux%" --load "%%f" --run trim.py --save "%%~nf_edit.mp4" --quit
)
exit /b
#PY <- Needed to identify #
#--automatically built--
adm = Avidemux()
ed = Editor()
adm.markerA = ed.getNextKFramePts(-1)
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"eng")
if adm.audioTotalTracksCount() <= 0:
raise("Cannot add audio track 0, total tracks: " + str(adm.audioTotalTracksCount()))
adm.audioAddTrack(0)
adm.audioCodec(0, "copy")
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "displayWidth=1280", "rotation=0", "clockfreq=0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment