Author Topic: Batch processing AVI to MP4 (H.264)  (Read 15250 times)

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Batch processing AVI to MP4 (H.264)
« Reply #15 on: March 29, 2012, 11:41:46 AM »
avidemux should start and close while doing reset, then start avidemux and start processing your video. each time.
Not familiar with windows, don't even know if this can be done this way. Is far beyond me, not having windows.
Perhaps some more experienced people should step in here and see if there is still a user solution to this, or it has to be referred to the developers? In this case it might be useful you provide a sample of the used home video .avi approx. size 20 MB. Upload and provide a link to it.
I've done similar in this posting: only 1st time processing possible

Ahari

  • Newbie
  • *
  • Posts: 16
Re: Batch processing AVI to MP4 (H.264)
« Reply #16 on: March 29, 2012, 11:56:51 AM »
So close and yet so far! I'm now stumped! I am about to give up and try another program - maybe a break will help!

Jan, you have been a great help 8) thank you for your enormous patience and time.

Maybe it is time for a bug report? I don't think a video sample would help as the issue is the encoder crashing Avidemux when run from a batch file?

Is there anyone out there advanced enough who can help with this issue which (as far as I can see) has basically dissolved down to:
How to get 2 pass (average bitrate) x264 encoding to work from a batch file.
« Last Edit: March 29, 2012, 11:59:37 AM by Ahari »

Ahari

  • Newbie
  • *
  • Posts: 16
Re: Batch processing AVI to MP4 (H.264)
« Reply #17 on: March 30, 2012, 11:35:28 AM »
I am in the company of experts!

My thanks to everyone for your patient help - especially Jan Gruuthuse! What a great forum.

By changing to CRF mode all my problems have disappeared!! After some tests, I have settled on CRF 18 - seems to work well for my videos. Processing is faster too. Wish I had thought of this long ago! Comments anyone?

Last question (I hope!): By de-interlacing, the frames appear much sharper, but the video playback is more jerky and not as smooth. I heard that if you deinterlace you should increase the fps from 25 to 50 (I'm on PAL).

Is that right and if so, what is the best way to do it?

Some Googling revealed lots of different opinions on whether to even de-interlace or not.

What to do?

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Batch processing AVI to MP4 (H.264)
« Reply #18 on: March 30, 2012, 12:39:48 PM »
if the output is on flatscreen tv (hdmi, ...) I would not deinterlace, deinterlace would sometimes help on computer displays. interlaced is most of the times TV originated and if the target is again the TV, I would keep it that way.
The best judge is of course yourself, make some sample clips and do test with these for comparing the best result in your opinion.
And this is just my opinion.
What is Deinterlacing? Facts, solutions, examples.
Rule of Thumb: deinterlacing blurrs picture. interlaced pictures show 'steps/lines'. whatever you do - you do wrong.

Ahari

  • Newbie
  • *
  • Posts: 16
Re: Batch processing AVI to MP4 (H.264)
« Reply #19 on: March 30, 2012, 12:44:40 PM »
Thanks, I will do some experimenting.

Going on holiday for a week now, so please forgive my lack of response to any posts while away!

Ahari

  • Newbie
  • *
  • Posts: 16
Re: Batch processing AVI to MP4 (H.264)
« Reply #20 on: April 10, 2012, 10:27:03 AM »
Well, I'm back from holiday and have sorted out my problems now!

Thanks Jan for the excellent link about "What is Deinterlacing?". A very good read.

My final settings:
I am using CRF 18 which gives me excellent quality and small file sizes.
The batch file runs perfectly.
Code: [Select]
SETLOCAL

set avidemux="C:\Program Files\Avidemux 2.5\avidemux2.exe"
set myjob="_avitomp4.js"
for %%f in (*.avi) do %avidemux% --force-alt-h264 --load "%%f" --run %myjob% --save "%%~nf.mp4" --quit
pause

ENDLOCAL
The name of my job file is titled like that so that it appears at the top of my folder when I run it - easier to find amongst my video files.
The "SETLOCAL" and "ENDLOCAL" are there to make sure the variables used are only used for this session and don't mess with the global variables in Windows - not really necessary, but keeps it clean.
I decided after much testing to deinterlace using the Yadif filter set to "Bob, Temporal & Spacial check, Bottom field first". This seemed to play back better on both my PC and TV and the file sizes were acceptably only a bit larger. By doing this the frame rate is increased to 50 fps and playback is very smooth and crisp.

For anyone who is interested these are the settings in my project file:
Code: [Select]
//AD  <- Needed to identify//
//--automatically built--
var app = new Avidemux();

//** Postproc **
app.video.setPostProc(3,3,0);

app.video.fps1000 = 25000;

//** Filters **
app.video.addFilter("YADIF","mode=1","order=0");

//** Video Codec conf **
app.video.codecPlugin("32BCB447-21C9-4210-AE9A-4FCE6C8588AE", "x264", "AQ=18", "<?xml version='1.0'?><x264Config><presetConfiguration><name>Alan's settings for converting Canon's DVCPro AVI files to H264 MP4 files for archiving</name><type>user</type></presetConfiguration><x264Options><fastFirstPass>true</fastFirstPass><threads>0</threads><deterministic>true</deterministic><sliceThreading>false</sliceThreading><threadedLookahead>-1</threadedLookahead><idcLevel>-1</idcLevel><vui><sarAsInput>true</sarAsInput><sarHeight>1</sarHeight><sarWidth>1</sarWidth><overscan>undefined</overscan><videoFormat>undefined</videoFormat><fullRangeSamples>true</fullRangeSamples><colorPrimaries>undefined</colorPrimaries><transfer>undefined</transfer><colorMatrix>smpte240m</colorMatrix><chromaSampleLocation>0</chromaSampleLocation></vui><referenceFrames>4</referenceFrames><gopMaximumSize>250</gopMaximumSize><gopMinimumSize>0</gopMinimumSize><scenecutThreshold>40</scenecutThreshold><periodicIntraRefresh>false</periodicIntraRefresh><bFrames>6</bFrames><adaptiveBframeDecision>2</adaptiveBframeDecision><bFrameBias>0</bFrameBias><bFrameReferences>normal</bFrameReferences><loopFilter>true</loopFilter><loopFilterAlphaC0>0</loopFilterAlphaC0><loopFilterBeta>0</loopFilterBeta><cabac>true</cabac><openGop>disabled</openGop><interlaced>disabled</interlaced><constrainedIntraPrediction>false</constrainedIntraPrediction><cqmPreset>flat</cqmPreset><intra4x4Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intra4x4Luma><intraChroma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intraChroma><inter4x4Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></inter4x4Luma><interChroma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></interChroma><intra8x8Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></intra8x8Luma><inter8x8Luma><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value><value>16</value></inter8x8Luma><analyse><partitionI4x4>true</partitionI4x4><partitionI8x8>true</partitionI8x8><partitionP8x8>true</partitionP8x8><partitionP4x4>false</partitionP4x4><partitionB8x8>true</partitionB8x8><dct8x8>true</dct8x8><weightedPredictionPframes>smart</weightedPredictionPframes><weightedPrediction>true</weightedPrediction><directPredictionMode>auto</directPredictionMode><chromaLumaQuantiserDifference>0</chromaLumaQuantiserDifference><motionEstimationMethod>multi-hexagonal</motionEstimationMethod><motionVectorSearchRange>28</motionVectorSearchRange><motionVectorLength>-1</motionVectorLength><motionVectorThreadBuffer>-1</motionVectorThreadBuffer><subpixelRefinement>10</subpixelRefinement><chromaMotionEstimation>true</chromaMotionEstimation><mixedReferences>true</mixedReferences><trellis>allModeDecisions</trellis><fastPSkip>true</fastPSkip><dctDecimate>true</dctDecimate><psychoRdo>1</psychoRdo><psychoTrellis>0</psychoTrellis><noiseReduction>0</noiseReduction><interLumaDeadzone>21</interLumaDeadzone><intraLumaDeadzone>11</intraLumaDeadzone></analyse><rateControl><quantiserMinimum>10</quantiserMinimum><quantiserMaximum>30</quantiserMaximum><quantiserStep>4</quantiserStep><maximumConstantRateFactor>0</maximumConstantRateFactor><averageBitrateTolerance>1</averageBitrateTolerance><vbvMaximumBitrate>0</vbvMaximumBitrate><vbvBufferSize>0</vbvBufferSize><vbvInitialOccupancy>0.9</vbvInitialOccupancy><ipFrameQuantiser>1.4</ipFrameQuantiser><pbFrameQuantiser>1.3</pbFrameQuantiser><adaptiveQuantiserMode>variance</adaptiveQuantiserMode><adaptiveQuantiserStrength>1</adaptiveQuantiserStrength><mbTree>true</mbTree><frametypeLookahead>40</frametypeLookahead><quantiserCurveCompression>0.6</quantiserCurveCompression><reduceFluxBeforeCurveCompression>20</reduceFluxBeforeCurveCompression><reduceFluxAfterCurveCompression>0.5</reduceFluxAfterCurveCompression></rateControl><accessUnitDelimiters>false</accessUnitDelimiters><spsIdentifier>0</spsIdentifier><sliceMaxSize>0</sliceMaxSize><sliceMaxMacroblocks>0</sliceMaxMacroblocks><sliceCount>0</sliceCount><hrd>none</hrd></x264Options></x264Config>");

//** Audio **
app.audio.reset();
app.audio.codec("Faac",224,4,"e0 00 00 00 ");
app.audio.normalizeMode=0;
app.audio.normalizeValue=0;
app.audio.delay=0;
app.audio.mixer="NONE";
app.setContainer("MP4");
setSuccess(1);
//app.Exit();

//End of script

May it be of use to someone - I derived the settings after much reading and they seem to work very nicely.

My batch file is running as I type - there are over 2500 video clips spanning 6 years totalling over 30 hours of video. At the rate it is going, it should take about 60 hours for everything! My machine is very fast! At least I think so!

These files will be my archive of all my home videos and will take up only about 20% of the space of the original DV camera files. They will play back better on TV and PC and my Mede8er media player will recognise and play them too! I am very pleased to say the least!

Unless there are any further posts with comments or constructive criticism about my chosen methods, this will be my last post on this thread.

So, huge thanks again to everyone (mostly Jan Gruuthuse) for the patient help.

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Batch processing AVI to MP4 (H.264)
« Reply #21 on: April 10, 2012, 11:24:02 AM »
Thanks for sharing this with us.

Track11

  • Newbie
  • *
  • Posts: 1
Re: Batch processing AVI to MP4 (H.264)
« Reply #22 on: April 21, 2012, 01:59:02 PM »
Thank you for this batch file.
I hope someone can read my english.

I've got a problem witch batchprocessing. It starts to convert the first .avi file in the home folder and save it in the right way. Then it will load the second .avi file and the "ruibuildframeindex" loops all the time with no error or something.
This problem appears only by multiple audiolines. I have set the trigger on halt on no errors in the avidemux settings.

I would be glad by fixing this issue :)


Greetings from germany with best wishes :)

Jan Gruuthuse

  • Hero Member
  • *****
  • Posts: 6051
Re: Batch processing AVI to MP4 (H.264)
« Reply #23 on: April 22, 2012, 09:09:22 AM »
have a different folder for the  multiple audio tracks.