[2.6.4] Script for extract parts of large video

Started by n!co, June 20, 2013, 11:07:29 PM

Previous topic - Next topic

n!co

Hi,

I have write a script for cut large videos take with my gopro hd.
Please change codec and container as your convenience

Comments are welcome :)

n!co


#PY
# This script helps you to extract parts of large videos
# Simply set start time and end time, and start again :)
#
# Tips, use two avidemux and switch them with alt-tab
#
# v0.4
# n!co

# select video
gui=Gui()
input=gui.fileReadSelect("Select video")

# /!\ REMEMBER TO ADJUST VALID CODEC AND CONTAINER
#
adm = Avidemux()
adm.loadVideo(input)
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.audioAddTrack(0)
adm.audioCodec(0, "copy")
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True")

# ------------------------------------------
# SCRIPT
# ------------------------------------------

# convert in microsecond
def convert(t):
return (t * 1000 ) #+ 64

# process segment
def process(t1, t2):
start = convert(t1)
len = convert(t2) - start
#
adm.clearSegments()
adm.addSegment(0, start, len)
adm.markerA = 0
adm.markerB = len
#
output=gui.fileWriteSelect("Save segment")
adm.save(output)

# loop until user cancel
res = 1
while (res == 1):
time1 = DFTimeStamp("Start time",0,30000)
time2 = DFTimeStamp("End time",0,30000)
dialog = DialogFactory("Save segment")
dialog.addControl(time1)
dialog.addControl(time2)
res = dialog.show()

if (res == 1):
process(time1.value, time2.value)


Change Log :
0.4 : remove tricky offset
0.3 : add write file selector to save segment
0.2 : fix crash comes with last minute beautifulness
0.1 : initial script