script for batch converting not changing container anymore.

Started by xxredxpandaxx, December 03, 2016, 05:16:32 AM

Previous topic - Next topic

xxredxpandaxx

I have been using a script for a couple months now to change my videos from h.264 to h.265 and also change everything to a mkv extension. But now when I use it, it keeps the same extension as the original.

Here is my script.
#PY  <- Needed to identify #
#--automatically built--

gui = Gui()
adm = Avidemux()
inputFolder = "C:/Users/server/Documents/h.26x/files/h.264/"
outputFolder = "C:/Users/server/Documents/h.26x/files/h.265/"
ext = "mp4"
sep = "\\"
#
def convert(filein):
    filename = basename(filein)
    adm.loadVideo(filein)
    if(0 == adm.loadVideo(filein)):
        gui.displayError("oops","cannot load "+filein)
        raise
    adm.videoCodec("x265", "useAdvancedConfiguration=True", "general.params=AQ=20", "general.poolThreads=99", "general.frameThreads=99", "general.preset=", "general.tuning=", "general.profile=", "level=-1", "vui.sar_height=1"
    , "vui.sar_width=1", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40", "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "interlaced_mode=0"
    , "constrained_intra=False", "lookahead=40", "weighted_pred=2", "weighted_bipred=True", "cb_chroma_offset=0", "cr_chroma_offset=0", "me_method=3", "me_range=16", "subpel_refine=5", "trellis=1", "psy_rd=1.000000"
    , "fast_pskip=True", "dct_decimate=True", "noise_reduction=0", "noise_reduction_intra=0", "noise_reduction_inter=0", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "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=0", "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.300000"
    , "ratecontrol.aq_mode=2", "ratecontrol.aq_strength=1.000000", "ratecontrol.cu_tree=True", "ratecontrol.strict_cbr=False")
    adm.audioClearTracks()
    adm.setSourceTrackLanguage(0,"English")
    adm.audioAddTrack(0)
    adm.audioCodec(0, "copy");
    adm.audioSetDrc(0, 0)
    adm.audioSetShift(0, 0,0)
    adm.setContainer("MKV")
    adm.save(outputFolder + sep +  filename)
    print("Done")

list = get_folder_content(inputFolder,ext)
if(list is None):
    raise
for i in list:
    convert(i)
print("Done")

Jan Gruuthuse


xxredxpandaxx

Quote from: Jan Gruuthuse on December 03, 2016, 06:07:39 AM
adm.save(outputFolder + sep +  filename + ".mkv")

Will that not just add a .mkv after the .mp4? Also isn't that the same thing as changing the extension manually? As in it's not really putting it in a mkv container?

Jan Gruuthuse

#3
check the properties of the video/container if it is mkv muxed.
not all OS require the extension to recognise mkv video (like linux, ...)

could be you need to test with
Quoteoutput-format, set output format (one arg )
--output-format    AVI | AVI_DUAL | AVI_UNP | ES | MP4 | OGM | PS | TS | MATROSKA
see: http://www.avidemux.org/admWiki/doku.php?id=using:command_line_usage

only tinypy scripts are supported (also on windows, if this your OS)