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.

PSP.py 3.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ###############################################
  2. # Convert to SVCD adm tinypy script
  3. # Mean 2011
  4. ###############################################
  5. import ADM_imageInfo
  6. import ADM_image
  7. finalSizeWidth=480 # Start with DVD target, we'll adjust later
  8. finalSizeHeight=[272,272,272]
  9. #
  10. #
  11. adm=Avidemux()
  12. ##########################
  13. # Compute resize...
  14. ##########################
  15. source=ADM_image.image()
  16. dest=ADM_image.image()
  17. desc=""
  18. true_fmt=ADM_imageInfo.get_video_format(desc)
  19. if(true_fmt is None):
  20. raise
  21. fmt=true_fmt
  22. if(true_fmt==ADM_image.FMT_FILM):
  23. fmt=ADM_image.FMT_NTSC
  24. source.width=adm.getWidth()
  25. source.height=adm.getHeight()
  26. source.fmt=fmt
  27. dest.fmt=fmt
  28. print("Format : "+str(fmt))
  29. dest.width=16
  30. dest.height=16
  31. #*****************************
  32. # Dialog...
  33. #*****************************
  34. #
  35. mnuResolution = DFMenu("Resolution:");
  36. mnuSourceRatio = DFMenu("Source Aspect Ratio:");
  37. mnuSourceRatio.addItem("1:1")
  38. mnuSourceRatio.addItem("4:3")
  39. mnuSourceRatio.addItem("16:9")
  40. dlgWizard = DialogFactory("auto PSP ("+desc+")");
  41. dlgWizard.addControl(mnuSourceRatio);
  42. res=dlgWizard.show()
  43. if res!=1:
  44. exit()
  45. source.ar=mnuSourceRatio.index
  46. dest.ar=1
  47. resizer=source.compute_resize(source,dest,finalSizeWidth,finalSizeHeight,ADM_imageInfo.aspectRatio)
  48. if(resizer is None):
  49. exit()
  50. print("Resize to "+str(resizer.width)+"x"+str(resizer.height))
  51. source.apply_resize(resizer)
  52. ############################
  53. # Handle audio....
  54. ############################
  55. adm.audioClearTracks()
  56. adm.audioAddTrack(0)
  57. adm.audioSetResample(0,48000)
  58. adm.audioSetMixer(0,"STEREO")
  59. adm.audioCodec(0,"Faac","bitrate=160")
  60. ##################################
  61. # Video
  62. ##################################
  63. adm.videoCodec("x264", "general.params=CBR=500", "general.threads=99", "general.fast_first_pass=True", "level=30", "vui.sar_height=1", "vui.sar_width=1",
  64. "MaxRefFrames=2", "MinIdr=0", "MaxIdr=250", "i_scenecut_threshold=40", "intra_refresh=False", "MaxBFrame=2", "i_bframe_adaptive=0",
  65. "i_bframe_bias=0", "i_bframe_pyramid=0", "b_deblocking_filter=False", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0", "cabac=True",
  66. "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=False", "analyze.b_i4x4=True", "analyze.b_i8x8=False", "analyze.b_p8x8=True", "analyze.b_p16x16=False",
  67. "analyze.b_b16x16=False", "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=3",
  68. "analyze.chroma_offset=0", "analyze.me_method=0", "analyze.me_range=16", "analyze.mv_range=-1", "analyze.mv_range_thread=-1", "analyze.subpel_refine=7", "analyze.chroma_me=True", "analyze.mixed_references=True",
  69. "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True", "analyze.dct_decimate=True",
  70. "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0",
  71. "ratecontrol.qp_constant=0", "ratecontrol.qp_min=0", "ratecontrol.qp_max=32", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0",
  72. "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0", "ratecontrol.ip_factor=1.000000", "ratecontrol.pb_factor=1.000000", "ratecontrol.aq_mode=1",
  73. "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")
  74. ###################################
  75. # Container = Mpeg PS/DVD
  76. ###################################
  77. #
  78. #
  79. adm.setContainer("MP4", "muxerType=1", "useAlternateMp3Tag=True")