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.

dvd.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ###############################################
  2. # Convert to DVD adm tinypy script
  3. # Mean 2011/2013
  4. ###############################################
  5. import ADM_imageInfo
  6. import ADM_image
  7. adm=Avidemux()
  8. gui=Gui()
  9. finalSizeWidth=720
  10. finalSizeHeight=[ 480,576,480]
  11. #
  12. #
  13. MP2=80
  14. AC3=0x2000
  15. DTS=0x2001
  16. supported=[MP2,AC3,DTS]
  17. ##########################
  18. # Compute resize...
  19. ##########################
  20. source=ADM_image.image()
  21. dest=ADM_image.image()
  22. desc=""
  23. true_fmt=ADM_imageInfo.get_video_format(desc)
  24. if(true_fmt is None):
  25. raise
  26. fmt=true_fmt
  27. if(true_fmt==ADM_image.FMT_FILM):
  28. fmt=ADM_image.FMT_NTSC
  29. source.width=adm.getWidth()
  30. source.height=adm.getHeight()
  31. source.fmt=fmt
  32. dest.fmt=fmt
  33. print("Format : "+str(fmt))
  34. dest.width=16
  35. dest.height=16
  36. #*****************************
  37. # Dialog...
  38. #*****************************
  39. #
  40. mnuResolution = DFMenu("Resolution:");
  41. mnuSourceRatio = DFMenu("Source Aspect Ratio:");
  42. mnuSourceRatio.addItem("1:1")
  43. mnuSourceRatio.addItem("4:3")
  44. mnuSourceRatio.addItem("16:9")
  45. mnuDestRatio = DFMenu("Destination Aspect Ratio:");
  46. mnuDestRatio.addItem("4:3")
  47. mnuDestRatio.addItem("16:9")
  48. dlgWizard = DialogFactory("auto DVD ("+desc+")");
  49. dlgWizard.addControl(mnuSourceRatio);
  50. dlgWizard.addControl(mnuDestRatio);
  51. res=dlgWizard.show()
  52. if res!=1:
  53. exit()
  54. source.ar=mnuSourceRatio.index
  55. dest.ar=mnuDestRatio.index+1
  56. resizer=source.compute_resize(source,dest,finalSizeWidth,finalSizeHeight,ADM_imageInfo.aspectRatio)
  57. if(resizer is None):
  58. exit()
  59. print("Resize to "+str(resizer.width)+"x"+str(resizer.height))
  60. source.apply_resize(resizer)
  61. ############################
  62. # Handle audio....
  63. ############################
  64. tracks=adm.audioTracksCount()
  65. print("We have "+str(tracks)+ " audio tracks.")
  66. if tracks==0:
  67. gui.displayError("Audio","No audio tracks!")
  68. exit()
  69. for i in range(0,tracks):
  70. print("Processing track "+str(i))
  71. encoding=adm.audioEncoding(i)
  72. fq=adm.audioFrequency(i)
  73. channels=adm.audioChannels(i)
  74. reencode=False
  75. # 1 check frequency
  76. if(fq != 48000):
  77. adm.audioSetResample(i,48000)
  78. reencode=True
  79. if(not(encoding in supported)):
  80. reencode=True
  81. if(True==reencode):
  82. if(channels!=2):
  83. adm.audioSetMixer(i,"STEREO")
  84. adm.audioCodec(i,"Aften","bitrate=224","mode=0")
  85. ##################################
  86. # Video
  87. ##################################
  88. ff_ar=0
  89. if(resizer.ar==ADM_image.AR_16_9):
  90. ff_ar=1
  91. #
  92. 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")
  93. ###################################
  94. # Container = Mpeg PS/DVD
  95. ###################################
  96. adm.setContainer("ffPS","muxingType=2","acceptNonCompliant=False","muxRatekBits=11000","videoRatekBits=9800","bufferSizekBytes=224")