For users of other Linux distributions there is a script that installs the programs available at http://progs.fangornsrealm.eu/install_linux.sh
for the current user. It also checks for the availability of external dependencies and tells the user if a program is missing.

I hope the new installation helpers make it more easy for normal users to take advantage of these scripts.

Edit:
I will no longer add new features to the pages here.
I will just announce new versions here and update the feature lists at the project page (http://fangornsrealm.eu)

I am still answering to requests and bug reports here

Hi,

As some of you might have noticed, I posted scripts for video conversion from time to time.

The purpose of this thread is to

create a location where to easily find the most recent version

answer question and requests in one place

Why use these scripts?

There are many other solutions for doing this job(s). Most of them have shiny graphical user interfaces,
some are for the command line, but most of them have limited or no batch processing capabilities. Also most
of them either have near to none or hundreds of settings. I did not find anything in between. So either you have
a tool that does just one job (and you cannot do something more specific) or you have a tool that has many
features, but you have to be a video encoding guru to know what exact settings you need to get the proper
results.

So I designed my scripts around two principles:

Batch processing

As I tend to have my computer running only when there is something to do, and I do not intend to sit in
front of it all the time to keep it busy, my scripts are designed to do perfect batch before they do
anything special. I am a huge fan of the command

Code:

for i in * ; do <programname> <options> $i ; done

that can keep your machine busy for quite some time.

Automatisms to choose proper settings for given source files and specified parameters

All my scripts use sensible defaults when no options are specified and automatisms to adjust
the settings if the user demands other features. So you will get something decent by default
and still can ask for special functions. (some scripts have quite a few options)

What can they do?

There are only three usage cases that you have to consider.

Ripping DVDs directly from DVD, from ISO files or from directory structure (ISO files or directory
structure are preferred for batch for obvious reasons)
riptoh264 provides this feature.

Conversion of (nearly) any other video source
menc provides this feature.

Anything that is common to those programs is outsourced into some scripts, avi2mkv for muxing the
output of the conversion to output containers (optionally considering limits of output containers
and playback devices concerning audio formats) and choose_x264_encoding_parameters.sh for choosing
correct encoding parameters (also optionally considering containerformat and geometry limits of
playback devices).

avi2mkv is also usable standalone when you have to transfer videos from a standard container
(for example AVI or MKV) to a container more advanced or suitable for the playback device.
Supported output containerformats are Matroska (.mkv), MPEG Transport Stream (.ts|.m2ts),
ISO MPEG4 (.mp4) or Ogg Movie (.ogm).
Matroska gives the most advanced options, like chaptermarks, subtitles (vobsub(dvd), srt, ass),
coverart. Only some of these options are supported for the other container formats
(partly for lack of support in the format, partly because I did not implement it yet).

As you might have recognized, the options are plenty. If you have a usage case you don't know if
these scripts will fit, just ask and we will try to figure it out.

Tips

For those who didn't know: you can use mplayer or ffmpeg to get information about a movie.
Encoding of video and audio, audio stream count, ids of multiple streams, in more modern container
formats like Matroska also languages of audio streams

Code:

mplayer <filename> -vo dummy -ao dummy -identify

Code:

ffmpeg -i <filename>

All my scripts have a block with the default settings directly after the big commented block.
Settings intended to be adjusted by the user are up front and specially marked. You have to set your
preferred language(s), your preferred containerformat, ...

My scripts assume that file and directory names to not include "weird" characters. For achieving
this goal I use the script dejunk presented further down on this page. But be careful. It assumes
that you know what you are doing and renames any files and subdirectories in the current working
directory. So please be sure that you have moved all files to rename into an own directory and are
actually there on the command line.

Important
I use handcompiled versions of mencoder, ffmpeg and x264 that I install to /usr/local/bin to not
distract installed programs depending on those packages every time I build a new version. If you
use packages maitained by portage or another way where only one version of the package is installed,
change the variables in the beginning of the script to

(Some other Distributions place the which program in /bin instead of /usr/bin)

Also the fileformat detection with mplayer assumes that mplayer delivers text output in english.
This means mplayer has to be compiled in an environment with

Code:

export LINGUAS="en"
or
export LINGUAS="en <something_other>"

So use

Code:

export LINGUAS="en" emerge mplayer

or if you build by hand

Code:

LINGUAS="en" ./configure <options>

to build your version of mplayer.

Dependencies:
yet to come

Finally! The programs:

Here is the list of programs, always newest version. For more information on a single program go to
the respective post.

Transfer audio/video streams to several containers. Basically this is a Matroska (.mkv)
container, but it supports ISO MP4 (.mp4), MPEG Transport Stream (.ts) and Ogg Media (.ogm).
(this is a dependency of all my encoding scripts)
http://progs.fangornsrealm.eu/avi2mkv/avi2mkv

All my encoding scripts use mencoder to produce h.264 video and mostly copied audio streams in AVI
containers. Additionally I have to convert .avi to .mkv on a regular basis to join up parts, add
second audio stream, add subtitles or chapter marks. So I have created a little script to do the job.

I called this script avi2mkv as this was the design goal for the first versions, but it can perform
nearly any operation on any input mkvmerge can read and I added more features - like other output
containers - after the main features worked.

What can it do?

create a .mkv containing video and up to two audio tracks

join multiple .avi files before converting to .mkv (this obviously only works for .avi files)

join video/audio with a second audio from seperate file

reverse audio stream order from input file or input file and external audio

add language tags to audio streams (specified in the script code)
Default: German and English

reverse the order of the language codes
for example: first audio stream is english not german

fix audio sync problems by inserting (positive or negative) delays

specify a distinct movie title saved into the title tag
Default: derive it from the name of the input file

Update 10.04.2009

split existing files up into elementary streams, remux video to mp4 container and build Matroska
file from there to overcome sync issues

Update 05.05.2009

drop audio in avi and merge up to two audio streams in external files instead (language settings
apply as normal)

Update 18.10.2009

mux subtitles into the output Matroska. DVD (vobsub) and Text format subtitles are supported.
It expects a comma seperated list of <filename>:<languagecode>.
For Example: -S sid1.idx:eng,sid2.idx:ger

if there are multiple audio tracks in source use language settings if available to determine correct streams

optionally use all internal audio streams when joining external audio
to a maximum of the number of defined languages minus the count of external audio files
(default: use the first (matching if language information is available) audio stream only)

specify on command line which internal stream(s) to use (-aid) when joining external audio

if source is Matroska and has subtitles, chapters or tags, transfer them to the target matroska container

Examples

This script is mostly used by my encoding scripts. But it is also usable standalone.

Source: AVI with 2 audio streams, the order of the audio streams is wrong (you prefer the second
stream as default).
You want a Matroska file with a specific title (that is shown in some players)
independent from the file name.

Code:

avi2mkv --reverse_audio_streams --title <new_title> <inputfile>

Source: AVI with 1 audio stream, second stream in external file. The stream in the AVI file is the one
you want first, but it is of the language you specified sesond.

Source: a series of AVI files that you want concatenated (filename for the outputfile will be derived
from first input file)

Code:

avi2mkv --join_avis <file1> <file2> ...

These are just some examples of basic usage. But when considering presets, containers and audio
conversion, examples get quite complex. If you have problems finding the correct combination or are
unsure if avi2mkv can do the job for you at all, just ask.

specify output video width and/or height on the command line
should only one parameter be given, video is scaled to calculated value given by specified value and source aspect ratio
and black borders are added if the selected x264 video preset/playback device demands it

rip dvds directly from the drive, from an iso/image or use a dump to the harddisk created by
"dvdbackup -M -i <inputdevice> -o <path> -n <moviename>"
(or any other program ripping the complete structure of the dvd)

rip the longest title (default) but can rip any title specified on command line

specify the name of the selected title seperately for ripping episodic serials for example

process two audio streams (defaults to german and english, but can reverse ordering on command line)

automatically scale anamorphic video to widescreen by flag in .mkv or in resolution when exporting to .avi

optionally specify output video width and/or height on the command line
should only one parameter be given, video is scaled to calculated value given by specified value and
source aspect ratio and black borders are added if the selected x264 video preset/playback device
demands it

added profile support using external script
choose_x264_encoding_parameters.sh (I wish to thank the developer(s) of h264enc
for providing this excellent collection of presets)

automatic audio language detection in MPEG Transport Streams (if available, else using default audio
stream) if no language settings are available and audio streams are not first
and then second, you have to specify streams on commandline!
Update 07.02.2010

optionally specify output video width and/or height
on the command line should only one parameter be given, video is scaled to
calculated value given by specified value and source aspect ratio and black
borders are added if the selected x264 video preset/playback device demands
it

if more than one audio stream of one preferred language is found, the first one is used,
regardless which format it has

BluRay/HDDVD/AVCHD processing

At the moment there is no support for reading .m2ts and AFAIK .evo directly. For
BluRay, HDDVD or AVCHD camcorders you have to repackage the input data into a
Transport stream (.ts).

Update:
Now there is no need for wine or the GUI anymore. I have written a
little Perl program that can do anything needed (nearly) automatically (not
completely automatically, but I am still developing it *wink* ).

bluray-info can not only display the contents of a BluRay directory structures,
it can also extract the titles to Mpeg Transport Streams (using the tsMuxeR
command line tool. Also it can export chaptermarks and Subtitles (subtitle
export is dependant on java and BDSup2Sub.jar). These features are available
under Linux and Windows!

Later the Perl version of blu2mkv will use bluray-info
to gather information and extract BluRay data from directories and ISOs
automatically.

Here is the manual process

Open the file to convert in tsMuxerGUI.exe (Windows)
and deselect the streams not to write into the .ts file (default output
setting). For each stream you can perform additional tasks, like converting
DTS-HD to DTS and TrueHD to AC3 (as my hardware cannot handle the new sound
formats). Keep in mind in which order you output the audio streams!

Hit the "Copy to Clipboard" button at the bottom of the windows

paste the clipboard
into a pure ascii file in notepad.exe, adjust path differences between the
virtual machine and your wine environment and save the file

in the linux command line run

Code:

wine tsMuxeR.exe <commandfile> outputfile.ts

process the outputfile.ts in blu2mkv as desired
Update: there is now also a linux version, so no need for wine any more. But the command line is the
same when using the CLI version. The GUI version still stops exporting from time
to time, but it can export clean <commandfile> for the CLI version.

I don't know about the hand-compiled version, but mplayer from portage also brings /usr/bin/midentify, which looks like this

Code:

#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.

The presets and most of the behaviour is copied directly from h264enc. So i wish to thank the author(s)
of h264enc for providing and maintaining this excellent collection of presets.
I do not have either the knowledge nor the time to collect these presets.

I added features specific to my scripts for checking container formats, audio formats, video geometries,
but all are depending on the data of h264enc.

Usage

This is a helper script used by my encoding programs. If you want to use it for your own projects, see
my encoding scripts for how to utilize it.

Changelog

13.03.2010
Rewritten the program in perl to remove unnecessary dependencies. This should make it usable on any platform that has Perl.
In the process I renamed the program to reflect the wider usage scenario.

As I reallized, tsMuxeR has problems reporting proper language codes. At least when the mastering of the BluRay uses non-ISO language codes.

So I decided to write my own little program to parse BluRay Playlists and export tsMuxeR .meta files.

Gratitude

This task would have been damned to fail if I didn't find an existing parser for .mpls files, namely mpls_dump developed by
developer(s) over at the handbrake forum. The library is still in development, but the parser works perfectly, so thanks to the developer(s)
for sharing this and sparing me some tremendous amount of work!

What can it do

The original tool does read binary .mpls file(s) and prints information about it with optional filters and multiple information levels.

I added features to output .meta files for tsMuxeR and optionally directly start tsMuxeR to export to .ts
Optionally it searches the longest Track of multiple playlists or output .meta (and also optionally .ts) files for all tracks given on command line
Optionally it removes all audio and subtitle streams that do not match up to two preferred languages.

The features of the original program are quite stable and relatively well tested in my reimplementation.
The new features added by me do work as far as I have them tested, but the handling is everything but foolproof.

Usage

go into the BluRay directory (or the BDMV directory) and call the program.
for example:

Code:

bluray-info BDMV/PLAYLIST/*

will list the durations of all the available titles. As does

Code:

bluray-info .

Code:

bluray-info --filter_short .

will display all titles longer than x seconds (default is 300 seconds).

There is a tip when your source has AC3 audio also. Choose this as first audio stream so it gets encoded into the AVI. Any further audio stream will sync up nicely when merged into the Matroska file, even if it is DTS.

Also I added the beginning support for x264 encoding profiles to blu2mkv. If you have experience with this, please review the implemented profiles and give comments or additional ones.

This is the significant part (maxrate is the hardware limit of my network player therefore I made it possible to disable this limit)

I found the solution for the dts sync problem. When recoding DTS audio to mp3 into the avi and merging the original dts stream(s) instead by hand (using mmg) the sync problem is gone.

I will post a new version of blu2mkv as soon as I have cleaned up the code a bit.

Unluckily this is far from the point where I want this script to be. I am a fan of "for i in * ; do blu2mkv $i ; done" but that is not going to happen soon. At the moment one will have to address for the special settings for each and every file by hand. But I will try to get a better solution, and if it is only for my convenience.

fangorn I just wanted to comment on the great work you are doing with your scripts. That's an interesting technique you use to merge the DTS stream avoiding sync issues. Can't wait to see what the final version will look like

I just added support for dropping the mp3 audio stream and adding up to two external audio streams instead to avi2mkv and blu2mkv. When using blu2mkv -m ... this is done automatically. You can also use avi2mkv on the command line

Code:

avi2mkv -i video_source.avi audio_stream_1 <audio_stream_2>

I am sorry, but this option still isn't available for .ts sources. For these you still have to demux/mux by hand. But now muxing is possible with avi2mkv instead of mmg._________________Video Encoding scripts collection | Project page

I've got to this post while searching for a way to convert MKVs into PS3 compatible M2TS files... tsMuxerGUI works for almost every file, but some modern MKVs include streams with formats that tsMuxer doesn't recognize...

... anyway, I'm really impressed by your effort and the quality of both your post and your scripts. I'm trying to learn from them... I'll take some time for sure!!!

I just posted an update to menc (which can crop black borders automatically now).

I am testing a major rewrite of riptoh264 right now. It already has support for cropping black borders and some telecining filters. Automatic detection of telecining and interlacing is still some testbed.

I am still working on (vobsub) subtitle support for riptoh264, blu2mkv (from Matroska source files) and avi2mkv. To implement it only once I am thinking about transplanting mkv merging engine from riptoh264 completely to avi2mkv. So I will update all the scripts approximately tomorrow, but riptoh264 will probably have no subtitle support.

I just updated avi2mkv and riptoh264 to the newest version. I will post blu2mkv when I have at least one successfull run. Testing just takes a little longer with HD.

riptoh264 is now dependent on avi2mkv for muxing Matroska containers.

avi2mkv now supports subtitles in vobsub and some text formats. This allowed me to add subtitle support to blu2mkv and riptoh264, but made the external muxing mechanism for riptoh264 necessary. For a complete listing of the changes, see the post containing the code._________________Video Encoding scripts collection | Project page

Profile support is implemented in only some of my scripts, but it is planned for all encoding scripts. In your case a forced resize of the video stream would also be advisable, but that is not a problem for implementation. As I wrote some posts before, I am always open for addition of more profiles. Main problem here is the export of .mp4. Not the encoding parameters. If export of MP4 works, there is not a problem in adding dozens of profile for mobile devices.

I will definately experiment with your suggestion. When it is doable in reasonable time I will implement it.

You are saying that mencoder can write .mp4 files directly for your device? I tried direct MP4 output once using ffmpeg and it seemed fairly broken.

I have tried adding .mp4 muxing to the features of blu2mkv more than once, but I failed miserably using mp4create or MP4Box. They refused to add an audio track to the .mp4 file.

In your case I would guess that menc is the script where the feature would have to be added.

Profile support is implemented in only some of my scripts, but it is planned for all encoding scripts. In your case a forced resize of the video stream would also be advisable, but that is not a problem for implementation. As I wrote some posts before, I am always open for addition of more profiles. Main problem here is the export of .mp4. Not the encoding parameters. If export of MP4 works, there is not a problem in adding dozens of profile for mobile devices. z

I will definately experiment with your suggestion. When it is doable in reasonable time I will implement it.

You are saying that mencoder can write .mp4 files directly for your device? I tried direct MP4 output once using ffmpeg and it seemed fairly broken.

I have tried adding .mp4 muxing to the features of blu2mkv more than once, but I failed miserably using mp4create or MP4Box. They refused to add an audio track to the .mp4 file.

In your case I would guess that menc is the script where the feature would have to be added.

do I understand that correct, that the subtitles get hardcoded to the video stream (ergo not removable) in your command line?

Work for me, In some scripts in net I found to convert movies to android playable format is after run mencoder to mp4 run ffmpeg with "ffmpeg -i "$1.tmp.mp4" -vcodec copy -acodec copy "$1.mp4"
rm -f "$1.tmp.mp4" And after that all should work but for me work without running ffmpeg.

Yeah, I adding hardsubs because I like subs with transparent background and android still dont have good movie player what will be able to play movie with subs with background._________________BitBucket -- better-initramfs

I just posted a fixed version of avi2mkv that can mux Matroska files again

Also I just released a new version of blu2mkv that does not hardcode forced subtitles from Matroska sources anymore but instead copies all available subtitle streams and chapter information to the new file._________________Video Encoding scripts collection | Project page