[Solved] Batch conversion, avi 2 mp4

Started by I12learn, September 11, 2012, 09:16:44 AM

Previous topic - Next topic

I12learn

Hello Forum,
I'm new here and I landed to this forum because I was trying several methods to convert my videos from avi to mp4, which also my TV would plays.
Maybe wouldn'd be long, may be I'll like to discuss this my new trend :D

The most reason, to choose mp4, is because makes smaller size and it plays fine on all DLNA connection, including Sony TV.
Till now I got to try with several bash tools such as mkmp4, MBox4tools, mencoder, neroenc, aacencplus, they fail and the sound is asyncronous and varying on volume. Also hard to set a smaller size. Then avidemux does it as I want it done.
Since I didn't know about batch scripting, I'm just runnin the GUI and wait when one convertion finish to start another  :-\  :-\. Some time goes late on the night  :P  :P. Then I found the scripting, but I'm facing a couple of problems:
  • Generating a job will crash avidemux.
      The job is to set video as MPEG-4 AVC, set audio as AAC (Faac) and format as MP4 taking from their drop menus.
       I'd like to do some audio equalization, preferred auto
  • Trying to copy the setting from the drop menu I didn't find a valid equivalent on video codecs for the script
  • I found some script over here, but importing as job will complain tha is not a valid EMACS script
Like it said here it seems to me that I miss something to change for the first example on the page top or the something.js is not a linux script for the second chance and doesn't do for mp4 encoding.
I know some scripting in python or bash, but it's difficult to get EMACS and java scripts.



OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

something.js is a saved project. Make all required/needed settings in GUI.
Save project. Edit project: remove reference to loaded video and remove maker settings
and call that project from script.
See basic usage here: 2.6 audio track switching in job.py

I12learn

As I wrote saving the job is crashing the app. Here's the report :
QuoteAssert failed :0
at line 386, file /build/src/avidemux_2.5.6/avidemux/ADM_encoder/adm_encConfig.cppADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
saveCrashProject()
ADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
A_saveWorkbench(char const*)
FileSel_ReadWrite(void (*)(char const*), int, char const*, char const*)
avidemux2_gtk() [0x52bf19]
HandleAction(Action)
guiCallback(_GtkMenuItem*, void*)
g_closure_invoke

g_signal_emit_valist
g_signal_emit
gtk_widget_activate
gtk_menu_shell_activate_item
Then I cannot get to the next step as you're suggesting.
This is what I get wrote, but is incomplete//AD  <- Needed to identify//
//--automatically built--
//--Project: /tmp/avid_prg

var app = new Avidemux();

//** Video **
// 01 videos source
app.load("/media/X&X&X/++++/*x*x*x.mp4");
//01 segments
app.clearSegments();
app.addSegment(0,0,148030);
app.markerA=0;
app.markerB=148029;

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

app.video.fps1000 = 23976;

//** Filters **
app.video.addFilter("mpresize","w=720","h=400","algo=0");

//** Video Codec conf **


The file was finish flawlessly, I was curious to know if was some problem around.


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

Download attachment toAvcMp4.js and save it somewhere you find it back.
Load a small video in avidemux 2.5.6.  From main menu: Load/Run Project and select toAvcMp4.js
Did this work?

Jan Gruuthuse

the next step would be to have a script calling that project.
This script would search for all avi's in /Home/Videos and
#!/bin/bash
for FIL in `ls ~/Videos/*avi | sort` ; do
  /usr/bin/avidemux2_cli --force-alt-h264 --load "$FIL" --run ~/Videos/toAvcMp4.js --save ${FIL%.*}.mp4 --quit
done

you could exchange avidemux2_cli by avidemux2_gtk (for visual testing)
~/Videos/ would by the current users folder Videos in his/hers home folder where the videos are you want to process.
~/Videos/toAvcMp4.js if you use a different location for project, change accordingly.
Tested in Ubuntu 12.04 Terminal, could be small changes/convertion is needed for running in OS Archlinux.

I12learn

#5
Quote from: Jan Gruuthuse on September 11, 2012, 02:42:56 PM
Download attachment toAvcMp4.js
Thank you so much. I've apreciated very much your help. Well, I still have to try it out.

I found a similar script on the here's windows forum, but there are some particulars that differ.

A small question, can the very long line broke down on several ones?
Bash, python and other scripting languages allow to brake the long line with/without a special placeholder.
A smaller question :), can I change AQ value for some either smaller or better results?
I just guest AQ is likely that one on mencoder settings :P


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

Quote from: I12learn on September 11, 2012, 05:16:09 PM
A small question, can the very long line broke down on several ones?
I'm just a user, not a developer, programmer, script writer.
This one starting with: app.video.codecPlugin(... should be one line, I'm using gedit for these (ascii editor not word processor)
QuoteBash, python and other scripting languages allow to brake the long line with/without a special placeholder.
Not sure if this is possible, could be needed on one line as these are passed to encoder as parameter. Developers could perhaps enlighten us users on this one?
QuoteA smaller question :), can I change AQ value for some either smaller or better results?
I just guest AQ is likely that one on mencoder settings :P
AQ:  0 = High Quality, 51 = Low Quality. Looks like these are the minimum/maximum values for this setting in the filter.

I12learn

#7
Quote from: Jan Gruuthuse on September 11, 2012, 05:37:42 PM
Quote from: I12learn on September 11, 2012, 05:16:09 PM
A small question, can the very long line broke down on several ones?
I'm just a user, not a developer, programmer, script writer.
Ok i spent some time and I can assure that we can. I enclosed my embellished version. That gives more readabilty on the xml data.
The rules are very same to the other scripting. That's mean we can use for separation any number of space or tab or newline, just to close the paired delimiter evenly.

Quote from: Jan Gruuthuse
AQ:  0 = High Quality, 51 = Low Quality. Looks like these are the minimum/maximum values for this setting in the filter.
Well mencoder values are floating point and starting from 0.1 to 50.0. Here I've to believe that you're right.
Low values means more accuracy, bigger file result, correct me if I'm wrong.

I also inform that I've tried the your setting. After loading the movie all gone well and I could add some of my liking, then I could save the project without crashes (including my own settings)
But I didn't see starting to save the conversion. I suppose that will go on the script.
...
/usr/bin/avidemux2_cli --force-alt-h264 --load "$FIL" --run ~/Videos/toAvcMp4.js --save ${FIL%.*}.mp4 --quit
...
EDIT
Finally I found the correct way to split long lines. It is like bash scripting or perhaps the readline library rule. The backslash "\" allows to move to the next line. There was the highlighting on gedit showing correctly that I was wrong, but I tought it was some strange behaviour of gedit. The attachment is the corrected one :P


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

#8
Yes, project loads only settings. When saving project, don't forget to remove references to current video loaded in avidemux_gtk. Bolded should be deleted.
Quote//** Video **
//** Video **
// 01 videos source
app.forceUnpack();
app.load("/media/DataSafe/Video/Wanderlust.avi");
//01 segments
app.clearSegments();
app.addSegment(0,0,140994);
app.markerA=0;
app.markerB=140993;
If problems remove app.forceUnpack(); to.

I12learn

#9
Yeah
I found that stops the process.
I got another problem, but is not related to avidemux. Name with space   :-\ :-\


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

Spaces in file and folder names are tricky. Same for foreign ascii: ß é ç ... Perhaps when enclosed in quotation marks?  ââ,¬Ëœ ââ,¬â,,¢ or ââ,¬Å" ââ,¬Â ?

I12learn

#11
this will take to modify IFS before doing the script and restore it upon completion.
Well my polished version doesn't work  :'(. Maybe I confused to upload the project  during my test. I'm gonna check EMACS rules. I'd like to see is we can import the xml file and leave it somewhere else.
For unicode I haven't had into that. I'm rather aware to avoid these novelties that aren't so necessary. Perhaps I'll rename the files before and after :P
New problem
[Variable bit rate stream]. Now the GUI stops to ask me what to do. I miss the fully automation


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

Do you have access to avidemux 2.6? If not can you build this yourself on archlinux? Think some issues do go away with this version.
Compiling Avidemux 2.6.x

I12learn

#13
Archlinux has a very good felxibility. The package is ready. Also available the svn version :P
BTW, do you think there's some problem with my current version?
I'm asking because the option app.forceUnpack(); seems having no effects. Is the new version let me skip the dialog when uploading the avi with packed vbr?

Other interests are driving me to adopt the custom menu of avidemx_GUI. After I'd include the option to scan a directory and repeat the conversion, all from within GUI. (I've read some detail). Supposed to widen the script with file/dir searching dialog box and the main loop all into the java script. But no time constrains (I should learn some more on java  ???  ???)


OS Archlinux x86_64 (or i868 on another PC), Avidemux 2.5.6, bash version 4.2.37(2)

Jan Gruuthuse

My understanding is 2.6 should handle new videos / codecs / containers better. You should be able to run 2.6 alongside 2.5.6. Sometimes 2.6 isn't handling 2.5.6 stuff and reverse.
Projects are not interchangeable 2.5 <> 2.6. There is also a developer Avidemux 2.6 Scripting Reference in 2.6 main menu help. Should be great help as you have more experience with scripting then I have.
2.5.6 is called by avidemu2_**** , 2.6 by avidemu3_****