News:

--

Main Menu

Batch processing from another directory drive

Started by Leilu, November 15, 2021, 07:25:35 PM

Previous topic - Next topic

Leilu

Hi,

I try to re-encode all my course videos to HEVC so that they take up less space.

Here are my scripts and parameters:

ScriptAvidemux.bat
set avidemux="C:\Program Files\Avidemux 2.7 VC++ 64bits\avidemux_cli.exe"
: %%~nf returns the filename without the extension
for %%f in (*.mp4 *.mov *.mts) do %avidemux% --load "%%f" --run hevccpu.py --save "%%~nf.mkv" --quit
del *.mp4

hevccpu.py
#PY  <- Needed to identify #
#--automatically built--

adm = Avidemux()
adm.videoCodec("x265", "useAdvancedConfiguration=True", "general.params=AQ=30", "general.poolThreads=99", "general.frameThreads=0", "general.output_bit_depth=0", "general.preset=ultrafast", "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=2", "i_bframe_bias=0", "i_bframe_pyramid=1", "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.audioClearTracks()
adm.setSourceTrackLanguage(0,"und")
if adm.audioTotalTracksCount() <= 0:
    raise("Cannot add audio track 0, total tracks: " + str(adm.audioTotalTracksCount()))
adm.audioAddTrack(0)
adm.audioCodec(0, "copy")
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0, 0)
adm.setContainer("MKV", "forceAspectRatio=False", "displayWidth=1280", "displayAspectRatio=2", "addColourInfo=False", "colMatrixCoeff=2", "colRange=0", "colTransfer=2", "colPrimaries=2")

If I run ScriptAvidemux.bat from my D: or E: hard drive, it doesn't work. I have to put all my video and script files in a C: folder. How can I fix that?

I would also like to be able to re-encode the videos present inside subfolders instead of moving back and forth all my videos in the processing folder to their original sub-folders.

Finally, what setting do you recommend to be able to go back during playback every 5 seconds at most? With the current settings, when I click the seek bar of my video player, the increments are 10s between each keyframes. This is not ideal for me who often goes back a few seconds in videos.

Thanks. ;)

eumagga0x2a

Quote from: Leilu on November 15, 2021, 07:25:35 PMFinally, what setting do you recommend to be able to go back during playback every 5 seconds at most?

Please use the latest 2.8.0 nightly. It exposes time-based seek commands (which existed for years without many users noticing) in the GUI. Of course, seeking to pictures which are not keyframes is usually very slow, but this is how this universe works. The encoder decides which frame it encodes as a keyframe, so once a video has been created, keyframes cannot be moved by means other than re-encoding.

Regarding recursive operation, full path etc., please ask user "dosdan" for help.

szlldm

I think Leilu meant the seeking in the video player. The player probably jumps to a key frame, in this case you can try reencode with lowered maximum GOP length (MaxIdr parameter in case of x265)

eumagga0x2a

You are definitely right, I misread the question. I would only like to add that reduction of GOP size would also reduce compression rate (or quality). If the output HEVC stream doesn't need to be editable in copy mode, I would recommend enabling Open GOP in the configuration of the x265 encoder plugin. libx265 itself defaults to enabling Open GOP, a setting which Avidemux disables to avoid disappointing users who would discover that they cannot cut videos they had re-encoded using x265 in copy mode later without damaged pictures at cut points.

Leilu

#4
I enabled Open GOP and tried 100 instead of 250 for the max GOP size. It works great. My player seek bar jumps are around 3s now, which is way better. Thank you.

Any idea for my two first concerns?

Edit:
I did this, it kinda works.
set avidemux="C:\Program Files\Avidemux 2.7 VC++ 64bits\avidemux_cli.exe"
: %%~nf returns the filename without the extension
@echo off
for /R %%I in (*.mp4 *.mov *.mts *.ts); do %avidemux% --load "%%I" --run hevccpu.py --save "%%~fI.mkv" --quit;
del *.mp4 /s