How do I batch process - simple case where all files require the same settings

Started by MarkEMark, October 06, 2022, 01:39:21 PM

Previous topic - Next topic

MarkEMark

Hello, I can't find the answer to a seemingly trivial case.

Suppose I have DVDs of a TV series. And I've extracted all the VOBs.

I create a Project Script .py file of how I want the 1st episode converted.

How can I carry out batch processing so I can leave my PC running overnight instead of having to load a new project each time. As it's py, I thought that this would be simple, but it does not seem to be.

(I have even got to the point of creating the .py files for the entire series - with the different filenames and lengths).

If this is not possible, do any of you have ideas on how to achieve this using Avidemux (I do not really have time to learn another app)

Thanks

eumagga0x2a

Depending on location and naming scheme of source videos, you should decide whether you can use internal tinyPy scripting to load videos or have to do it on command line (i.e. via a batch / shell script).

Quote from: MarkEMark on October 06, 2022, 01:39:21 PMI create a Project Script .py file of how I want the 1st episode converted.

Would you mind posting the script minus the loadVideo part?

Quote from: MarkEMark on October 06, 2022, 01:39:21 PMI have even got to the point of creating the .py files for the entire series - with the different filenames and lengths

If you use just the default segment layout, you don't need to have addSegment and any other timing or length related methods in the script.



MarkEMark

Thanks eumagga0x2a

Here are the first two py files that I created. I did not have my DVD ones, so these are actually for a bluray.

<arghhh!!! I have tried several times to quote the py files but this forum interprets as spam!>

What you say makes sense but is just a bit beyond me. I work well from examples though so I would appreciate it if you could use these samples to create and example for me. As I can't post examples are you able to still construct a sample for me? It just needs to be from two similar py files that just have a different filename in both - e.g. 1x01.VOB and 1x02.VOB and the segment/markerB being appropriately different - which makes no difference to your sample, I suppose.

Thanks in advance - your help is very much appreciated!

eumagga0x2a

If CleanTalk prevents you both from posting scripts inline and from attaching them to your replies, please send me a personal message (PM) with the script attached (preferably) or inline in the body of the message.

The main piece of information I need from you besides the platform (Linux? macOS? Windows?) is the naming scheme and location of source video files. Having files named sequentially like 1x01.VOB, 1x02.VOB etc. in the same directory may result in Avidemux prompting for logical concatenation in the MPEG-PS demuxer.

To be able to help, I need to have a look at what you actually try to do (the word "converted" conveys practically no information).

eumagga0x2a

Thank you for the scripts. First of all, please remove

adm.setPostProc(3, 3, 0)
for good and disable post-processing in Preferences. If enabled, it can completely ruin the result if the source is interlaced (what I assume based on Yadif in the filter chain). Avidemux defaults for quite a long time to PP being disabled, but won't ignore existing configurations.

adm.addVideoFilter("crop", "top=2", "bottom=2", "left=10", "right=8", "ar_select=0")
I would also discourage cropping the picture. This may worsen compressibility as the dimensions aren't multiples of 16 anymore and makes it much more complicated to restore the original aspect ratio – if the source is a video DVD, the picture is probably anamorphics (it uses non-square pixels) and you should properly convey this property in the configuration of the muxer ("Force aspect ratio") and desirably also in the configuration of the video encoder.

adm.audioCodec(0, "LavAAC")
Are you forced to re-encode audio? If yes, is the first audio track of the DVD stereo (two channels)? Else the default 128 kbit/s bitrate may be too low.

Quote from: MarkEMarkThe setup time is not a problem for me, it's the leaving it to run converting which is causing hassle because I currently have to do one at a time.

As you don't use any filters or encoders which require hardware acceleration, you could use File --> Queue (Ctrl+U) and then let Avidemux Job Control (avidemux_jobs.exe) to batch-process all files in one go.

I repeat my warning regarding sequentially named VOB files in the same source directory.

Regarding the batch-processing directory contents using a tinyPy script, you could try the following one (not really tested):

#PY  <- Needed to identify #
#
adm = Avidemux()
ui = Gui()
sep = "\\"
#
# Function to convert an individual video
#
def convert(filein,out):
    if not adm.loadVideo(filein):
        ui.displayError("Oops","Cannot load \"" + filein + "\"")
        return 0

    adm.setPostProc(0, 0, 0)
    adm.videoCodec("x265", "useAdvancedConfiguration=False", "general.params=2PASSBITRATE=2048", "general.poolThreads=99", "general.frameThreads=0", "general.output_bit_depth=0", "general.preset=slow", "general.tuning=none", "general.profile=main"
, "level=-1", "vui.sar_idc=0", "vui.sar_height=1", "vui.sar_width=1", "vui.color_primaries=2", "vui.transfer_characteristics=2", "vui.matrix_coeffs=2", "MaxRefFrames=3", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40"
, "MaxBFrame=3", "i_bframe_adaptive=1", "i_bframe_bias=0", "i_bframe_pyramid=4294967295", "b_deblocking_filter=True", "b_open_gop=False", "interlaced_mode=0", "constrained_intra=False", "b_intra=True"
, "lookahead=40", "weighted_pred=2", "weighted_bipred=True", "rect_inter=False", "amp_inter=False", "limit_modes=False", "cb_chroma_offset=0", "cr_chroma_offset=0", "me_method=3", "me_range=16", "subpel_refine=5"
, "limit_refs=3", "rd_level=3", "psy_rd=1.000000", "rdoq_level=0", "psy_rdoq=0.000000", "fast_pskip=True", "dct_decimate=True", "noise_reduction_intra=0", "noise_reduction_inter=0", "strong_intra_smoothing=True"
, "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_step=4", "ratecontrol.bitrate=0", "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=2", "ratecontrol.aq_strength=1.000000", "ratecontrol.cu_tree=True", "ratecontrol.strict_cbr=False")
    adm.addVideoFilter("yadif", "mode=0", "parity=0", "deint=0")
    if adm.audioTracksCount() > 0:
        adm.audioClearTracks()
        adm.audioAddTrack(0)
        adm.audioCodec(0, "LavAAC")
    adm.setContainer("MKV", "forceAspectRatio=False", "displayWidth=1280", "displayAspectRatio=2", "addColourInfo=False", "colMatrixCoeff=2", "colRange=0", "colTransfer=2", "colPrimaries=2")

    filename = (splitext(filein))[0]
    filename += ".mkv"
    filename = basename(filename)
    return adm.save(out + sep + filename)
#
# Main
#
# -------- select input directory --------
inputFolder = ui.dirSelect("Select source folder")
if inputFolder is None:
    ui.displayError("Oops", "No source folder selected")
    return

# -------- read content --------
list = get_folder_content(inputFolder, "vob")
if list is None:
    ui.displayError("Oops", "No VOB files found in \"" + inputFolder + "\"")
    return

# -------- select output directory --------
outputFolder = ui.dirSelect("Select output folder")
if outputFolder is None:
    ui.displayError("Oops", "No output folder selected")
    return

if(inputFolder == outputFolder):
    ui.displayError("Error","Output folder cannot be the same as the input one")
    return

# -------- process --------
total = 0
counter = 0

for i in list:
    total += 1
    counter += convert(i, outputFolder)

if not counter:
    ui.displayInfo("Warning", "No files converted")
    return

if counter == 1:
    ui.displayInfo("Finished", "One file out of " + str(total) + " converted")
    return

ui.displayInfo("Finished", str(counter) + " files out of " + str(total) + " converted")

The line

    adm.setPostProc(0, 0, 0)
is there with the sole purpose to counteract post-processing eventually enabled in Avidemux Preferences.

Again, you might want to check display aspect ratio settings in the encoder and in the MKV muxer and adjust the script accordingly.

MarkEMark

Thank you for both of those methods. I will try them and let you know which works for me.

Also thanks for all the conversion tips - they were just sample files.

All the best!