Sample script : Convert a whole folder

Started by mean, March 09, 2014, 07:24:33 AM

Previous topic - Next topic

mean

The attached script will prompt for a folder and re-encode all the mkv file in it
Additionnaly, it will deinterlace the video and encode it to h264

I use it to store some  DVDs of a sitcom i'm watching

The process is makemkv to extract the episods as-is + this script

I12learn

Sorry Mean,
the better reading, for that small  program, is to exceed not 80 columns width.
Also I don't get why not to put the encoding in a variable. Would be better if can be imported, too  8)

Jan Gruuthuse

As this is not a program but a script containing instructions, you can have issues with 80 columns width. If reading this script is an issue. You best you use a combined text and source code editor.
- Windows: notepad++
- OS x: TextWrangler
- Linux: Gedit
or similar program.

If issue while executing the script: command line instructions have to be in one line, nothing much could be done about this. (in my user experience)

I12learn

Editors like kate and gedit can cope for a width of 32768 characters, but i fairly hard to read.

Jan Gruuthuse

the point was these can show formated output instead of txt only

TheTooleMan

I am looking for a script to perform exactly the function described in the initial post. Apparently the attached script is no more. Any pointers to it or a more current version would be greatly appreciated.  8)

eumagga0x2a

You could start at https://avidemux.org/smif/index.php/topic,19456.msg91175.html#msg91175

To add Yadif filter outputting deinterlaced picture for each field, add

adm.addVideoFilter("yadif", "mode=1", "parity=0", "deint=0")
at the appropriate location (after adm.videoCodec()), paying attention to indentation (Python uses indentation for code nesting).

If you export to MP4, please note that the list of parameters has been extended in current nightlies:

adm.setContainer("MP4", "muxerType=0", "optimize=0", "forceAspectRatio=False", "aspectRatio=1", "displayWidth=1280", "rotation=0", "clockfreq=0")
(displayWidth added). "optimize=0" disables time-consuming rewrite of the entire output file at the cost of making it not fit for streaming.

TheTooleMan

Thanks for the pointer to your script! I will use it as the basis for my own with some additional settings for the video codec.

I still have a question, though. In the "convert" procedure, there isn't any code which sets markerA and markerB, and the ClearSegment and AddSegment statements are missing. Are segments and markers required for Avidemux to properly encode video? Every time I save a project, markers and segments are created.

eumagga0x2a

#8
If the default segment layout fits the task (a single segment spanning the video file from the first keyframe to the end and the selection which extends from zero to the end of video), these statements can be skipped. Please note that the part with the default segment layout starting at the first keyframe PTS rather than at the zero time is relatively new.

Quote from: TheTooleMan on June 25, 2022, 05:17:10 PMEvery time I save a project, markers and segments are created.

Yes, this is fine this way, avoids ambiguity.

mosiclover

I cannot find your attachment?
Quote from: mean on March 09, 2014, 07:24:33 AMThe attached script will prompt for a folder and re-encode all the mkv file in it
Additionnaly, it will deinterlace the video and encode it to h264

I use it to store some  DVDs of a sitcom i'm watching

The process is makemkv to extract the episods as-is + this script