Started by antisol, September 02, 2018, 05:03:40 PM
#PY <- Needed to identify ## This script removes the selection from the video:# Open a video file, select the start and end of the# section you want to cut out, and then run this.# it does this by saving start -> marker A as a file,# then saving marker B -> end as another file,# then it loads file A and appends file B# finally, it saves the resultadm = Avidemux()ed = Editor()gui = Gui()#prompt for destination file to save result todest = gui.fileWriteSelect("Choose destination file")start = adm.markerAend = adm.markerBvidlen = ed.getVideoDuration()adm.videoCodec("Copy")adm.audioCodec(0, "copy");#save section before selection:adm.markerA = 0adm.markerB = start#NOTE: this is linux-specific. ideally you'd generate# temporary file names and use those, but # unfortunately the tinypy included with avidemux# doesn't appear to include anything like os.tmpnam()adm.save("/tmp/avidemux_remove_selection-A")#save section after selection:adm.markerA = endadm.markerB = vidlen#NOTE: also linux-specific, see anove.adm.save("/tmp/avidemux_remove_selection-B")#now, join the two sections together. more linux-specific paths hereadm.loadVideo("/tmp/avidemux_remove_selection-A")adm.appendVideo("/tmp/avidemux_remove_selection-B")adm.save(dest)gui.displayInfo("Done!","All done!\n\nIf you survive, please come again!")
Quote from: antisol on September 02, 2018, 05:03:40 PMdear devs: please consider including more of the standard python libraries, sys, os, and re in particular would be extremely helpful!
QuoteI'd also love to have a way to seek to the next/previous keyframe from tinypy
Quote from: eumagga0x2a on September 04, 2018, 10:25:37 AMI can imagine that using an extremely limited python implementation is deliberate and rather a security feature.
QuoteI'm currently trying to find out whether the absence of navigation and editor functions is a design decision or simply not implemented due to time shortage or similar.
QuoteWith regard to your script, I think using temporary files and append can be avoided. Two adm.addSegment calls should be enough.
Quote from: antisol on September 04, 2018, 10:48:39 AM2. re-encode from keyframe before marker A to marker A into tempfile B, using same codec/settings as the video
Quote from: eumagga0x2a on September 04, 2018, 02:03:50 PMQuote from: antisol on September 04, 2018, 10:48:39 AM2. re-encode from keyframe before marker A to marker A into tempfile B, using same codec/settings as the videoThere is no infrastructure in Avidemux to achieve this. Even if you implement it, the success for a particular video stream is not guaranteed for H.264 and newer codecs.
start=adm.markerAadm.markerA = adm.previousKeyframe(start)adm.markerB = startadm.videoCodec(adm.currentVideoCodec())adm.save('/tmp/fileA')