User Tools

Site Tools


tinypy:tinypybatch2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tinypy:tinypybatch2 [2016/06/20 08:03]
mean created
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 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
 +      # ---------- 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.
 +
 +  ​
tinypy/tinypybatch2.1466402599.txt.gz · Last modified: 2016/06/20 08:03 by mean