You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcd.py 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ###############################################
  2. # Convert to VCD adm tinypy script
  3. # Mean 2011/2013
  4. ###############################################
  5. import ADM_imageInfo
  6. import ADM_image
  7. adm=Avidemux()
  8. gui=Gui()
  9. finalSizeWidth=352
  10. finalSizeHeight=[ 240,288,240]
  11. #
  12. MP2=80
  13. supported=[MP2]
  14. ##########################
  15. # Compute resize...
  16. ##########################
  17. source=ADM_image.image()
  18. dest=ADM_image.image()
  19. desc=""
  20. true_fmt=ADM_imageInfo.get_video_format(desc)
  21. if(true_fmt is None):
  22. raise
  23. fmt=true_fmt
  24. if(true_fmt==ADM_image.FMT_FILM):
  25. fmt=ADM_image.FMT_NTSC
  26. source.width=adm.getWidth()
  27. source.height=adm.getHeight()
  28. source.fmt=fmt
  29. dest.fmt=fmt
  30. print("Format : "+str(fmt))
  31. dest.width=16
  32. dest.height=16
  33. #*****************************
  34. # Dialog...
  35. #*****************************
  36. #
  37. mnuResolution = DFMenu("Resolution:");
  38. mnuSourceRatio = DFMenu("Source Aspect Ratio:");
  39. mnuSourceRatio.addItem("1:1")
  40. mnuSourceRatio.addItem("4:3")
  41. mnuSourceRatio.addItem("16:9")
  42. mnuDestRatio = DFMenu("Destination Aspect Ratio:");
  43. mnuDestRatio.addItem("4:3")
  44. mnuDestRatio.addItem("16:9")
  45. dlgWizard = DialogFactory("auto VCD ("+desc+")");
  46. dlgWizard.addControl(mnuSourceRatio);
  47. dlgWizard.addControl(mnuDestRatio);
  48. res=dlgWizard.show()
  49. if res!=1:
  50. exit()
  51. source.ar=mnuSourceRatio.index
  52. dest.ar=mnuDestRatio.index+1
  53. resizer=source.compute_resize(source,dest,finalSizeWidth,finalSizeHeight,ADM_imageInfo.aspectRatio)
  54. if(resizer is None):
  55. exit()
  56. print("Resize to "+str(resizer.width)+"x"+str(resizer.height))
  57. source.apply_resize(resizer)
  58. ############################
  59. # Handle audio....
  60. ############################
  61. tracks=adm.audioTracksCount()
  62. print("We have "+str(tracks)+ " audio tracks.")
  63. if(tracks!=1):
  64. gui.displayError("Error","Please have only one audio track for VCD!")
  65. exit()
  66. encoding=adm.audioEncoding(0)
  67. fq=adm.audioFrequency(0)
  68. channels=adm.audioChannels(0)
  69. reencode=False
  70. # 1 check frequency
  71. if(fq != 44100):
  72. adm.audioSetResample(0,44100)
  73. reencode=True
  74. if(not(encoding in supported)):
  75. reencode=True
  76. if(channels!=2):
  77. adm.audioSetMixer(0,"STEREO")
  78. reencode=True
  79. if(True==reencode):
  80. adm.audioCodec(0,"TwoLame","bitrate=224")
  81. ##################################
  82. # Video
  83. ##################################
  84. ff_ar=0
  85. if(dest.ar==ADM_image.AR_16_9):
  86. ff_ar=1
  87. #
  88. adm.videoCodec("ffMpeg2","params=CQ=2","lavcSettings=:version=2:MultiThreaded=2:me_method=5:_GMC=0:_4MV=0:_QPEL=0:_TRELLIS_QUANT=1:qmin=2:qmax=31:max_qdiff=3:max_b_frames=2:mpeg_quant=1:is_luma_elim_threshold=1:luma_elim_threshold=4294967294:is_chroma_elim_threshold=1:chroma_elim_threshold=4294967291:lumi_masking=0.050000:is_lumi_masking=1:dark_masking=0.010000:is_dark_masking=1:qcompress=0.500000:qblur=0.500000:"+"minBitrate=0:maxBitrate=9500:user_matrix=1:gop_size=18:interlaced=0:bff=0:widescreen="+str(ff_ar)+":"+"mb_eval=2:vratetol=8000:is_temporal_cplx_masking=0:temporal_cplx_masking=0.000000:is_spatial_cplx_masking=0:spatial_cplx_masking=0.000000:_NORMALIZE_AQP=0:use_xvid_ratecontrol=0:bufferSize=224:override_ratecontrol=0:dummy=0","matrix=0")
  89. ###################################
  90. # Container = Mpeg PS/DVD
  91. ###################################
  92. adm.setContainer("ffPS","muxingType=0","acceptNonCompliant=False","muxRatekBits=1400","videoRatekBits=1152","bufferSizekBytes=40")