This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tinypy:tinypybatch2 [2016/06/20 08:04] mean |
tinypy:tinypybatch2 [2016/06/20 08:19] (current) 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 36: | Line 38: | ||
| "ratecontrol.lookahead=40") | "ratecontrol.lookahead=40") | ||
| adm.addVideoFilter("swscale", "width=1280", "height=960", "algo=2", "sourceAR=1", "targetAR=1") | adm.addVideoFilter("swscale", "width=1280", "height=960", "algo=2", "sourceAR=1", "targetAR=1") | ||
| + | adm.audioCodec(0, "Faac"); | ||
| adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | adm.setContainer("MP4", "muxerType=0", "useAlternateMp3Tag=True") | ||
| | | ||
| We'll reinject that part in the convert function we defined in the skeleton. | We'll reinject that part in the convert function we defined in the skeleton. | ||
| It is now : | 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 | ||
| + | # ---------- Inserting project start------------ | ||
| + | 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") | ||
| + | # ---------- Inserting project end------------ | ||
| + | adm.save(filein+".converted.mp4") # save the file | ||
| + | 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. | ||
| + | |||
| | | ||