User Tools

Site Tools


tinypy:examples

Differences

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

Link to this comparison view

Next revision
Previous revision
tinypy:examples [2013/04/27 10:29]
fx created
tinypy:examples [2016/06/20 08:00]
mean
Line 1: Line 1:
-===== Complex exampple ​===== +===== Skeleton for batch processing ​===== 
-  ​ext="​mpg"​ + 
-  ​inputFolder="/​tmp/​ts"​+Here is a simple tinypy script that will load all files with a mp4 extension in a folder.
   #   #
-  ​def convert(filein)+  ​# Load all the files in c:\tmp with .mp4 extension. 
-     fileout=filein+".converted.ps+  # That's it. 
-     print(filein+"​=>"​+fileout+  # 
-     ​if(0 == adm.loadVideo(filein)):​ +  ext="mp4
-         ​ui.displayError("​oops","​cannot load "​+filein) +  ​inputFolder="​c:​\\tmp\\"​ 
-         ​raise +  # 
-     adm.save(fileout) +  def convert(filein):    
-     print("​Done"​) +      if(0 == adm.loadVideo(filein)):​ 
-    +          ui.displayError("​oops","​cannot load "​+filein) 
 +          raise 
 +      print("​Done"​) 
 +      
   #   #
   # Main   # Main
Line 17: Line 20:
   ui=Gui()   ui=Gui()
   adm=Avidemux()   adm=Avidemux()
-  adm.audioReset() 
-  adm.audioCodec("​copy",​28152032) 
-  adm.videoCodec("​Copy"​) ​         adm.setContainer("​ffPS","​muxingType=3","​acceptNonCompliant=False","​muxRatekBits=30000",​ 
-  "​videoRatekBits=25000"," ​ bufferSizekBytes=500"​) 
   #   #
   list=get_folder_content(inputFolder,​ext)   list=get_folder_content(inputFolder,​ext)
   if(list is None):   if(list is None):
-     raise+      ​raise
   for i in list:   for i in list:
-        ​convert(i)+          ​convert(i)
   print("​Done"​)   print("​Done"​)
  
----- +The first part is the initialization. We set the input folder (beware, on windows the \ must be put twice, so c:\tmp\ becomes c:\\tmp\\) and extension '​.mp4'​ here.  
-    +Ending the path with a '​\\'​ is a good idea. 
-[[using:​tinypy|Go back to tinypy]]       ​+  ext="​mp4"​ 
 +  inputFolder="​c:​\\tmp\\"​ 
 + 
 +The we create the object that enables tinypy to interact with avidemux 
 +  ui=Gui() 
 +  adm=Avidemux() 
 +All avidemux commands will be performed on the '​adm'​ object. 
 +Next, get the list of files with the given extension and call the '​convert'​ function for all of them 
 +   
 +  list=get_folder_content(inputFolder,​ext) 
 +  if(list is None): 
 +      raise 
 +  for i in list: 
 +          convert(i) 
 +  print("​Done"​) 
 +   
 +You'll note that "​list"​ is the list of files with full path to them, i.e. c:​\\tmp\\foobar.mp4 
 +   
 +  def convert(filein): ​  ​ 
 +    if(0 == adm.loadVideo(filein)):​ 
 +        ui.displayError("​oops","​cannot load "​+filein) 
 +        raise 
 +    print("​Done"​) 
 + 
 +That's where everything happens. For this simple example, we just load the file, and raise an error if we cannot. 
 + 
 +If you try this script, it will load all files ending with mp4 from the c:\\tmp\\ folder. 
 + 
 +[[tinypyBatch2|Using the skeleton]] 
tinypy/examples.txt · Last modified: 2016/06/20 08:00 by mean