Author Topic: Need help with batch file please.  (Read 6174 times)

soupy

  • Newbie
  • *
  • Posts: 4
Need help with batch file please.
« on: September 16, 2013, 09:59:12 PM »
I am completely new to this program and am totally lost on how to create the correct batch file. I am trying to simply change all my AVI files to MKV files without changing anything else.

I have tried to create a project and that all works fine, but I don't know what to edit to make that project convert all AVI in the folder.

Here is a copy of the project that a created. It is for the movie Unstoppable. I need to edit Unstoppable out and replace it with a command to convert all files in F:/New folder/. This is where I dragged all AVI files. So there is nothing but AVI files in that folder. Any help would be greatly appreciated.

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

adm = Avidemux()
adm.loadVideo("F:/New folder/Unstoppable (2010) [720p].avi")
adm.clearSegments()
adm.addSegment(0, 0, 5910385605)
adm.markerA = 0
adm.markerB = 5910385605
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.audioAddTrack(0)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")

Thanks,
Soupy

soupy

  • Newbie
  • *
  • Posts: 4
Re: Need help with batch file please.
« Reply #1 on: September 16, 2013, 10:32:06 PM »
I just tried the 64bit version and same thing. Everything works with one file but I can't seem to figure out what to change for multiple files in one folder. Both builds are 2.6.5.

Does it matter if the AVI are not all the same. Some are 720p, DVD, and SD. Some may have multiple audio but I am not trying to to change any of that. I did notice in my my project I created it is stating frame width=1280. Is that a problem?

Here is copy of project from 64bit version.

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

adm = Avidemux()
adm.loadVideo("F:/New folder/Unstoppable (2010) [720p].avi")
adm.clearSegments()
adm.addSegment(0, 0, 5910385900)
adm.markerA = 0
adm.markerB = 5910385900
adm.videoCodec("Copy")
adm.audioClearTracks()
adm.audioAddTrack(0)
adm.audioCodec(0, "copy");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10967
Re: Need help with batch file please.
« Reply #2 on: September 17, 2013, 06:04:56 AM »
adm = Avidemux()
adm.loadVideo("F:/New folder/Unstoppable (2010) [720p].avi")
adm.setContainer("MKV", "forceDisplayWidth=False", "displayWidth=1280")
adm.save("blah blah.mkv")

soupy

  • Newbie
  • *
  • Posts: 4
Re: Need help with batch file please.
« Reply #3 on: September 17, 2013, 11:03:32 AM »
Thanks Mean, That works for the one movie, but I am trying to the whole folder which has all avi files. I don't how to point to the folder to run all files. Plus some files may have a different display width. Not sure if what I want to do is even possible?

I would like it to grab all files in F:/New folder which only has avi files but some are 720p, DVD, SD etc. Basically just wanting to convert avi to mkv.

Thanks again,
Soupy

mean

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10967
Re: Need help with batch file please.
« Reply #4 on: September 17, 2013, 11:24:29 AM »

soupy

  • Newbie
  • *
  • Posts: 4
Re: Need help with batch file please.
« Reply #5 on: September 17, 2013, 11:45:55 AM »
Thanks again mean for your help! I think this might just be over my head. I have no ideal what I am looking at in those links. I was kinda hoping it would be as simple as changing something in "adm.loadVideo("F:/New folder/Unstoppable (2010) [720p].avi")" of the project to point to all movies and not just the one. Maybe I should just stick to manually doing them.


EEMcGee

  • Jr. Member
  • **
  • Posts: 64
Re: Need help with batch file please.
« Reply #6 on: October 04, 2013, 02:05:23 AM »
I've been working on learning to do some batch scripts too.  If you don't do any of the clear or add segment stuff, I believe it will just use the whole video.  Here is a batch file I just made for processing all avi files in the directory you put it into and run it.
I just cut down a project file (.py) I had saved to use the encoding settings and saved it as "recode animation.py".  Then in the batch file I referenced it.  Remember it has to be in the same directory as the batch file.  The x264 settings I used here are something I worked out that seems to be working well for recoding recordings of my kids TV shows into much smaller files that still have all the visual quality.  Here are the Batch and script.

--ANIMATION MP4.BAT--

set avidemux="C:\Program Files\Avidemux 2.6 - 64bits\avidemux.exe"
for %%f in (*.avi) do %avidemux% --load "%%f" --run "recode animation.py" --save ${%%f.*}.avi --quit

--recode animation.py--

adm = Avidemux()
adm.videoCodec("x264", "general.params=AQ=22", "general.threads=99", "general.fast_first_pass=True", "level=4294967295", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=16", "MinIdr=60", "MaxIdr=600", "i_scenecut_threshold=30"
, "intra_refresh=False", "MaxBFrame=16", "i_bframe_adaptive=2", "i_bframe_bias=30", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=1", "cabac=True"
, "interlaced=False", "constrained_intra=False", "tff=True", "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=False", "analyze.b_i8x8=True", "analyze.b_p8x8=True", "analyze.b_p16x16=True"
, "analyze.b_b16x16=True", "analyze.weighted_pred=2", "analyze.weighted_bipred=True", "analyze.direct_mv_pred=3", "analyze.chroma_offset=0", "analyze.me_method=2", "analyze.me_range=32", "analyze.mv_range=-1"
, "analyze.mv_range_thread=-1", "analyze.subpel_refine=8", "analyze.chroma_me=True", "analyze.mixed_references=True", "analyze.trellis=1", "analyze.psy_rd=0.400000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True"
, "analyze.dct_decimate=True", "analyze.noise_reduction=0", "analyze.psy=True", "analyze.intra_luma=8", "analyze.inter_luma=30", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=10"
, "ratecontrol.qp_max=60", "ratecontrol.qp_step=8", "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.600000", "ratecontrol.pb_factor=1.600000", "ratecontrol.aq_mode=2", "ratecontrol.aq_strength=0.500000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=80")
adm.audioClearTracks()
adm.setSourceTrackLanguage(0,"eng")
adm.setSourceTrackLanguage(1,"eng")
adm.audioAddTrack(0)
adm.audioCodec(0, "Faac", "bitrate=224");
adm.audioSetDrc(0, 0)
adm.audioSetShift(0, 0,0)
adm.setContainer("MP4V2", "optimize=0", "add_itunes_metadata=0")


I hope this helps and would like feedback from others on If there is a way to make this better.

EEMcGee

  • Jr. Member
  • **
  • Posts: 64
Re: Need help with batch file please.
« Reply #7 on: October 05, 2013, 05:35:53 AM »
Here is a revision of the ANIMATION MP4.BAT file.  It names the files properly and doesn't add the original files extension on as part of the file name.

set avidemux="C:\Program Files\Avidemux 2.6 - 64bits\avidemux.exe"
for %%F in (*.avi) do %avidemux% --load "%%F" --run "recode animation.py" --save "%%~nF.mp4" --quit