This shows you the differences between two versions of the page.
Next revision | Previous revision Last revision Both sides next revision | ||
tinypy:tinypybatch2 [2016/06/20 08:03] mean created |
tinypy:tinypybatch2 [2016/06/20 08:18] mean |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | == Batch Processing 2 == | + | ====== Batch Processing 2 ====== |
The first step is to process one file manually and save the corresponding tinypy project. | The first step is to process one file manually and save the corresponding tinypy project. | ||
+ | |||
A typical file would look like this : | A typical file would look like this : | ||
#PY <- Needed to identify # | #PY <- Needed to identify # | ||
Line 26: | Line 28: | ||
adm.audioSetShift(0, 0,0) | adm.audioSetShift(0, 0,0) | ||
adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | ||
+ | | ||
+ | We'll remove the beginning where we load the file and set the markers to only keep the settings part. | ||
+ | It becomes : | ||
+ | adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=AQ=20", "general.threads=99", "general.preset=", "general.tuning=", "general.profile=", "general.fast_decode=False",\ | ||
+ | "general.zero_latency=False", "general.fast_first_pass=True" \ | ||
+ | , "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=-1", \ | ||
+ | ... | ||
+ | ... | ||
+ | "ratecontrol.lookahead=40") | ||
+ | adm.addVideoFilter("swscale", "width=1280", "height=960", "algo=2", "sourceAR=1", "targetAR=1") | ||
+ | adm.audioCodec(0, "Faac"); | ||
+ | adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | ||
+ | | ||
+ | We'll reinject that part in the convert function we defined in the skeleton. | ||
+ | It is now : | ||
+ | |||
+ | # | ||
+ | # Load all the files in c:\tmp with .mp4 extension. | ||
+ | # That's it. | ||
+ | # | ||
+ | ext="mp4" | ||
+ | inputFolder="c:\\tmp\\" | ||
+ | # | ||
+ | def convert(filein): | ||
+ | if(0 == adm.loadVideo(filein)): | ||
+ | ui.displayError("oops","cannot load "+filein) | ||
+ | raise | ||
+ | # manual file insert | ||
+ | adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=AQ=20",\ | ||
+ | "general.threads=99", "general.preset=", "general.tuning=", "general.profile=",\ | ||
+ | "general.fast_decode=False",\ | ||
+ | "general.zero_latency=False", "general.fast_first_pass=True", \ | ||
+ | "general.blueray_compatibility=False", "general.fake_interlaced=False", "level=-1", \ | ||
+ | ... | ||
+ | ... | ||
+ | "ratecontrol.lookahead=40") | ||
+ | adm.addVideoFilter("swscale", "width=1280", "height=960", "algo=2", "sourceAR=1", "targetAR=1") | ||
+ | adm.audioCodec(0, "Faac"); | ||
+ | adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | ||
+ | # manual insert end | ||
+ | adm.save(filein+".converted.mp4") | ||
+ | print("Done") | ||
+ | | ||
+ | # | ||
+ | # Main | ||
+ | # | ||
+ | ui=Gui() | ||
+ | adm=Avidemux() | ||
+ | # | ||
+ | list=get_folder_content(inputFolder,ext) | ||
+ | if(list is None): | ||
+ | raise | ||
+ | for i in list: | ||
+ | convert(i) | ||
+ | print("Done") | ||
+ | |||
+ | A couple of pitfalls : | ||
+ | * The script is invalid, the x264 configuration line has been truncated. You must put a complete and valid line. | ||
+ | * Dont forget that a line cannot exceed 200 chars, split it and add "\" at the end of each split line. | ||
+ | |||
+ | |