News:

--

Main Menu

Batch Resizing with varying frame heights

Started by anyluck, August 24, 2013, 07:21:57 AM

Previous topic - Next topic

anyluck

Hello Everyone!!

I LOVE avidemux for quick edits..  then I found out I can batch resize files which i desperately need to do to improve performance on my video stream.

I have the following resize.js code:
//AD  <- Needed to identify //
//--automatically built--


adm.videoCodec("x264", "general.params=AQ=20", "general.threads=99", "general.fast_first_pass=True", "level=31", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=2", "MinIdr=100", "MaxIdr=500", "i_scenecut_threshold=40", "MaxBFrame=2", "i_bframe_adaptive=0", "i_bframe_bias=0", "i_bframe_pyramid=0", "b_deblocking_filter=False", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0", "cabac=True", "interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=False"
, "analyze.b_i8x8=False", "analyze.b_p8x8=False", "analyze.b_p16x16=False", "analyze.b_b16x16=False", "analyze.weighted_pred=0", "analyze.weighted_bipred=False", "analyze.direct_mv_pred=0", "analyze.chroma_offset=0", "analyze.me_method=0", "analyze.mv_range=16", "analyze.subpel_refine=7", "analyze.chroma_me=False", "analyze.mixed_references=False", "analyze.trellis=1", "analyze.psy_rd=0.000000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True", "analyze.dct_decimate=False", "analyze.noise_reduction=0", "analyze.psy=True"
, "analyze.intra_luma=21", "analyze.inter_luma=21", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=0", "ratecontrol.qp_max=0", "ratecontrol.qp_step=0", "ratecontrol.bitrate=0", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0", "ratecontrol.ip_factor=0.000000", "ratecontrol.pb_factor=0.000000", "ratecontrol.aq_mode=0", "ratecontrol.aq_strength=0.000000", "ratecontrol.mb_tree=False", "ratecontrol.lookahead=0");
adm.addVideoFilter("swscale", "width=320", "height=240", "algo=2", "sourceAR=1", "targetAR=1");
adm.audioCodec(0, "copy");
adm.setContainer("AVI", "odmlType=1");


..triggered by resize_mp4.bat:
set avidemux="C:\Program Files\avidemux_2.6.1_win64\avidemux.exe"
for %%f in (*.mp4) do %avidemux% --load "%%f" --run "C:\WMT PREP\resize.js" --save "%%f_resized.mp4" --quit


...this would work like a charm..  but I need a wildcard to insert into the "height=240" field of the .js file.
All of the frame widths and heights vary, and if I can set them to a fixed width while maintaining aspect ratio that would be perfect.. but the heights will still vary..

Is there any way to code the .js to indicate all files need to be resized to 320 pixels wide, while maintaining original aspect ratio, and let the frame height vary from file to file??

Any help is greatly appreciated!!!
Thanks for such a powerful tool!


anyluck

since im thinking there might be no solution to this.. i scripted the following in autohotkey to automate this process...

^+r::
Loop {
WinWaitActive, VIDEO PREP
        Sleep, 500
IfWinExist, VIDEO PREP
WinActivate
        Send {F2}
        Send ^c
        Send {ESC}
        Send +{F10}
        Send h
        Send a
WinWaitActive, Avidemux
        Sleep, 500
IfWinExist, Avidemux
WinActivate
        Send ^!f
WinWaitActive, Video Filter Manager
        Sleep, 500
IfWinExist, Video Filter Manager
WinActivate
        Click 251,413
        Click 251,413
WinWaitActive, Resize
        Sleep, 500
IfWinExist, Resize
WinActivate
        Click 90,155
        Click 90,155
        Send 320
        Send {Enter}
        Send {Enter}
        Sleep 500
        Click 92,195
        Sleep 500
        Click 92,303
        Send ^s
        Sleep 500
        Send C:\VIDEO PREP\RESIZED\{Enter}
        Sleep 500
        Send ^v
        Sleep 500
        Send _resized{Enter}
        WinWaitClose, Encoding...
WinWaitActive, Info
        Sleep, 500
IfWinExist, Info
WinActivate
        Send {Space}
        Sleep 500
        Send !{F4}
WinWaitActive, VIDEO PREP
        Sleep, 500
IfWinExist, VIDEO PREP
WinActivate
        Send {Down}
}


...the only problem is, Avidemux has a bug in which every 5-7 videos or so will crash when you paste the filename in the text field when saving....  very very frustrating as I was *so* close to automating this procedure on the thousands of videos that I have to resize.

Anyone have any input on this????? I'm sure someone out there had to batch resize videos with varying resolutions to conform to a certain width... Any help at all is greatly appreciated.....

tuxutat

Avidemux isn't really the best tool for this, use ffmpeg instead. I do some resizing with that myself, here's a commandline for what you want to do:

ffmpeg -i "input.mp4" -vf scale=w=320:h=-1 -crf:v 20 -acodec copy -vcodec libx264 -threads 0 -f mp4 -y "output.mp4"

Get it from here: http://ffmpeg.zeranoe.com/builds/

anyluck

AMAZING!! I am eternally grateful!!
Cant wait till i get to that machine to try it out! Thanks again!

Can input.mp4 and output.mp4 be wildcards so i can run it as a batch? or does this require that i specify a file each time?

tuxutat

You'll have to use "for .. in .." like in your first post.

anyluck

tuxutat.. may you live for a thousand years.