News:

--

Main Menu

Batch file using varying transparencies

Started by adam, May 03, 2021, 05:34:42 AM

Previous topic - Next topic

adam

I have a working tinypy script that will convert (.MP4 to .mkv) an incoming video, add a transparency and rotate. The transparency is named such that swapping the extension from ".MP4" (of video file) to ".png" will pick up the correct file and add correctly. My output files are also renamed using this.

This is using a global variable created using "gui.fileReadSelect".

I am now trying to create a batch file that can work in similar fashion, I am currently trying to use a windows batch file to perform this but cannot create my global variable as I am not using the gui to select the video file.

Is there a command to get the current video filepath or can I pass a variable from a batch file into AVI Demux.
 

#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()
gui = Gui()


Video=gui.fileReadSelect("Select Video to convert")
adm.loadVideo(Video)
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", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40", "intra_refresh=False"
, "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0", "cabac=True", "interlaced=False"
, "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=True", "analyze.b_i8x8=True", "analyze.b_p8x8=True", "analyze.b_p16x16=False", "analyze.b_b16x16=False"
, "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=1", "analyze.chroma_offset=0", "analyze.me_method=1", "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", "analyze.trellis=1", "analyze.psy_rd=1.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True", "analyze.dct_decimate=True"
, "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=11", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10", "ratecontrol.qp_max=51"
, "ratecontrol.qp_step=4", "ratecontrol.bitrate=0", "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=1", "ratecontrol.ip_factor=1.400000"
, "ratecontrol.pb_factor=1.300000", "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.000000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")

# Rotate video
adm.addVideoFilter("rotate", "angle=180")
# Rotate Video

#Add Transparency
Trans = Video.replace('MP4','png')
adm.addVideoFilter("addLogo", "x=0", "y=0", "alpha=255", "logoImageFile=" + Trans, "fade=0")
#Add Transparency

adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")

## Audio mute
adm.audioAddTrack(0)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
## Audio Mute

#Save and rename Video
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280", "displayAspectRatio=0")
OldName = dirname(Video) + basename(Video)
NewName = OldName.replace('MP4','mkv')
adm.save(NewName)

butterw

If I understand correctly you want to specify the filepath in your bat file rather than use the Avidemux fileReadSelect dialog. 

I would assume it's possible to get the path of the current loaded file via Tinypy (untested with bat file).
ed = Editor()
Video=ed.getRefVideoName(0)


! The python string method replace works in Tinypy, but other python methods do not (the in operator also works)
Video.replace('MP4','png')

eumagga0x2a

Quote from: butterw on May 03, 2021, 08:38:52 AM! The python string method replace works in Tinypy, but other python methods do not (the in operator also works)
Video.replace('MP4','png')

Really good to know, I wasn't aware of that.

adam