# HOWTO conveniently convert videos using mencoder, x264

## fangorn

Edit 2011-0917

Some News:

blu2mkv is discontinued. menc can do all it does and more.

There is a new download page at http://progs.fangornsrealm.eu/downloads that is a central point to get the programs.

All other programs are now installable a lot more comfortable.

For Gentoo users ebuilds are available at http://progs.fangornsrealm.eu/ebuilds.tar.bz2 that install all the denpendencies automatically.

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)

 :Exclamation:  I am still answering to requests and bug reports here  :Exclamation: 

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.  :Wink:  I am a huge fan of the command

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

that can keep your machine busy for quite some time.  :Twisted Evil: 

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. 

Ripping BluRay/AVCHD from ISO files or directory structure or converting already ripped data in 

Matroska or MPEG Transport Stream containers (or probably some other container formats)

blu2mkv 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.  :Wink: 

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

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

```
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 

```
mplayer=`/usr/bin/which mplayer`

mencoder=`/usr/bin/which mencoder`

ffmpeg=`/usr/bin/which ffmpeg`
```

(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 

```
export LINGUAS="en"

or

export LINGUAS="en <something_other>"

```

So use 

```
export LINGUAS="en" emerge mplayer
```

or if you build by hand 

```
LINGUAS="en" ./configure <options>
```

to build your version of mplayer.

Dependencies: 

yet to come  :Rolling Eyes: 

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

Select x264 encoding profile preset 

(this is a dependency of all my encoding scripts)

http://progs.fangornsrealm.eu/choose_video_parameters/choose_video_parameters

Toolbox (containing functions used by more than one script)

(this is a dependency of most of scripts)

http://progs.fangornsrealm.eu/toolbox_fangorn/toolbox_fangorn

Encode nearly anthing to x264 video and copy audio or transform to stereo MP3.

http://progs.fangornsrealm.eu/menc/menc

Rip DVDs to x264 video

http://progs.fangornsrealm.eu/riptoh264/riptoh264

Reencode HD video material from HDDVD/BluRay/HDTV

http://progs.fangornsrealm.eu/blu2mkv/blu2mkv

Display information and extract titles from BluRay directory structures and ISO files

http://progs.fangornsrealm.eu/bluray-info/bluray-info

----------

## fangorn

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 

Update 30.11.2009

 mux to MP4 container (using MP4Box)

 mux to MPEG Transport Stream containers (using tsMuxeR)

 handle h.264 presets for specific playback standards/devices 

(as in BluRay/AVCHD/PS3/mobile phones/...)

 recode audio streams unsupported by selected h.264 preset/playback device

 automatically choose sensible container format and audio codec if selection is unsuitable for 

selected h.264 preset/playback device

Update 06.02.2010

 mux into OGM container

Update 13.03.2010 

 chapter support for TS container

Update 11.04.2010

 audio conversion is now also available for Matroska container

 uses external config file

 optionally specify languages on the command line

 process as many audio streams as languages are specified

 join multiple external audio sources

 replace internal audio with multiple external audio sources

 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.

```
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. 

```
avi2mkv --join_external_audio_file <external_audio_file> --first_audio_is_second_language <inputfile>
```

Source: a series of AVI files that you want concatenated (filename for the outputfile will be derived

from first input file)

```
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. 

Finally, the program

http://progs.fangornsrealm.eu/avi2mkv/avi2mkv

----------

## fangorn

menc

This is a script to convert nearly any input material to h.264 in .mkv or .avi containers. 

Feature list

convert video to h.264 using x264 using one- or two-pass-encoding up to 1080p

use different bitrates reflecting video resolution

handle up to two audio streams

copy audio streams or convert them to stereo MP3

reverse audio stream order in output file

automatically correct aspect of SVCD sources

force widescreen display on .mkv output (encoding in 720x576 for PAL or 720x480 for NTSC)

or encode to widescreen video (1024x576 for PAL or 1024x480 for NTSC) 

Update 28.10.2009

specify video bitrate on the command line

optionally crop black borders

optionally add black borders to get 16/9 aspect ratio after cutting black borders

optionally encode audio to AAC (2 channel)

optionally give raw, preformatted commands to mencoder (that are unsupported in menc)

Update 25.11.2009

use encoding profiles, including x264 encoding parameters, video scaling, audio 

encoding and output container 

(I wish to thank the developer(s) of h264enc for providing this excellent collection of presets)

optionally specify a target video size  

copy title information from WMV to MKV

Update 28.01.2010

temporary files are now processed in a subdirectory (placing of the subdirectory is configurable)

output file is placable in a directory different from the current working directory (configurable)

optionally specify the name of the output movie

Update 06.02.2010

outsourced video scaling calculation to choose_x264_encoding_parameters.sh (version 0.2.0 or newer)

automatically scale video size to restrictions of the selected x264 video 

preset/playback device

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

check video bitrate against x264 preset limits 

(through choose_x264_encoding_parameters.sh version 0.2.0 or newer)

Update 09.05.2010

configuration file handling

optionally give multiple input files on command line

optionally override video encoding parameters with own mencoder -ovc encoder -<options> line

process multiple audio streams of specifyable language(s)

automatically select streams of preffered language(s) if stream information is available in source

automatic chapter handling if information is available in source

optionally pass options to avi2mkv 

supports encoding of MPEG Transport Streams now!

Examples

yet to come

Finally, the program

http://progs.fangornsrealm.eu/menc/menc

----------

## fangorn

riptoh264

This is a script to rip DVDs to h.264/AC3. 

What can it do?

 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

Update:

 automatically detect source format (NTSC, NTSC movie, PAL) and adjust filter chain

 convert with a video bitrate given on command line

Update:

 easy setting of other languages to use 

 use only single audio stream (first if present, else second or default)

Update 18.10.2009

rip subtitles to the output container

optional automatic cropping of black borders. 

remove telecining/interlacing. 

(by hand for the moment, as automatic detection does not work atm.) 

Set the format of your DVD in the beginning of the script and according actions will be taken.

rip a dvd into an iso first

Update 28.10.2009

optionally specify telecining method on the command line

optionally automatically expand video frame to 16/9 aspect ratio after cropping black borders

Update 24.11.2009

use encoding profile presets

(I wish to thank the developer(s) of h264enc for providing this excellent collection of presets)

rip all titles of a disk (longer than a configurable number of seconds)

Update 06.02.2010

outsourced video scaling calculation to choose_x264_encoding_parameters.sh 

(version 0.2.0 or newer)

automatically scale video size to restrictions of the selected x264 video preset/playback device

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

check video bitrate against x264 preset limits 

(through choose_x264_encoding_parameters.sh version 0.2.0 or newer)

linear pcm audio is "converted" to pcm by default and reencoded to something matching the chosen 

x264 preset when muxed with avi2mkv

Examples

yet to come

Finally, the program

http://progs.fangornsrealm.eu/riptoh264/riptoh264Last edited by fangorn on Sun Mar 07, 2010 8:36 am; edited 33 times in total

----------

## fangorn

blu2mkv

This script is designed to convert HD video from BluRay, HDDVD, AVCHD, DVB-HD,

...  to a format more readable, h.264/AC3(or DTS) in Matroska Container (as you

might have guessed  :Wink:  ) to be precise. 

Update: In the meantime blu2mkv depends on avi2mkv, so more target containers

are supported.  Possible Targets are AVI, MKV, MP4, TS, MTS, M2TS, BluRay, OGM

(not atm)

This script can: 

Read HD sources in Matroska (.mkv) and MPEG Transport

Stream (.ts) (and probably other) containers and transcode them 

optionally resizing to 1080p or 720p (optionally expanding by adding black borders) 

copy up to two audio streams or convert them to stereo MP3 

utilize avi2mkv to create several output containers Update 05.09.2009 

optionally use dynamic noise reduction. CAUTION: Very time consuming!!!  Update 21.10.2009 

transfer subtitles and chapter marks from Matroska Sources (detected automatically)

Update 14.11.2009 

optionally give reverse audio and reverse languages flags

to avi2mkv Update 28.11.2009 

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 crop black borders 

automatically scale video size to restrictions of the selected x264 video

preset/playback device 

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 

check video bitrate against x264 preset limits (through

choose_x264_encoding_parameters.sh version 0.2.0 or newer) 

explicitely ask    for another output container than Matroska by the options -4 

(ISO MP4) -t (MPEG Ttransport Stream) -o (OGM) which is passed through to avi2mkv for

muxing 

Update 09.02.2010: 

automatically detect interlacing (when mediainfo is present) 

Update 14.02.2010: 

automatically rescale HDV (1400x1080) recordings to fullHD 

optionally pass even more options to avi2mkv

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 

```
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. 

Finally, the program

http://progs.fangornsrealm.eu/blu2mkv/blu2mkv

----------

## avx

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

```
#!/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.

if [ -z "$1" ]; then

        echo "Usage: midentify.sh <file> [<file> ...]"

        exit 1

fi

mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |

        sed -ne '/^ID_/ {

                          s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p

                        }'
```

Thanks for your work, personally I like the avi2mkv best  :Smile: 

----------

## fangorn

dejunk

I use a script to get rid of all those special characters in file-/directorynames that get in the way when 

handling files/directories on the commandline.

Caution:

This script processes EVERYTHING in the current working directory by default without asking once! 

So move everything you want to process in a subdirectory and run the script there.

Usage

yet to come

Changelog

13.03.2010

added optional command line arguments. If file(s) given, only they are renamed, if directories given, their 

contents are renamed.

Finally, the program

http://progs.fangornsrealm.eu/dejunk

----------

## fangorn

choose_video_parameters

This is a dependency for all my conversion scripts. 

It is used to select x264 encoding profile presets. 

Thanks

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. 

Finally, the program

http://progs.fangornsrealm.eu/x264_profile/choose_video_parameters

For reference, the old program

http://progs.fangornsrealm.eu/x264_profile/choose_x264_encoding_parameters.sh

----------

## fangorn

bluray-info

Finally here it is, my very first Perl program  :Very Happy: 

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. 

Feature list

mpls_dump feature list reimplemented in bluray-info: 

read BluRay Playlist(s) and display runtime of the title(s) specified

optionally display chapter information

optionally display detailed information

optionally display list of clips used in the title

when parsing multiple Playlists, filter short titles, duplicate and repetitive clips

0.0.1 additions:

write .meta file(s) (for tsMuxeR) for one playlist, the longest of all given playlists or all given playlists

filter the output to .meta file for short titles, duplicate and repetitive clips

optionally only use two predefined languages for audio and subtitle streams to write to .meta file

optionally use tsMuxeR and generated .meta file to export selected streams to MPEG Transport stream container

optionally use tsMuxeR to strip DTS-HD and TrueHD down to DTS and AC3 core respectively

0.1.0

accept single directory as input and parse every playlist in the according BluRay directory structure

export all titles longer than <min> minutes when optional value --longer <min> bigger than 1

optionally only extract core stream if DTS-HD or TrueHD audio

export chapter marks to a file when writing tsMuxeR meta file 

(optionally specify name of the chaptermark file)

optionally export and convert Sup subtitles to Vobsub (DVD) format (using BDSup2Sub)

including optional target framerate and video geometry change

0.2.0 additions:

added dependency on toolbox_fangorn (as the name implies, this is a script where I collect tools used by more than one script)

accepts working directories different from the BluRay directory structure 

(for example if BluRay directories are not writable)

extracts Titles from ISO files also if they are mounted in the system

(in Linux only works if the ISO has been decrypted and in Windows also when AnyDvdHD is running)

number of "preferred languages" is flexible now. Just add or remove elements of the languages array. 

 accepts a a list of files and directories mixed together at command line

accepts selection of a plylist item (the number) in directory mode

0.2.1 additions:

added configuration file handling (toolbox_fangorn version 0.1.0 or newer)

Development Status

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.   :Rolling Eyes: 

Usage

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

for example:

```
bluray-info BDMV/PLAYLIST/*
```

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

```
bluray-info .
```

```
bluray-info --filter_short .
```

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

```
bluray-info --longest 60 .
```

will list the durations of all titles longer than 60 minutes. 

These filter options are available for tsMuxeR output mode also. 

```
bluray-info -Tt test BDMV/PLAYLIST/00000.mpls BDMV/PLAYLIST/00001.mpls
```

will create test_00000.meta, test_00000.ts, test_00001.meta, test_00001.ts in the working directory. 

Finally, the program

http://progs.fangornsrealm.eu/bluray-info/bluray-info

----------

## fangorn

And another program to handle.   :Rolling Eyes: 

toolbox_fangorn

I came up with a little toolset of perl subroutines that I plan to use in all my scripts. 

atm this is a dependency of 

bluray-info-0.2.0 and following

avi2mkv_2.0.0 and following

riptoh264_2.0.0 and following

menc_3.0.0 and following

Changelog: 

0.1.0

added config file handling

added audio file format detection

added video geometry/fps detection

0.1.1

added some functions for language search

0.2.0

fixed a bug in automatic cropping

added menc options to the configuration file handling routine

added routine to extract chapter information from all sources supported by mplayer

the program

http://progs.fangornsrealm.eu/bluray-info/bluray-info

----------

## fangorn

Still no solution for the DTS sync problems of blu2mkv/avi2mkv. 

But I found time to upgrade the riptoh264 script. 

you can now specify the video bitrate on the command line and it detects NTSC, NTSC movie and PAL sources and builds a sensible filter chain automatically.

----------

## fangorn

And still nothing from the DTS front. 

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)

```
# Video encoding options

if [ "$nolimit" = "no" ] ; then

   maxrate=":vbv_maxrate=9500:vbv_bufsize=20000"

else

   maxrate=""

fi

# Default

opts_1st="subq=1:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=${BITRATE}${maxrate}:direct_pred=auto:keyint=100:turbo=2:threads=auto"

opts_2nd="frameref=6:analyse=all:me=umh:subme=7:trellis=2:bframes=4:b_pyramid:subq=7:mixed_refs:weight_b:no_fast_pskip:direct_pred=auto:mixed_refs:keyint=100:nr=200:bitrate=${BITRATE}${maxrate}:threads=auto:pass=2"

if [ "$profile" = "ps3" ] ; then

   opts_1st="bitrate=${BITRATE}${maxrate}:pass=1:turbo=2:level_idc=41:frameref=3:threads=0:mixed_refs:bframes=3:b_pyramid:brdo:subq=1:direct_pred=auto:partitions=p8x8,b8x8,i4x4,nopsnr,bime:weight_b:trellis=1:ssim"

   opts_2nd="bitrate=${BITRATE}${maxrate}:pass=2:level_idc=41:frameref=3:threads=0:mixed_refs:bframes=3:b_pyramid:brdo:subq=6:direct_pred=auto:partitions=p8x8,b8x8,i4x4,nopsnr,bime:weight_b:trellis=1:ssim"

elif [ "$profile" = "med" ] ; then

   opts_1st="subq=1:partitions=4x4:bframes=3:b_pyramid:keyint=100:pass=1:psnr:bitrate=${BITRATE}${maxrate}:turbo=1:threads=0"

   opts_2nd="subq=5:partitions=4x4:8x8dct:frameref=3:bframes=3:b_pyramid:keyint=100:pass=2:psnr:bitrate=${BITRATE}${maxrate}:threads=0"

elif [ "$profile" = "slow" ] ; then

   opts_1st="subq=1:bframes=4:b_pyramid:weight_b:pass=1:psnr:bitrate=${BITRATE}${maxrate}:turbo=2:threads=0"

   opts_2nd="subq=6:partitions=4x4:me=umh:8x8dct:frameref=3:bframes=4:b_pyramid:pass=2:psnr:bitrate=${BITRATE}${maxrate}:threads=0"

fi

```

----------

## fangorn

Success!

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.    :Rolling Eyes:  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.

Also I am testing a new version of tsMuxeR-1.9.9 that provides a native commandline tool and and GUI for linux! So far it is working perfect.

----------

## shebang_line

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  :Smile: 

----------

## fangorn

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 

```
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.

----------

## fangorn

I have posted a script to clean up file- and directorynames from various sources from special characters and other stuff.

----------

## mikioma

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!!!   :Very Happy: 

Thanks for you effort!!!

----------

## lordcris

there is 

 *Quote:*   

> media-video/h264enc
> 
>      Available versions:  ~*8.9.7 (~*)9.0.0 {aac dvd flac lame matroska mp4 ogm vorbis}
> 
>      Installed versions:  9.0.0(12:36:00 AM 10/06/2009)(aac dvd flac vorbis -lame -matroska -mp4 -ogm)
> ...

 

in portage now.

----------

## fangorn

h264enc is a good alternative, but it uses a completely different philosophy. 

h264enc is fully interactive while my scripts are by design totally scriptable. 

I like the possibilty to just hack up a 30 line script with individual encoding parameters for every movie and go on a vacation. 

People who want maximum options and flexibility and just encode a movie now and then are maybe better off using h264enc.

----------

## fangorn

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.   :Rolling Eyes: 

Edit: 

All went very well. I am debugging at the moment but it looks promising for riptoh264-1.9.0, avi2mkv-1.1.0 and blu2mkv-0.7.3 to be released tomorrow.

----------

## fangorn

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.   :Wink: 

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.

----------

## SlashBeast

Thanks for your work, your scripts work, cool.

Can you write a script to convert movies for portable devices, if it is no problem for you? Im not too good in video encoding but to convert movie for my htc magic (android-based device) I using

```
 mencoder -vf dsize=480:352:2,scale=-8:-8,harddup -oac faac -faacopts mpeg=4:object=2:raw:br=92 -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 -x264encopts nocabac:level_idc=30:bframes=0:bitrate=512:threads=auto:turbo=1:global_header:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh -fontconfig -font "Arial Black" -subfont-text-scale 2.7 -sub-bg-alpha 150 -subpos 97 -subcp cp1250 101_-_yesterday\'s_jam.avi -sub 101_-_yesterday\'s_jam.txt -o 01.mp4
```

----------

## fangorn

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. 

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

----------

## SlashBeast

 *fangorn wrote:*   

> 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. 
> ...

 

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.

----------

## fangorn

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

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.

----------

## fangorn

I just posted an update to riptoh264

Also I had a little free time on my hands so I updated my menc script. It has some neat new features now but depends on avi2mkv for Matroska muxing.

@SlashBeast

Try the menc script for your problem. I tried it with some sources and it worked, but I did not have any subtitles at hand. 

Try this command (including the " and the \") 

```
menc  -p htcmagic -R "-fontconfig -font \"Arial Black\" -subfont-text-scale 2.7 -sub-bg-alpha 150 -subpos 97 -subcp cp1250 -sub <subfile>" <inputfile>
```

you can also add 2pass encoding, but atm all other options for video processing (like deinterlacing, denoising, ... ) are ignored.

----------

## SlashBeast

35-38fps on core2 t7500 and 720p source, after encoding I have something about MP4 Container and just dropped to shell, still ${name}_tmp.mp4 and... this file dont work at all, even ffmpeg cant read it.

----------

## fangorn

OK, my test file was standard PAL and I only played it in VLC as I don't own any mobile devices. That is why I wanted you to test it.   :Rolling Eyes: 

Can you paste the log files and the output from the shell somewhere so I can try to debug?

----------

## fangorn

I just updated avi2mkv. It now has some exciting new features. See the according post for a list  :Wink: 

Also I updated all my other scripts to reflect this new features. Even if they are not using them all atm. 

@SlashBeast

Please update the scripts and try again with menc, adding the -4 option and replacing "-p htcmagic" by "-p htm". (while using the command line given before)

----------

## durian

Can these be downloaded from somewhere? They are too large for my copy/paste buffer at least...

-peter

----------

## fangorn

Not at the moment. I am working on a solution to place them somewhere always accessible. My dyndns is too unstable for that.  :Rolling Eyes: 

----------

## fangorn

I just changed my distribution scheme. You can now download always the newest version from a server and the forum is some kB smaller  :Wink:  The first post contains a link list to the newest versions.

----------

## durian

Nice, thanks!

-peter

----------

## fuzzybee

I'm trying to use your scripts to shrink a Blu-Ray rip mkv file.  I enter:

~ # blu2mkv -nB -p bd40 /var/video/movies/New_rips/The_Hangover.mkv

and I get:

```
Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream one

No audio stream specified. Trying to use specified languages if specified in source file. If not, default stream will be used.

MPlayer SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

Playing /var/video/movies/New_rips/The_Hangover.mkv.

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_TRUEHD) "5.1", -aid 0, -alang eng

[mkv] Track ID 3: audio (A_AC3) "3/2+1", -aid 1, -alang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

Core dumped ;)

Exiting... (End of file)

calling external program choose_x264_encoding_parameters.sh

external call was successfull

using seleted preset bd40

not resizing video

video filters used for first pass:  -vf harddup

MEncoder SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

success: format: 0  data: 0x0 - 0x81563005

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_TRUEHD) "5.1", -aid 0, -alang eng

[mkv] Track ID 3: audio (A_AC3) "3/2+1", -aid 1, -alang eng

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 0

Opening video filter: [harddup]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

Exiting...

video filters used for second pass:  -vf harddup

MEncoder SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

success: format: 0  data: 0x0 - 0x81563005

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_TRUEHD) "5.1", -aid 0, -alang eng

[mkv] Track ID 3: audio (A_AC3) "3/2+1", -aid 1, -alang eng

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 0

Opening video filter: [harddup]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

Exiting...

muxing to Matroska container

mkvmerge v2.9.7 ('Tenderness') built on Dec 11 2009 09:57:09

Error: The file 'The_Hangover.avi' has unknown type. Please have a look at the supported file types ('mkvmerge --list-types') and contact the author Moritz Bunkus <moritz@bunkus.org> if your file type is supported but not recognized properly.

```

In my file's directory, I have:

0 2010-01-21 23:47 The_Hangover.avi

408 2010-01-21 23:47 The_Hangover_avi2mkv_command.log

237 2010-01-21 23:47 The_Hangover_avi2mkv_mkvmerge_info.txt

118 2010-01-21 23:47 The_Hangover_avi2mkv_mplayer_info.txt

1400 2010-01-21 23:47 The_Hangover_commands.log

1136497886 2010-01-21 23:47 The_Hangover_eng.ac3

59 2010-01-21 23:45 The_Hangover_file_info.txt

624 2010-01-21 23:47 The_Hangover_mencoder.log

15054811141 2010-01-21 06:34 The_Hangover.mkv

3655 2010-01-21 23:45 The_Hangover_mplayer_info.txt

375 2010-01-21 23:47 The_Hangover_x264_encoding_parameters.txt

Any suggestions as to what I can change to get this working?

----------

## fangorn

OK, this is a case I have not tested. Your source has 

TrueHD main audio stream

2 audio streams with the same language setting

SUP format subtitles (that are ignored and should not cause any problems)

Could you paste The_Hangover_commands.log The_Hangover_file_info.txt  The_Hangover_mencoder.log The_Hangover_mplayer_info.txt  and  The_Hangover_x264_encoding_parameters.txt somewhere? nopaste.info for example.

Easy fix: use mmg to reduce to one audio stream and no subtitle and encoding should work, regardless if audio is TrueHD or simple AC3. Also it should not be a problem if an unsupported subtitle is present, but I dont know because I did not test it explicitely.

As an alternative you can use the mmg Header Editor to change the language setting of one of the audio streams to an unneeded value (by default "ger" and "eng" are used and you choose "hun" for example)

I will look into the problem, but I don't know when I will have a solution.

----------

## fuzzybee

 *fangorn wrote:*   

> OK, this is a case I have not tested. Your source has 
> 
> TrueHD main audio stream
> 
> 2 audio streams with the same language setting
> ...

 

Thanks for the reply!

Here you go:

http://nopaste.info/aeb38f2675.html (I hope I did that right).

----------

## fuzzybee

I may be able to try the mmg when I get home - I'm just using CLI right now.

----------

## fuzzybee

OK - I installed mmg and took out the subtitles and the TrueHD track.  Once again, it puls out the AC3 track and then stops:

 # blu2mkv -nB -p bd40 /var/video/movies/New_rips/The_Hangover-b.mkv

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream one

No audio stream specified. Trying to use specified languages if specified in source file. If not, default stream will be used.

MPlayer SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

Playing /var/video/movies/New_rips/The_Hangover-b.mkv.

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_AC3) "3/2+1", -aid 0, -alang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

Core dumped  :Wink: 

Exiting... (End of file)

calling external program choose_x264_encoding_parameters.sh

external call was successfull

using seleted preset bd40

not resizing video

video filters used for first pass:  -vf harddup

MEncoder SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

success: format: 0  data: 0x0 - 0x3af767e6

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_AC3) "3/2+1", -aid 0, -alang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

==========================================================================

Opening audio decoder: [liba52] AC3 decoding with liba52

AUDIO: 48000 Hz, 2 ch, s16le, 640.0 kbit/41.67% (ratio: 80000->192000)

Selected audio codec: [a52] afm: liba52 (AC3-liba52)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 0

Opening video filter: [harddup]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=80000 sample-1)

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

Exiting...

video filters used for second pass:  -vf harddup

MEncoder SVN-r29796-4.1.2 (C) 2000-2009 MPlayer Team

success: format: 0  data: 0x0 - 0x3af767e6

[mkv] Track ID 1: video (V_MS/VFW/FOURCC), -vid 0

[mkv] Track ID 2: audio (A_AC3) "3/2+1", -aid 0, -alang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [WVC1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

==========================================================================

Opening audio decoder: [liba52] AC3 decoding with liba52

AUDIO: 48000 Hz, 2 ch, s16le, 640.0 kbit/41.67% (ratio: 80000->192000)

Selected audio codec: [a52] afm: liba52 (AC3-liba52)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 0

Opening video filter: [harddup]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=80000 sample-1)

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

Exiting...

muxing to Matroska container

mkvmerge v2.9.7 ('Tenderness') built on Jan 23 2010 09:46:28

Error: The file 'The_Hangover-b.avi' has unknown type. Please have a look at the supported file types ('mkvmerge --list-types') and contact the author Moritz Bunkus <moritz@bunkus.org> if your file type is supported but not recognized properly.

----------

## fangorn

Is your mplayer/ffmpeg built with support for vc1/wmv3 video? What versions are you using?

----------

## fuzzybee

I have installed each from their packages:

[I] media-video/mplayer

     Installed versions:  1.0_rc4_p20091026-r1(04:40:44 PM 12/31/2009)(3dnow 3dnowext X a52 aac alsa ass cddb cdio dirac dts dv dvb dvd dvdnav enca encode faac faad iconv ipv6 jack jpeg kernel_linux live mad mmx mmxext mp3 network opengl osdmenu oss quicktime rar real rtc schroedinger sdl shm speex sse sse2 theora toolame tremor truetype twolame unicode video_cards_nvidia vorbis x264 xinerama xscreensaver xv xvid xvmc -aalib -altivec -bidi -bindist -bl -bs2b -cdparanoia -cpudetection -custom-cpuopts -debug -dga -directfb -doc -dxr3 -esd -fbcon -ftp -ggi -gif -gmplayer -joystick -ladspa -libcaca -lirc -lzo -md5sum -mng -nas -nut -openal -opencore-amr -png -pnm -pulseaudio -pvr -radio -samba -ssse3 -svga -teletext -tga -v4l -v4l2 -vdpau -video_cards_mga -video_cards_s3virge -video_cards_tdfx -vidix -win32codecs -xanim -zoran)

[I] media-video/ffmpeg

     Installed versions:  0.5_p20373(04:24:02 PM 12/24/2009)(3dnow 3dnowext X alsa encode hardcoded-tables ieee1394 ipv6 jack mmx mmxext mp3 oss sdl ssse3 threads video_cards_nvidia vorbis x264 xvid zlib -altivec -bindist -cpudetection -custom-cflags -debug -dirac -doc -faac -faad -gsm -jpeg2k -network -opencore-amr -pic -schroedinger -speex -test -theora -v4l -v4l2 -vdpau)

----------

## fuzzybee

What's weird is that mplayer can play the .mkv with no problem (well, it's slow, because I'm going over VNC, but it plays).

It does say, though:

```
Requested video codec family [wmvvc1dmo] (vfm=dmo) not available.
```

but I get:

```
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)
```

If I do a  mplayer -vc help|grep vc1, I get:

```

ffvc1       ffmpeg    problems  FFmpeg WVC1  [vc1]

ffvc1vdpau  ffmpeg    problems  FFmpeg WVC1 (VDPAU)  [vc1_vdpau]

wmvvc1dmo   dmo       working   Windows Media Video (VC-1) Advanced Profile  [wvc1dmod.dll]
```

but I get problems with WMV3:

```
mplayer -vc help|grep wmv3

ffwmv3      ffmpeg    problems  FFmpeg WMV3/WMV9  [wmv3]

ffwmv3vdpau ffmpeg    problems  FFmpeg WMV3/WMV9 (VDPAU)  [wmv3_vdpau]
```

Where does the WMV3 get built-in?

----------

## fangorn

WMV3 is the newest codec version from Microsoft. Long time there were problems decoding this one. But ffmpeg from 2009-12 should decode it well. 

As I already told, I am using svn version built by hand, so I cannot be sure where the problem is. If you want to try (they are installing into /usr/local/ so they don't mess with your system packages).

```

svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
```

I am using these configurations

```
> less mplayer_config.sh

export LINGUAS="en de"

./configure --enable-vdpau --enable-network --disable-arts --disable-nemesi --disable-fribidi --disable-enca --disable-inet6 --disable-lirc --disable-lircc --disable-apple-ir --disable-libnut --enable-menu --disable-smb --disable-xss --disable-joystick --disable-libcdio --disable-tv-bsdbt848 --disable-ivtv --disable-pvr --enable-radio --enable-radio-capture --disable-liba52 --disable-musepack --disable-live --disable-mad --disable-mng --disable-pnm --disable-speex --disable-tga --disable-xanim --disable-qtx --disable-ggi --disable-md5sum --disable-aa --disable-dga1 --disable-dga2 --disable-dxr3 --disable-fbdev --disable-caca --disable-vesa --disable-vidix --disable-vidix-pcidb --disable-zr --disable-gui --enable-xvmc --with-xvmclib=XvMCW --disable-3dfx --disable-tdfxvid --disable-tdfxfb --disable-esd --disable-jack --disable-ladspa --disable-nas --disable-openal

> less ffmpeg_config.sh

./configure --disable-debug --enable-shared --enable-gpl --enable-nonfree --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-vdpau  --enable-libx264 --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-postproc
```

----------

## fuzzybee

OK, I've followed your directions here, and also had to get the SVN for x264.  Now, mplayer won't build - it keeps stopping at:

```

gcc -L"/usr/local/ffmpeg"/libavcodec -L"/usr/local/ffmpeg"/libavdevice -L"/usr/local/ffmpeg"/libavfilter -L"/usr/local/ffmpeg"/libavformat -L"/usr/local/ffmpeg"/libavutil -L"/usr/local/ffmpeg"/libpostproc -L"/usr/local/ffmpeg"/libswscale -Wl,--warn-common -Wl,--as-needed -Wl,-rpath-link,"/usr/local/ffmpeg"/libpostproc -Wl,-rpath-link,"/usr/local/ffmpeg"/libswscale -Wl,-rpath-link,"/usr/local/ffmpeg"/libavfilter -Wl,-rpath-link,"/usr/local/ffmpeg"/libavdevice -Wl,-rpath-link,"/usr/local/ffmpeg"/libavformat -Wl,-rpath-link,"/usr/local/ffmpeg"/libavcodec -Wl,-rpath-link,"/usr/local/ffmpeg"/libavutil -Wl,-Bsymbolic -o ffmpeg_g ffmpeg.o cmdutils.o -lavfilter -lpostproc -lavdevice -lavformat -lavcodec -lavutil -lswscale -lz -lbz2 -pthread -lm -lfaac -lfaad -lmp3lame -lm -ltheoraenc -ltheoradec -logg -lvorbisenc -lvorbis -logg -lx264 -lm -lxvidcore -lasound -ljack -ldl -lasound -ljack -lasound

/usr/local/ffmpeg/libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_83'

collect2: ld returned 1 exit status

make: *** [ffmpeg_g] Error 1
```

Anybody here run into this?

----------

## trumee

Is it possible to specify the path where the output file will be written. menc currently outputs to the folder where the source file exists which i dont want.

----------

## fangorn

@fuzzybee

Yes, it is a little bit tricky getting them to build when more than one version of x264 is installed. And WOW: they are at version 83 with x264 now? I am using revision 79. 

Your ffmpeg seems to have built fine. You can test it by running ffplay with a x264 video. 

See the ./configure --help of mplayer for how to set the path for x264. atm it detects your older version in /usb/lib.

@trumee

You could always edit the script, but there is no such option in the current version of the scripts.

----------

## trumee

Should i simply prepend the path to the filename i.e. change line number 132 in menc to

```

moviename=/myvideodir/"$moviebase"".mkv"

```

a) Also, is the output filename always the same as input filename. any way to modiy it? 

b) is it possible to redirect all the temporary files to /tmp. i only want to retain the mkv file.

My objective is to use this script as a userjob in mythtv to convert the recordings to x264.

Thanks for the excellent script.

----------

## fangorn

```

moviename=/myvideodir/"$moviebase"".mkv" 
```

This should work. Or you add a line 

```
mv "$moviename" /myvideodir/
```

after the call to avi2mkv 

to a)

atm menc is designed to always use the same name as the input file (as in massive batch conversion of hundreds of source files  :Wink:  ). An option to specify a moviename on the command line should not be a problem though. I just need to find the time to implement it. 

to b)

I was planning on putting temporary files in a subdirectory like in riptoh264 but did not get along so far.   :Rolling Eyes:  In this case all processing would be done in that directory and result mkv moved back to the current working directory.

----------

## fuzzybee

OK - finally got everything built (I think).  Thanks for the help.

I tried changing the language of the TrueHD track, and it didn't work.  Then, I changed the TrueHD track to #3, and the AC3 track to #2, and it's started.  I'll let you know tomorrow how it ends up.

----------

## fangorn

mmg header editor can also edit the "Default Track" flag. Remove from one and add to the other audio stream would be sufficient without rebuilding a copy of the MKV.

----------

## fuzzybee

I'm pretty sure I changed the default audio track, and it didn't like that.  I'll try again with the file tonight.

----------

## fangorn

I just uploaded new versions of menc, blu2mkv and choose_x264_encoding_parameters.sh.

menc writes to temporary directory now (configurable) and you can specify a output name and output directory.

I corrected some errors in filetype detection in blu2mkv 

And i changed format of presets in choose_x264_encoding_parameters.sh. Now they should be easier to read (and maintain, as I still copy them from h264enc  :Wink:  )

----------

## fangorn

It was a very productive weekend. 

I just updated all my scripts. If you update, be sure to update them all.

avi2mkv now finally automatically checks output container and audio format when a preset is specified. Also it can now mux to OGM container. Please test it and write if you find any problems.

choose_x264_encoding_parameters.sh now supports checking output video geometry and video bitrate. All encoding scripts now depend on it for scaling video!

menc, riptoh264 and blu2mkv now support user specified or x264 given output geometries and video bitrates. If there are multiple geometries allowed, the maximum resolution is used. When Bitrate is above preset limits, the maximum allowed value is used. User can specify output video width and height. 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.

Additionally riptoh264 now supports linear pcm audio streams.

blu2mkv also now supports the cropping of black borders and user specified output container selection (instead of Matroska use MPEG Transport Stream, ISO MP4 or OGM).

If you find any problems, report back here. Have Fun.

----------

## fuzzybee

Thanks for the updates.

For some reason, when I try to use blu2mkv, it displays:

```
 blu2mkv -p bd40 Pirates_of_the_Carribean_3.mkv

Search pattern not terminated at -e line 1.

Source file is of Type  Matroska

Width =

Height =

Aspect =

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

AUDIO1 is -aid 0 1

Resolution = 1280:720

Do not scale is no

video is interlaced: no

dynamic noise reduction is active: no

```

Any suggestion as to why it's not pulling the file width/height/AR?

----------

## fangorn

I silently fixed some bugs since monday, so please try the newest version.   :Confused: 

----------

## fuzzybee

So far, it's working on the audio, but I still get this:

```

blu2mkv -b 3000 -pbd40 Doubt-2.mkv

Search pattern not terminated at -e line 1.

Source file is of Type  Matroska

Width =

Height =

Aspect =

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

AUDIO1 is -aid 0 1

Resolution = 1280:720

Do not scale is no

video is interlaced: no

dynamic noise reduction is active: no

```

----------

## fangorn

 *fuzzybee wrote:*   

> So far, it's working on the audio, but I still get this:
> 
> ```
> 
> Search pattern not terminated at -e line 1.
> ...

 

So we have multiple minor and major problems here.

First: you have to put a space between -p and the preset. I don't know if this is a typo. 

Then a problem with an if-file-exists statement as it seems. 

The width and height problem is more serious. 

What does 

```
mplayer -msglevel identify=6 -frames 0 -identify -vc null -vo null -ao null Doubt-2.mkv 
```

 print?

do the following command lines print something?

```
ffmpeg -i Doubt-2.mkv 2>&1 | grep "Video" | cut -d' ' -f 10 | cut -d 'x' -f 1

ffmpeg -i Doubt-2.mkv 2>&1 | grep "Video" | cut -d' ' -f 10 | cut -d 'x' -f 2 | cut -d',' -f 1
```

If not, what does does 

```
ffmpeg -i Doubt-2.mkv
```

 print?

And: are there no language tags to the audio streams in the MKV file? You can correct that using the mmg header editor without copying all streams to a new file. 

Or if you  prefer other than the default languages (ger and eng), just set them in the beginning of the script (variables mkv_firstlanguage and mkv_secondlanguage). 

But it is strange why it wants to encode two streams at once. ("-aid 0 1") I have to look into this to see if this is just a stupid output or a serious bug.   :Rolling Eyes: 

And last just a tip: if you don't want your FullHD content to be scaled down to 720p you have to specify the -n option (--noscale if I find the time to rewrite the option system  :Wink:  )

Edit: I am not used to my own programming logic atm.   :Rolling Eyes:  With the new feature of preset based geometry checks, it is not clear if it gets scaled or if it doesn't. I will have to rethink the default values. Oh, those nifty library tool changes that affect multiple programs from different times. There is always an aspect you have not thought of.   :Rolling Eyes: 

----------

## fuzzybee

OK - I found part of my problem.  For some reason, I no longer had ffmpeg installed.

I still have the following, though:

```
 blu2mkv -b 3000 -p bd40 -n Doubt-2.mkv

Search pattern not terminated at -e line 1.

Source file is of Type  Matroska

Width =

Height =

Aspect =

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

AUDIO1 is -aid 0 1

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream: eng which is stream 0 1
```

----------

## fangorn

Is the path to ffmpeg in the beginning of the script set correctly?

run "which ffmpeg" and use the result there.

Also you might check your source file. It seems to have two audio streams of a preferred language, which irritates the script in the last version. 

I corrected that in my development version, but I already changed major features and my version is absolutely untested. So if you want to test further, consider changing the language setting of the unneeded audio stream in your source to something else (mmg has a header editor that can do that "in place" for Matroska sources). I don't know when i will release the corrected version. There are already some features i have in queue that seem easy to implement and maybe I will include them before the next release.   :Rolling Eyes: 

----------

## fuzzybee

OK - I don't know what went wrong with my ffmpeg install, but that's taken care of now, and the script points to the right spot.  I've altered the .mkv to call my DTS-HD file as Finnish.  Now, I get:

```
blu2mkv -b 3000 -p bd40 -n Doubt-1.mkv

Source file is of Type  Matroska

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

AUDIO1 is -aid 0

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream: eng which is stream 0

which is a DTS stream. To prevent sync problems, it will be converted to MP3 and muxed later

MPlayer SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

Playing Doubt-1.mkv.

[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0

[mkv] Track ID 2: audio (A_DTS) "3/2+1", -aid 0, -alang eng

[mkv] Track ID 3: audio (A_DTS) "HD Lossless", -aid 1, -alang fin

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 5: subtitles (S_HDMV/PGS), -sid 1, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

```

Why is it still trying to resize down to 1280:720?

----------

## fangorn

Your version scales video to 720p by default. To prevent that you have to specify the -n option. I thought I pointed that out in the script somewhere.  :Rolling Eyes: 

My development version has other defaults. But I changed/added about 500 lines of code in one and a half days and have to test a little.   :Wink: 

Edit: As I recognize now, you already got the -n option. The output is a little bit distracting in this case.  *Quote:*   

> Resolution = 1280:720
> 
> Do not scale is yes 

  means that default resolution is 720p, but source video is not scaled, so stays 1080p.

----------

## fuzzybee

It's cool - you missed the -n, I missed the "Do not scale is yes".  :Smile: 

I'm really confused now, though.  I know I've used this script successfully before, and I'm not sure what's changed on my system.  Now, the script complains that it can't find tsmuxer.  I have no indication that tsmuxer has ever been on this install.  I installed tsMuxeR, and it complains that it can't find libfreetype.so.6

Have the scripts changed to require tsMuxeR?

----------

## fangorn

Avi2mkv needs tsMuxer when muxing to MPEG transport stream (which is used by default by several x264 encoding profiles - for instance the avchd or bluray presets but also ps3 and others). Some also support other containers, but you have to specify them on the command line with blu2mkv.

blu2mkv needs tsMuxer when automatically reading BluRay/AVCHD structures from directory or ISO image. Oh, that is my development version only.   :Twisted Evil: 

----------

## fuzzybee

Gotcha.  I see what I did before - I muxed using vhq rather than bd40.  I'll try a shot at vhq.

----------

## fuzzybee

Argh.

So I edited the original MKV and took our the DTS-HD track altogether.  Now, I get this:

blu2mkv -b 3000 -p vhq -n Doubt-3.mkv

```
Source file is of Type  Matroska

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

AUDIO1 is -aid 0

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream: eng which is stream 0

which is a DTS stream. To prevent sync problems, it will be converted to MP3 and muxed later

MPlayer SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

Playing Doubt-3.mkv.

[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0

[mkv] Track ID 2: audio (A_DTS) "3/2+1", -aid 0, -alang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 3: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 1, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

Core dumped ;)

Exiting... (End of file)

not resizing video

calling external program choose_x264_encoding_parameters.sh

external call was successfull

using seleted preset vhq

using nombtree for compatibility reasons with mp3 audio conversion

geometryfilteroptions expand=1920:1080

video filters used for first pass:  -vf expand=1920:1080,hqdn3d=2:1:2,harddup

AUDIO channel used -aid 0

second audio

MEncoder SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x654b0620

[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0

[mkv] Track ID 2: audio (A_DTS) "3/2+1", -aid 0, -alang eng

[mkv] Track ID 3: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 1, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

==========================================================================

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)

Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [harddup]

Opening video filter: [hqdn3d=2:1:2]

Opening video filter: [expand w=1920 h=1080]

Expand: 1920 x 1080, -1 ; -1, osd: 0, aspect: 0.000000, round: 1

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2001 chans=2 rate=48000 bits=16 B/s=192000 sample-1)

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

Exiting...

video filters used for second pass:  -vf spp,expand=1920:1080,hqdn3d=2:1:2,harddup

MEncoder SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x654b0620

[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0

[mkv] Track ID 2: audio (A_DTS) "3/2+1", -aid 0, -alang eng

[mkv] Track ID 3: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 1, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

==========================================================================

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)

Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [harddup]

Opening video filter: [hqdn3d=2:1:2]

Opening video filter: [expand w=1920 h=1080]

Expand: 1920 x 1080, -1 ; -1, osd: 0, aspect: 0.000000, round: 1

Opening video filter: [spp]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

[PP] Using external postprocessing filter, max q = 6.

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

Exiting...

Source files has subtitle tracks

Track numbers 3 4

extract subtitle track 3

format not found, skipping

extract subtitle track 4

format not found, skipping

muxing to Matroska container

mkvmerge v2.9.7 ('Tenderness') built on Jan 21 2010 20:47:46

Error: The file 'Doubt-3.avi' has unknown type. Please have a look at the supported file types ('mkvmerge --list-types') and contact the author Moritz Bunkus <moritz@bunkus.org> if your file type is supported but not recognized properly.

```

I'm really not sure why this has ceased working.

----------

## fangorn

There should be a *_commands.log or *_mencoder.log with the command lines used for encoding.

Try to run those on the command line (in the same directory) and see what mencoder spits out. 

I had cases, where mencoder was not built with x264 support, where mencoder could not handle one or more of the x264 preset parameters, ... If you did not recompile mplayer lately, the second option is more likely.

----------

## fuzzybee

OK - here's where I've gotten.  It's bombing out on:

```
/usr/local/bin/mencoder Doubt-3.mkv -aid 0 -oac copy -nosub -ovc x264 -x264encopts me=umh:me_range=24:nodct_decimate:8x8dct:nofast_pskip:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4:mixed_refs:keyint=240:psy_rd=0.8,0.2:frameref=4:bframes=5:b_adapt=2:b_pyramid=normal:weight_b:weightp=2:direct_pred=auto:subq=7:nombtree/:chroma_me:cabac:aq_mode=1:deblock:vbv_maxrate=9500:vbv_bufsize=12000:level_idc=41:threads=auto:ssim:psnr:bitrate=3000:pass=1:turbo=2 -passlogfile Doubt-3_2pass.log -vf expand=1920:1080,hqdn3d=2:1:2,harddup -fps 24000/1001 -ofps 24000/1001 -o /dev/null

```

The error I get is:

```
FATAL: Cannot initialize video driver.

```

I can understand why it's not initializing the video driver, because I'm just SSHd in to the box.  Can mencoder no longer work from command line?

----------

## fangorn

try removing the -vf expand=1920:1080,hqdn3d=2:1:2,harddup part. I can't understand anyway why it wants to expand the video.

mencoder does not open display windows. So the "video driver" is the decoding chain, the filter set or the encoder. when it is a x264 option there is a small statement somewhere that option xyz is not recognized.

----------

## fuzzybee

Thanks for all your help with this.

Here's what I get after removing the -vf part:

```
/usr/local/bin/mencoder Doubt-3.mkv -aid 0 -oac copy -nosub -ovc x264 -x264encopts me=umh:me_range=24:nodct_decimate:8x8dct:nofast_pskip:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4:mixed_refs:keyint=240:psy_rd=0.8,0.2:frameref=4:bframes=5:b_adapt=2:b_pyramid=normal:weight_b:weightp=2:direct_pred=auto:subq=7:nombtree/:chroma_me:cabac:aq_mode=1:deblock:vbv_maxrate=9500:vbv_bufsize=12000:level_idc=41:threads=auto:ssim:psnr:bitrate=3000:pass=1:turbo=2 -passlogfile Doubt-3_2pass.log -fps 24000/1001 -ofps 24000/1001 -o /dev/null

MEncoder SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

Option x264encopts: Unknown suboption nombtree/

success: format: 0  data: 0x0 - 0x654b0620

[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0

[mkv] Track ID 2: audio (A_DTS) "3/2+1", -aid 0, -alang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 3: subtitles (S_HDMV/PGS), -sid 0, -slang eng

[mkv] Subtitle type 'S_HDMV/PGS' is not supported.

[mkv] Track ID 4: subtitles (S_HDMV/PGS), -sid 1, -slang eng

[mkv] Will play video track 1.

Matroska file format detected.

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:31  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

==========================================================================

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)

Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2001 chans=2 rate=48000 bits=16 B/s=192000 sample-1)

[h264 @ 0x13df760]non-existing SPS 1 referenced in buffering period

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

FATAL: Cannot initialize video driver.
```

----------

## fuzzybee

Ah!

```
Option x264encopts: Unknown suboption nombtree/

```

----------

## fangorn

Most likely it is the slash at the end. Have not seen that before. You can also test if mbtree works for you. It is said to have good quality improvement with slight impact on the conversion time. (But in my experience there is not a visible difference in most sources when encoding fullHD in two-pass mode with 6000 kBit/s average bitrate, which is the default of blu2mkv - might be different when converting MTV-cut source material, but I could not watch that for a whole movie length  :Wink:  )

Edit: 

Thank you, you found a bug. 

My replacement when encoding DTS audio sources is wrong. 

encopts="${encopts//:mbtree/:nombtree/}" 

is sed style. bash does not need the last /.

Edit:

It is corrected in the recent version. Just re-download blu2mkv

----------

## fangorn

I just uploaded an updated version of blu2mkv. It will still take a while to implement the "killer feature" of version 1.0.0. 

I recognized that tsMuxeR can't reproducibly report language codes, so I had to search for an alternative. I found one, but it is a C program that maybe will be a part of handbrake later. So I decided to reimplement the parser and add my functions to the program. Thanks to the developer(s) for providing this excellently working parser code. Took me less time to write it as my first real Perl program than it would have taken to read the documentation of the binary format. If they are interested, I will provide them with the additional functions to output tsMuxeR .meta files.

----------

## fuzzybee

Thanks for the update!

It's me again  :Smile: 

Working on the same file blu2mkv doesn't seem to recognize the command-line switches:

```
blu2mkv -b 3000 -p vhq -n Doubt.mkv

head: cannot open `3000' for reading: No such file or directory

Search pattern not terminated at -e line 1.

Source file is of Type  Unknown :(

Width =

Height =

Aspect =

Aspect should be 1.77777777777778

Source Framerate:

Input Framerate used:

Output Framerate used:

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

Resolution = 1920:1080

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream: default

/usr/bin/blu2mkv: line 612: [: : integer expression expected

/usr/bin/blu2mkv: line 615: [: : integer expression expected

syntax error at -e line 1, at EOF

Execution of -e aborted due to compilation errors.

/usr/bin/blu2mkv: line 647: [: : integer expression expected

calling external program choose_x264_encoding_parameters.sh

-> No preset specified!

choose_x264_encoding_parameters.sh Version 0.2.1

Program to choose x264 encoding presets.

Usage: choose_x264_encoding_parameters.sh -p <preset>  -W <sourcewidth> -H <sourceheight> -f <fps> -o <outputfile> -B <bitrate>

                [-eL] [-c <CROPparameters>] [-w <outputwidth>] [-h <outputheight>]

                [-l <level>] [-b <max_bufsize>] [-r <max_bitrate]

 -o <outputfile>

            specify outputfile to log settings (mandatory)

 -f <fps>

            frames per second of source video (mandatory)

 -p <preset>

            x264 encoding preset (mandatory)

 -W <sourcewidth>

 -H <sourceheight>

            input video width and height (mandatory)

 -B <bitrate>

            video bitrate (mandatory)

 -w <outputwidth>

 -h <outputheight>

            output video width and height (optional)

            when none of them are given, source video or preset maximum geometry is used

            if only one is given, the other is calculated from the given value and the source or target aspect ratio

               if -e option is present, black borders are added to reach output aspect ratio

            if both are given, these are used

 -c <CROPparameters>

            parameters created by a "mplayer -cropdetect" run (optional)

 -l <level>

            h.264 level [Default: 4.1]

 -b <max_bufsize>

            maximum bufsize for video stream (optional)

 -r <max_bitrate>

            maximum bitrate for video stream (optional)

 -e         expand video with black borders to match given or demanded aspect ratio (optional)

 -L         list available presets and exit (optional)

            Use a predefined H.264 quality preset. You can

            choose from 61 different presets:

            PC Presets

            ~~~~~~~~~~

            ulq -------> Ultra Low Quality preset

            elq -------> Extreme Low Quality preset

            vlq -------> Very Low Quality preset

            lq --------> Low Quality preset

            mq --------> Medium Quality preset

            nq --------> Normal Quality preset

            hq --------> High Quality preset (recommended)

            vhq -------> Very High Quality preset (recommended)

            ehq -------> Extreme High Quality preset (recommended)

            uhq -------> Ultra High Quality preset

            ihq -------> Insane High Quality preset

            nlq -------> Near Lossless Quality preset

            fghq ------> Film Grain optimized High Quality preset

            ani -------> Anime preset

            anihq -----> Anime High Quality preset

            vdhq ------> VDPAU/DXVA High Quality (High@L4.1) preset

            vdehq -----> VDPAU/DXVA Extreme High Quality (High@L4.1) preset

            vdihq -----> VDPAU/DXVA Insane High Quality (High@L4.1) preset

            Software Compatible Presets

            ~~~~~~~~~~~~~~~~~~~~~~~~~~~

            fl --------> Flash Player preset

            flhq ------> Flash Player High Quality preset

            qt --------> QuickTime preset

            qthq ------> QuickTime High Quality preset

            Device Presets

            ~~~~~~~~~~~~~~

            bd40 ------> Blu-ray (Main@L4.0) preset

            bdhq40 ----> Blu-ray High Quality (High@L4.0) preset

            bd41 ------> Blu-ray (Main@L4.1) preset

            bdhq41 ----> Blu-ray High Quality (High@L4.1) preset

            avchd -----> AVCHD (Main@L4.0) preset

            avchdhq ---> AVCHD High Quality (High@L4.1) preset

            sdb -------> Stand-alone HW players SD (Baseline@L3.0) preset

            sdm -------> Stand-alone HW players SD (Main@L3.0) preset

            sdh -------> Stand-alone HW players SD (High@L3.0) preset

            hdb -------> Stand-alone HW players HD (Baseline@L4.0) preset

            hdm -------> Stand-alone HW players HD (Main@L4.0) preset

            hdh -------> Stand-alone HW players HD (High@L4.0) preset

            ag1 -------> Android G1 preset

            ag1hq -----> Android G1 High Quality preset

            ipc -------> Apple iPod Classic preset

            ipchq -----> Apple iPod Classic High Quality preset

            ip --------> Apple iPod preset

            iphq ------> Apple iPod High Quality preset

            iph -------> Apple iPhone preset

            iphhq -----> Apple iPhone High Quality preset

            atv -------> AppleTV preset

            atvhq -----> AppleTV High Quality preset

            ar --------> Archos 605 preset

            arhq ------> Archos 605 High Quality preset

            ar5 -------> Archos 5 preset

            ar5hq -----> Archos 5 High Quality preset

            bb --------> Blackberry Bold 9000 preset

            bbhq ------> Blackberry Bold 9000 High Quality preset

            nks60 -----> Nokia S60 preset

            nks60hq ---> Nokia S60 High Quality preset

            psp -------> Sony PSP preset

            psphq -----> Sony PSP High Quality preset

            ps3 -------> Sony PS3 preset

            ps3hq -----> Sony PS3 High Quality preset

            mz --------> Microsoft Zune preset

            mzhq ------> Microsoft Zune High Quality preset

            mx --------> Microsoft XBOX 360 preset

            mxhq ------> Microsoft XBOX 360 High Quality preset

            htm -------> HTC Magic

external call was successfull

grep: 3000_x264_encoding_parameters.txt: No such file or directory

encoder options by preset are empty. Using default settings.

grep: 3000_x264_encoding_parameters.txt: No such file or directory

geometryfilteroptions

video filters used for first pass:  -vf harddup

AUDIO channel used

second audio

MEncoder SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

Exiting... (error parsing command line)

video filters used for second pass:  -vf harddup

MEncoder SVN-r30425-4.3.4 (C) 2000-2010 MPlayer Team

Exiting... (error parsing command line)

Please specify an existing file as input

Call to external program avi2mkv failed.
```

It does seem to work without the options, though.

----------

## fangorn

OK, maybe the release was a little bit hasty.   :Embarassed: 

As you might have read in the Changelog, I have rewritten the option handling. But -b should normally work. For a try, use --bitrate instead. I think the long version of -p is --preset, but I am not sure atm.   :Rolling Eyes: 

And -n is not needed/supported any more. 

Note to self: Do not remove options, just drop them dead when not needed any more.   :Evil or Very Mad: 

----------

## fangorn

Found the bug. I assigned -n option twice.   :Rolling Eyes: 

New version of blu2mkv is online. Sorry.

----------

## miroR

Can the viewing be fixed perchance?

https://docs.google.com/leaf?id=0B27EDPvRqbLKYTAyNDI5YTYtMTNjNi00ZTYxLWExMWQtZGI3OTgwOWZhYzBh&hl=en

https://docs.google.com/leaf?id=0B27EDPvRqbLKNjczMmZlODQtMTY2Mi00NDgyLTg5NzAtYjI0NzQyODIzNDIx&hl=en

(I hope anyone can see what I mean...)

Can that be fixed?

Because the scripts look great...

Or could something else be the matter... I wouldn't think so, as I browse the https://forums.gentoo.org/ just fine anywhere else...

Thanks!

----------

## fangorn

I don't know. 

The Format of the pages was adjusted to this width when the posts contained the code. After deleting the code from the pages the width stayed as it was.

----------

## fangorn

I just released the first version of bluray-info (version 0.0.1, so don't expect too much stability or features  :Wink:  )

It is a perl program based on a parser for .mpls Playlists of BluRay directory structures from bdtools (unreleased AFAIK and therefore reimplemented in Perl).

It can print Clip information as the original mpls_dump, but additionally it can export tsMuxeR .meta files or even use it to output .ts files directly. 

Please use it with care, as it is widely untested.    :Exclamation: 

----------

## ExElNeT

I really like your scripts, they work nice.

Still there are some things I would like to see in your scripts. I am looking for a nice solution to encode a dvd into a mkv container. Your solution is perfect if you have the computing power. Unfortunately I dont. So I would like to use your scripts with a different codec or maybe no codec at all. (keep the mpeg2).

Where would I start if i wanted to extend your scripts? 

thanks, greetz

exelnet

----------

## fangorn

I just updated a few helper programs. 

dejunk now supports optional file- and directory names as command line parameters and only processes them if given.

bluray-info now has the feature export chaptermarks to seperate file when writing tsMuxeR .meta file(s) and optionally demuxing Sup subtitles instead of copying it to .ts container and optionally convert them to VobSub (DVD) subtitle format (using BDSup2Sub). Optionally it only processes all titles longer than <min> minutes, be it for display or export functions.

choose_x264_encoding_parameters.sh is reimplemented in Perl and renamed to choose_video_parameters. No new features atm, but it should now run in any environment with a standard Perl environment.   :Wink: 

The released versions of my other scripts use the old (bash) version at the moment! I will change the used helper script with the next releases.

----------

## fangorn

 *ExElNeT wrote:*   

> I really like your scripts, they work nice.
> 
> Still there are some things I would like to see in your scripts. I am looking for a nice solution to encode a dvd into a mkv container. Your solution is perfect if you have the computing power. Unfortunately I dont. So I would like to use your scripts with a different codec or maybe no codec at all. (keep the mpeg2).
> 
> Where would I start if i wanted to extend your scripts? 
> ...

 

you could replace everything after 

# first pass  

in function encode_video by this:

```
   nice -n 10    $mencoder $DEVICE $AUDIO $nosubs \

        -ovc copy  $audiocodec \

        $INPUT_FRAMERATE $OUTPUT_FRAMERATE \

        -o "${TMP}/""$moviename""_tmp.avi" 2>> "${TMP}/""$moviename""_mencoder.log"
```

This copies video and the first audio stream to an avi. normally the rest of the calls (mainly to avi2mkv) should work es usual, but I have not tested it. 

You could also replace the -ovc copy part by -ovc lavc -lavcopts ...

There are quite a few howtos for converting DVD content to MPEG4 (DIVX/XVID). I'd start with a 1pass setting for testing what -lavcopts suit your needs.

----------

## fangorn

There are some news (after quite a while of not saying anything, but I was busy). 

I just released bluray-info-0.2.0. It has some new features, but mainly is easier in handling and more tested. It is dependent on a new program though. I created a script for all the tools I plan to use in perl versions of all my scripts. toolbox_fangorn is available from the list of programs and has it's own post. 

As already stated I am in the process of rewriting all my scripts in Perl and in the process clean them up a lot and centralize functions used in all of them. Here is a little update on the progress I make. 

Atm. I am testing avi2mkv (the more advanced features like automatic audio recoding) on both Linux and Windows. Basics are already working.

blu2mkv is rewritten and I just have to test it. riptoh264 is a little stubborn atm. as some dependencies are not available for windows and I have to think of how to replace them either in Perl or with available external programs. 

Also I set up a little project page for all my tools. It is reachable under http://fangornsrealm.eu

(don't complain about the design, please. I know it is ugly as hell.   :Twisted Evil:  But I do neither have the time nor the skills to design a prettier one.)

----------

## Brad1213

I'm having trouble with blu2mkv

I have built x264,ffmpeg and mplayer from svn/git and configured them using the options from earlier in this thread.

When I run blu2mkv, I get this:

```

blu2mkv -b 3000 -p hq casino-test.mkv 

Video Bitrate set to 3000

x264 encoding preset set to hq

Source file is of Type  AVI

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

No audio stream specified. Trying to use specified languages if available in source file. If not, default stream will be used.

Resolution = 1920:1080

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: no

using audio stream: default

calling external program choose_x264_encoding_parameters.sh

external call was successfull

using seleted preset hq

geometryfilteroptions expand=1920:1080

video filters used for first pass:  -vf expand=1920:1080,hqdn3d=2:1:2,harddup

AUDIO channel used

second audio

MEncoder SVN-r30985-4.3.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x17a79b54

AVI file format detected.

[aviheader] Video stream found, -vid 0

[aviheader] Audio stream found, -aid 1

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps  25996.1 kbps (3173.3 kbyte/s)

[V] filefmt:3  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [harddup]

Opening video filter: [hqdn3d=2:1:2]

Opening video filter: [expand w=1920 h=1080]

Expand: 1920 x 1080, -1 ; -1, osd: 0, aspect: 0.000000, round: 1

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=56000 sample-1)

[h264 @ 0xb7cf00]concealing 8160 DC, 8160 AC, 8160 MV errors

[h264 @ 0xb7cf00]concealing 6921 DC, 6921 AC, 6921 MV errors.000 [0:0]

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

[h264 @ 0xb7cf00]concealing 7448 DC, 7448 AC, 7448 MV errors.004 [0:0]

[h264 @ 0xb7cf00]concealing 6970 DC, 6970 AC, 6970 MV errors.008 [0:0]

[h264 @ 0xb7cf00]concealing 8063 DC, 8063 AC, 8063 MV errors.011 [0:0]

[h264 @ 0xb7cf00]concealing 6805 DC, 6805 AC, 6805 MV errors.014 [0:0]

[h264 @ 0xb7cf00]concealing 8034 DC, 8034 AC, 8034 MV errors.017 [0:0]

[h264 @ 0xb7cf00]concealing 7001 DC, 7001 AC, 7001 MV errors.020 [0:0]

[h264 @ 0xb7cf00]concealing 7899 DC, 7899 AC, 7899 MV errors.022 [0:0]

[h264 @ 0xb7cf00]concealing 7268 DC, 7268 AC, 7268 MV errors.024 [0:0]

[h264 @ 0xb7cf00]concealing 8033 DC, 8033 AC, 8033 MV errors.026 [0:0]

[h264 @ 0xb7cf00]concealing 7035 DC, 7035 AC, 7035 MV errors.027 [0:0]

[h264 @ 0xb7cf00]concealing 8101 DC, 8101 AC, 8101 MV errors.029 [0:0]

[h264 @ 0xb7cf00]concealing 6543 DC, 6543 AC, 6543 MV errors.030 [0:0]

[h264 @ 0xb7cf00]concealing 7921 DC, 7921 AC, 7921 MV errors.031 [0:0]

[h264 @ 0xb7cf00]concealing 6535 DC, 6535 AC, 6535 MV errors.032 [0:0]

[h264 @ 0xb7cf00]concealing 8101 DC, 8101 AC, 8101 MV errors.033 [0:0]

[h264 @ 0xb7cf00]concealing 6068 DC, 6068 AC, 6068 MV errors.034 [0:0]

[h264 @ 0xb7cf00]concealing 8160 DC, 8160 AC, 8160 MV errors.035 [0:0]

Writing header...2f ( 1%) 10.75fps Trem:   4min   0mb  A-V:0.042 [0:0]

ODML: vprp aspect is 16:9.

Setting audio delay to 0.083s.

Writing header...

ODML: vprp aspect is 16:9.

Setting audio delay to 0.083s.

Pos: 117.9s   2878f (99%) 14.61fps Trem:   0min  14mb  A-V:0.042 [598:448]

Flushing video frames.

Writing index...

Writing header...

ODML: vprp aspect is 16:9.

Setting audio delay to 0.083s.

Video stream:  598.467 kbit/s  (74808 B/s)  size: 8979742 bytes  120.037 secs  2878 frames

Audio stream:  448.000 kbit/s  (56000 B/s)  size: 6636000 bytes  118.500 secs

video filters used for second pass:  -vf spp,expand=1920:1080,hqdn3d=2:1:2,harddup

MEncoder SVN-r30985-4.3.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x17a79b54

AVI file format detected.

[aviheader] Video stream found, -vid 0

[aviheader] Audio stream found, -aid 1

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps  25996.1 kbps (3173.3 kbyte/s)

[V] filefmt:3  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [harddup]

Opening video filter: [hqdn3d=2:1:2]

Opening video filter: [expand w=1920 h=1080]

Expand: 1920 x 1080, -1 ; -1, osd: 0, aspect: 0.000000, round: 1

Opening video filter: [spp]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=56000 sample-1)

[h264 @ 0xb7cf00]concealing 8160 DC, 8160 AC, 8160 MV errors

[h264 @ 0xb7cf00]concealing 6921 DC, 6921 AC, 6921 MV errors.000 [0:0]

[PP] Using external postprocessing filter, max q = 6.

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

Exiting...

muxing to Matroska container

mkvmerge v2.9.9 ('Tutu') built on Apr  2 2010 15:14:22

Error: The file 'casino-test.avi' has unknown type. Please have a look at the supported 

file types ('mkvmerge --list-types') and contact the author Moritz Bunkus <moritz@bunkus.org> 

if your file type is supported but not recognized properly.

```

It fails on the second pass,  I checked the command.log and ran the second pass again.

```

/usr/local/bin/mencoder casino-test.mkv -oac copy -nosub -ovc x264 -x264encopts me=umh:me_range=16:nodct_decimate:8x8dct:

nofast_pskip:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4:mixed_refs:keyint=240:psy_rd=0.8,0.2:frameref=3:bframes=4:b_adapt=2:

b_pyramid=normal:weight_b:weightp=1:direct_pred=auto:subq=6:mbtree:chroma_me:cabac:aq_mode=1:deblock:vbv_maxrate=9500:

vbv_bufsize=12000:level_idc=41:threads=auto:ssim:psnr:bitrate=3000:pass=2 -passlogfile casino-test_2pass.log 

-vf spp,expand=1920:1080,hqdn3d=2:1:2,harddup -fps 24000/1001 -ofps 24000/1001 -o casino-test.avi

MEncoder SVN-r30985-4.3.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x17a79b54

AVI file format detected.

[aviheader] Video stream found, -vid 0

[aviheader] Audio stream found, -aid 1

VIDEO:  [avc1]  1920x1080  24bpp  23.976 fps  25996.1 kbps (3173.3 kbyte/s)

[V] filefmt:3  fourcc:0x31637661  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [harddup]

Opening video filter: [hqdn3d=2:1:2]

Opening video filter: [expand w=1920 h=1080]

Expand: 1920 x 1080, -1 ; -1, osd: 0, aspect: 0.000000, round: 1

Opening video filter: [spp]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=56000 sample-1)

[h264 @ 0xb7cf00]Missing reference picture

[h264 @ 0xb7cf00]decode_slice_header error

[h264 @ 0xb7cf00]Missing reference picture

[h264 @ 0xb7cf00]decode_slice_header error

[h264 @ 0xb7cf00]Missing reference picture

[h264 @ 0xb7cf00]decode_slice_header error

[h264 @ 0xb7cf00]Missing reference picture

[h264 @ 0xb7cf00]decode_slice_header error

[h264 @ 0xb7cf00]concealing 8160 DC, 8160 AC, 8160 MV errors

[h264 @ 0xb7cf00]top block unavailable for requested intra4x4 mode -1 at 0 50

[h264 @ 0xb7cf00]error while decoding MB 0 50, bytestream (15385)

[h264 @ 0xb7cf00]concealing 6921 DC, 6921 AC, 6921 MV errors

[PP] Using external postprocessing filter, max q = 6.

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

x264 [info]: using SAR=1/1

x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT

x264 [error]: requested bitrate is too low. estimated minimum is 78 kbps

x264_encoder_open failed.

FATAL: Cannot initialize video driver.

Exiting...

```

I've tried changing the bitrate but it doesn't make any difference.

Any ideas?

Brad

----------

## fangorn

I had similar problems once (when it was a very young feature) with mbtree. Now it is only a young feature and I have not had any problems with it lately, but who knows?

You could try if changing the :mbtree part in the encoding options to :nombtree makes this work. I honestly don't know if this option affects the normal twopass log too or if it is sufficient to just run the second pass without mbtree support. 

Also I recognized that the audio stream detection did not find anything in your case. Does the MKV have not language specifications (you can change that on the fly with mmg header editor) or do the language settings in blu2mkv do not match your preferred languages (you have to change them by hand at the top of the program).

----------

## Brad1213

Hi

I realised I didn't have mmg, so I remerged media-video/mkvtoolnix with wxwidgets to get mmg.

Opened the test file in mmg and it said it was not a valid mkv (xbmc was playing this test clip with no problems). 

I had used, mencoder -ss 600 -endpos 120 movie.mkv -oac copy -ovc copy -o movie-test-clip.mkv which appears to create an invalid mkv.

Guess that was part one of the problem  :Very Happy: , so I used to mmg to export some test clips as valid mkvs.

I tried changing the mbtree to nombtree but still the same error. I had already spent a couple days trying to get this working and was convinced it was something to do with my version or config  of mplayer and x264.

So I decided to try the ~amd64 versions from portage.  Which pulled in x264-0.0.20100118, ffmpeg-0.5_p21602 and mplayer-1.0_rc4_p20100213-r1

x264 is now at libx264.so.83 rather than the libx264.so.92 that I had from built from git. 

I set the path to /usr/bin/mencoder and tried blu2mkv again and it worked, almost. 

It did the second pass, but failed on the mkvmerge.

```
Setting audio delay to 0.083s.

Video stream: 3001.905 kbit/s  (375238 B/s)  size: 48594983 bytes  129.504 secs  3106 frames

Audio stream:  448.000 kbit/s  (56000 B/s)  size: 7252000 bytes  129.500 secs

muxing to Matroska container

mkvmerge v2.9.9 ('Tutu') built on Apr  6 2010 18:51:09

Error: No language specified in '--language 0:'.

```

I re-ran mkvmerge from the command.log but changed the '--language 0:' to '--language 0:eng' and it worked fine.

I had set the lang in avi2mkv

```
first="eng"

second= ""
```

and blu2mkv 

```
mkv_firstlanguage="eng"

mkv_firstlanguage=""

```

I set them all to eng and re-ran blu2mkv, it worked fine.  Not sure if that is a bug. 

What would be good bitrate to use to encode from a bluray source?  Xbmc says the bluray disk (also h264) is playing at 24-26Mbits, I re-encoded the test clip with -b 3000 and the bitrate when playing is about  1-1.2Mbits.  The file size went from 350mb to 75mb,  I couldn't see any loss of quality (2min clip is a small sample though).

So I set -b 6000 -p vdhq for the whole movie, but am still waiting on that..

Thanks for the scripts and help.

Brad

----------

## fangorn

Yes, with these settings mencoder produces "wrong" mkvs. It actually produces an AVI that is named .mkv  :Wink: 

The language problem is most likely a bug. I have this one on the agenda for the next version of avi2mkv anyway (which I am testing thoroughly atm.)

For bluray reencodings I use -b 6000 (default of blu2mkv for 1080p) and nq, which give - for my opinion - the best tradeoff between quality and reencoding time.

----------

## fangorn

I fixed a bug in bluray-info. New version available

----------

## fangorn

I just released some new versions with some new features. Main change nevertheless is the rewrite in Perl, so theoretically it should work on any Operating system that has Perl (and the respective dependencies, which is quite a problem with avi2mkv). I am not that used to actually using (as in not only running a program on it) Windows any more - as in the nineties with Windows NT 4.0 - so I have some problems setting up a testing environment that is capable of running avi2mkv.   :Rolling Eyes:  Therefore I decided to not longer postpone the release of version 2.0.0, even if one of the main features (windows) is not tested at all. 

I added configuration file support to toolbox_fangorn and therefore all following Perl versions, for the moment bluray-info_0.2.1 and avi2mkv_2.0.0 or later. 

I added handling of multiple languages and audio streams to avi2mkv. It handles as many audio streams as languages are specified (from script, config file or on the command line) be it internal, external or both.

Edit: Also there is a new version of choose_video_parameters where I fixed some bugs.

----------

## fangorn

And another brand new program to announce: riptoh264 is now available in version 2.0.0 as brand new Perl rewrite with all the shiny new features like configuration file and multiple languages and audio stream support. 

Also by default subtitles are now only exported when they match a preferred language and all subtitles can be exported by command line switch.

there is now normally no need for the -d option (when -n is used to specify a title, it is advisable to use the -d option too)

I also fixed a few bugs in avi2mkv subtitle handling and added some functions to toolbox-fangorn. New versions available.

----------

## fangorn

I have just released version 3.0.0 of menc.

In the process of rewriting the program in Perl I added some neat features, fixed some bugs and 

cleaned up a little.

Also I fixed some bugs in avi2mkv, added some features to toolbox_fangorn. Also riptoh264 has 

seen updates. New versions available.

----------

## CrazyTerabyte

Have you thought about adding an ebuild for your tools to the Sunrise overlay?

----------

## fangorn

I don't have any experience with writing ebuilds (just a little editing) so it would take me quite some time. I still have blu2mkv in queue for a rewrite and thorough testing. 

I don't see an ebuild or multiple ebuilds in the near future from my side. 

But if someone feels capable of writing (and maintaining) ebuilds, I am the last one to complain.   :Wink:  At least the dependencies of the Perl versions are easier to satisfy than for the old bash versions.  

At the moment I am thinking about a mailing list to announce releases and bugfixes.

Also, if someone has suggestions, requests, bug reports, ... PM me here or send me mail at progs @ fangornsrealm.eu

----------

## CrazyTerabyte

 *fangorn wrote:*   

> I don't have any experience with writing ebuilds (just a little editing) so it would take me quite some time.

 

Come on... You wrote your previous scripts in bash, you say you've edited a few ebuilds... And you can't make one? I'm pretty sure you can!   :Wink:  It's not that difficult. And since your scripts are quite "stand-alone", the ebuild will just run "dobin" at the src_install() to install them, and basically nothing else.

Check this: http://devmanual.gentoo.org/

Most pages are not updated to EAPI=2, but it still gives you a good idea about how to write an ebuild.

 *fangorn wrote:*   

> At the moment I am thinking about a mailing list to announce releases and bugfixes.

 

I think a newsfeed (RSS or Atom) at your blog or project homepage might be the best solution. It's easy to implement, and it's easy for everyone to keep updated.

BTW, if you want to parse a program output, try exporting LC_ALL=C before running that program. It will instruct the program to use the built-in, non-translated strings.

----------

## fangorn

 *CrazyTerabyte wrote:*   

> [ And since your scripts are quite "stand-alone.

 

Have you read the dependency list of avi2mkv? And I have reduced it already!   :Wink: 

Yes, I know my ways in bash, but with "edited" I meant "edit the arch" "delete a problematic patch", ...

And my project page is static html once designed by a "homepage builder" (therefore the ugly look) and now updated by hand. I don't know how to implement RSS in this.

----------

## CrazyTerabyte

If you use some kind of version control system, I'd suggest you to host your project at either http://github.com/ (if you use Git) or http://bitbucket.org/ (if you use Hg). I personally prefer Hg (AKA Mercurial), and I think bitbucket has a bit more features than github; but after all git or hg is just a personal preference.

If you don't use any version control system... Well... You should.  :Smile: 

----------

## fangorn

Thank you, but for me saved versions work great. If I would have co-developers, I would use something, but for me alone it is just overkill.

----------

## CrazyTerabyte

 *fangorn wrote:*   

> Thank you, but for me saved versions work great. If I would have co-developers, I would use something, but for me alone it is just overkill.

 

I used to think like that... (really, that's true!) Until I finally realized how good is to have a VCS, and then I started using one on every project, even the smaller ones.

Notice that Hg and Git (and Bzr) are distributed, and you can use them even without an external server. Heck, they are trivial to setup, just one command! I agree that SVN is an overkill, but maybe you should try one of the distributed VCS.

(don't worry, this is the last time I'll suggest this - I won't annoy you any more)

----------

## Korhul

avi2mkv fails for me with this message:

```
syntax error at /usr/local/bin/avi2mkv line 920, near ") {"

Global symbol "$AUDIOID" requires explicit package name at /usr/local/bin/avi2mkv line 922.

Global symbol "$AUDIOID" requires explicit package name at /usr/local/bin/avi2mkv line 923.

syntax error at /usr/local/bin/avi2mkv line 924, near "}"

Execution of /usr/local/bin/avi2mkv aborted due to compilation errors.

```

----------

## fangorn

Do you use the most recent version?

If yes, try an older version (sorry, no link yet, but the directory is openly accessible). 

Anyway, this should not happen as I use avi2mkv all the time, so at least it should start.

----------

## Brad1213

Hi

The latest version of avi2mkv fails, for me aswell.

```
avi2mkv -p vdhq -c title02_chapters.xml -i -t title02 title02.avi title02_first.dts title02_eng.ac3

syntax error at /usr/local/bin/avi2mkv line 920, near ") {"

syntax error at /usr/local/bin/avi2mkv line 924, near "}"

Execution of /usr/local/bin/avi2mkv aborted due to compilation errors.
```

Version http://progs.fangornsrealm.eu/avi2mkv/avi2mkv_1.9.99 works fine.

Version 2.0.0, 2.0.1 and 2.0.3 all fail with the same error.

Brad

----------

## bigdweeb

I'm getting the same error.  I started tracing this back to try and fix it.  

I am running the following command:

```
riptoh264 -p uhq -n Bolt
```

and I get the same error as above.

The problem is happening in the sub avi2mkv_audio_test_codec () subroutine.  The problem is that $AUDCODEC being used in the switch statement on line 920 is NULL.  $AUDCODEC is being set on line 918 as the lowercase version of $temp, but that variable is also NULL.  $temp is being set in the if/else statement above this, and I found the if was being triggered in my case.  In that if statement, $temp is being set by grep'ing through the the @ret array, but when I printed out the contents of the array I found this:

```
The aid option must be an integer: -identify

 Error parsing option on the command line: -aid

 MPlayer SVN-r30554-4.3.4 (C) 2000-2010 MPlayer Team
```

I went back one line to 904 where @ret gets set by running the contents of $command.  The contents of $command are:

```
/usr/bin/mplayer  Bolt.avi  -aid   -identify -frames 0 -vc null -vo null -ao null -nocache 2>&1
```

So it looks like the contents of $AUDIOSRC that gets passed to this function needs to include "-aid" plus an integer.  I'm not sure what is calling this function yet though.

----------

## fangorn

Is this 

```
riptoh264 -p uhq -n Bolt
```

really the command you use?

-n option activates the specification of the movie title after the inputfile. #

I can't see an inputfile in your command line. 

the command you debugged needs the audio id in mplayer specification (zero based, like specified on the command line). 

Normally the id is genrated either by grabbing the languages you specified (if language information is avaliable) or by interating over as many audio streams as either are available of as languages are specified.

It seems you ran into a race condition that never occured to me. Could you please verify that your input is valid? In the riptoh264 temporary directory you should have two log files containing commands. Start with testing the command calling avi2mkv and if that one fails try the one calling mkvmerge

2.0.0 was completly rewritten in another programming language, so it seems plausible that the error disappears pre-2.0.0. But I do not have an idea where to start looking for an error right now.

----------

## bigdweeb

I don't know the right syntax honestly, I am still trying to figure your scripts out.  I thought I found that syntax somewhere else as an example.  I was trying to read right off the disc.  Can you give me an example of how to use that tool correctly and I can try again?  

I am trying to read off the disc directly and encode into x264 in uhq quality, with English language audio.  I would also like to use chapters and maybe subtitles too, but those are secondary wants.

----------

## fangorn

If you want subtitles, then rip the disk to the harddisk first. Else you can buy a new drive before you have your movie!

I changed the default behaviour to assume "directory mode". But I now see, there is no command line option to set "read from disk". You have to set 

```
riptoh264_directory = no
```

in the configuration file (or directory => "no" at the beginning of the program code). I will have to fix that.  

Oh, I just see, the default in the config file is to put directory = no, which overrides the default. So this is not your problem. I just have to rethink my defaults   :Twisted Evil:   :Embarassed: 

Your command line is correct (if you use the default configuration in ~/.fangorn/config). Chaptermarks are transfered automatically. If you want to have only english, either set it to the the default in the config file (remove the language = ger line at the top of the file) or give an additional 

```
--language eng
```

 on the command line (you can also abbreviate it by -l eng). Subtitles are copied using the -s switch, but as already written, it is advisable to copy the dvd to disk before trying to extract subtitles, because for every subtitle used the movie[/code] is read once, plus two times for the encoding. If I want to be really fast, I even copy the dvd to a RAMdisk before starting.   :Twisted Evil:  Ok, that are the things you do if you have 12 GB of RAM and no need for virtualization at the time.  :Wink: 

If you want to rip to disk firs, I prefer the command

```
dvdbackup -M -i /dev/dvd -o . -n <moviename>
```

----------

## fangorn

bigdweeb, could you please verify (with mediainfo or similar) what audio sources your avi has?

Sorry I came up with this question so late. I was quite busy.

----------

## Brad1213

Using perl 5.8.8 with -w, I got this extra error msg.

Unquoted string "case" may clash with future reserved word at /usr/local/bin/avi2mkv line 922.

Updated perl to 5.10.1, had to unmask these in package.keywords:

```
=dev-lang/perl-5.10.1 ~amd64

=sys-devel/libperl-5.10.1 ~amd64

>=app-admin/perl-cleaner-2_pre090920 ~amd64

```

avi2mkv_2.0.3 now works for me.

----------

## fangorn

Ok, that is nice to know. Thanks. 

I originally decided to go with the switch/case statements to get compatibility with 5.8 versions of Perl. But I never tested.   :Embarassed: 

So if I need to depend on 5.10 anyway, I can replace them with given/when statements as Switch.pm will be removed from the standard distribution soon.

----------

## fangorn

@bigdweeb

I just released a new version of avi2mkv where I removed some bad programming style and a few errors. You could try again with this version.

@all

I am just testing new versions of all other programs.

----------

## fangorn

I just updated all my scripts. Including a completely new perl version of blu2mkv. For a complete write up on the new versions, see the project page.

As this is the last major program to port, I may have time for other things at my hands now.  :Rolling Eyes: 

----------

## bobspencer123

just trying out these scripts (specifically the riptoh264) and getting this error:

```

# riptoh264 BEO0NNF1/ test.mkv

###### the BEO0NNF1 is a dvd directory structure that was ripped to hd using dvdfab under wine

starting options testing

Encoding Movie BEO0NNF1 from device BEO0NNF1

encoding Title 1 which has 11 chapters

Volume ID: unknown

Disc ID:

Starting Processing. This can take a while. Please be patient.

  Title 1: has 11 chapters and is  seconds long

Use of uninitialized value in scalar chomp at /home/kundera/scripts/toolbox_fangorn line 1229.

Use of uninitialized value in scalar chomp at /home/kundera/scripts/toolbox_fangorn line 1232.

Use of uninitialized value in scalar chomp at /home/kundera/scripts/toolbox_fangorn line 1235.

Use of uninitialized value in division (/) at /home/kundera/scripts/toolbox_fangorn line 1236.

Use of uninitialized value in division (/) at /home/kundera/scripts/toolbox_fangorn line 1236.

Illegal division by zero at /home/kundera/scripts/toolbox_fangorn line 1236.

```

I have edited the location part for toolbox_fangorn in the riptoh264 script to point towards my script directory which is in my path. 

Any ideas appreciated.

 EDIT  Using the -d switch solved this.

----------

## bobspencer123

for some reason the script is outputting an avi instead of an mkv.

here is the command I'm using now:

```

riptoh264 -aa -a2 -d BEO0NNF1/ test.mkv

```

I also tried it with the -n switch before test.mkv

here is the mencoder log:

```

skip telecining detection, using preset Method: 24000/1001p soft telecined to 30000/1001t

/usr/local/bin/choose_video_parameters -o tmpdir_BEO0NNF1/BEO0NNF1_x264_encoding_parameters.txt  -f 29.970 -p nq  -w 720  -h 480 -W 720 -H 480  -B 1200

using seleted preset nq

geometryfilteroptions

Using filterset:

common filters: lavcdeint

first pass:  -vf lavcdeint

second pass:  -vf lavcdeint

nice -n 10 /usr/bin/mencoder  -dvd-device BEO0NNF1 dvd://1 -aid 128  -vf lavcdeint  -ovc x264 -x264encopts mixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=10:weightp=1:me=hex:aq_mode=2:weight_b:cabac:keyint=300:chroma_me:b_pyramid=normal:bitrate=1200:direct_pred=spatial:subq=5:nodct_decimate:frameref=3:nofast_pskip:trellis=1:level_idc=41:b_adapt=1:threads=auto:ssim:psnr:pass=1:turbo=2 -passlogfile tmpdir_BEO0NNF1/BEO0NNF1_2pass.log  -oac copy  -o tmpdir_BEO0NNF1/BEO0NNF1_tmp.avi

```

it also looks like the aac flag isn't being passed too. I also tried using the -mp4 flag and still avi file.

 EDIT  well I think I figured out that an avi is first created then it is muxed? / converted? to matroska. I let the whole run but then ended up with zero files and a cryptic message about next time try using an input file. I lost the exact message. I will try again tonite when I'm actually home on the computer instead of ssh and see if I can reproduce the problem.

----------

## fangorn

You should have a config file in your /home/<username>/.fangorn/config

Activate debug mode by setting 

debug = yes 

in the config file. Or give the --debug flag on the command line. Then the temporary directory does not get cleaned away. 

to clear the concept up a little: 

I use multiple scripts for encoding - riptoh264 for dvds, blu2mkv for HD content and menc for the rest - who all use mencoder

to produce a valid h.264 video stream and audio in an AVI container (because this one is best supported by mencoder). 

Then all the scripts call avi2mkv to mux the video and audio to other containers and maybe convert the audio on the fly if necessary.

riptoh264 in directory mode (which takes iso files also) is using the name of the directory as name of the movie by default.

If - like in your case - the directory is not named after the movie, you can provide the -n option and specify a name for the 

movie at the end of the command line. I know this is inconsistant, but it is as it is for compatibility reasons with earlier versions.

In no way you have to specify the extension. This is selected by avi2mkv when finally muxing.

A "correct" command line would be

```
riptoh264 --debug -dn BEO0NNF1 <moviename>
```

it is <moviename>, not <filename>

Now to the specific error message. It seems the script cannot fully read the dvd structure. Have you tried playing it with mplayer 

```
mplayer -dvd-device BEO0NNF1 dvd://
```

or you could see if lsdvd can read the dvd structure correctly.

Edit: 

And I think when you are using "long options" (even when they are the short version  :Twisted Evil:  ) it is recommended to use --aa --a2. The documentation for Getopt::Long is not very clear about that, but I do not think that this works for sure with just one -

But if these are the options you found working best for you, you can also set them in the config file.

If you want aac audio in a Matroska container, the support for audio conversion for matroska containers is quite young in avi2mkv and therefore not very well tested. I would start without audio conversion and if that works you can alway start another muxing session with an edited avi2mkv command line.

----------

## bobspencer123

riptoh264 --debug -dn BEO0NNF1 <moviename>

this command worked. I will just use a script I wrote myself (for now) to change the audio to aac and mux container to mp4.

Thanks!

----------

## fangorn

You can do that, but if you find the time, please test avi2mkv for this job, as it is its own domain.

As my hardware is not so keen of MP4 and AAC (it plays, but MKV is supported better) my production 

muxing goes into MKV. I ran just a few test cases, that worked for me. So I could use the input from 

a tester that actually prefers MP4.

----------

## PraetorZero

Try as I might, I haven't had much success with this.

```
blu2mkv 00004.m2ts 1 --on war.mkv

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 41.

Outputfile set to war.mkv

/usr/bin/mplayer 00004.m2ts -msglevel identify=6 -frames 0 -identify -vc null -vo null -ao null 2>/dev/null 

/usr/bin/ffmpeg -i 00004.m2ts 2>&1

Source file is of Type Unknown :(

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 24000/1001

Output Framerate used: 24000/1001

Resolution = 1280:720

Do not scale is yes

video is interlaced: no

dynamic noise reduction is active: 

Toolbox detect_crop

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

Argument "[CROP] Crop area" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1258.

Argument " X" isn't numeric in numeric lt (<) at /usr/local/bin/toolbox_fangorn line 1265.

resizing video to 720p

calling external program choose_video_parameters

/usr/local/bin/choose_video_parameters    -f 23.976 -o tmpdir_war.mkv/war.mkv_x264_encoding_parameters.txt -p nq  -w 1280  -h 720 -W 1920 -H 1080 -c 0:0:0:0 -B 4000

-> Using "Normal Quality" preset

Illegal division by zero at /usr/local/bin/choose_video_parameters line 592.

external call was successfull

using seleted preset nq

geometryfilteroptions: 

Filter used for pass 1: 

Filter used for pass 1: crop=0:0:0:0

geometry options used for pass 1: 

Filter used for pass 1: crop=0:0:0:0

Filter used for pass 1: crop=0:0:0:0

Filter used for pass 1: crop=0:0:0:0,hqdn3d=2:1:2

Filter used for pass 1: crop=0:0:0:0,hqdn3d=2:1:2,harddup

Filter used for pass 2: crop=0:0:0:0,hqdn3d=2:1:2,harddup

video filters used for first pass: crop=0:0:0:0,hqdn3d=2:1:2,harddup

AUDIO channel used  -aid 0

MEncoder SVN-r31947-4.4.4 (C) 2000-2010 MPlayer Team

Option x264encopts: turbo option is deprecated; use slow_firstpass to disable turbo

success: format: 0  data: 0x0 - 0x55b27800

TS file format detected.

VIDEO VC1(pid=4113) NO AUDIO!  NO SUBS (yet)!  PROGRAM N. 1

Searching for VC1 sequence header... found

VIDEO:  VC-1  1920x1080, 23.976 fps, header len: 33

[V] filefmt:29  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

==========================================================================

Requested video codec family [wmvvc1dmo] (vfm=dmo) not available.

Enable it at compilation.

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

x264 [info]: using SAR=1/1

x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT

x264 [info]: profile Main, level 4.1

Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]

1 duplicate frame(s)!

Writing header...

ODML: vprp aspect is 16:9.

Writing header...

ODML: vprp aspect is 16:9.

Pos:   0.0s     25f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]

Writing header...

ODML: vprp aspect is 16:9.

Pos: 130.7s   3158f ( 2%) 29.73fps Trem:  79min 2773mb  A-V:0.000 [3873:0]

Too many audio packets in the buffer: (4096 in 10485760 bytes).

Maybe you are playing a non-interleaved stream/file or the codec failed?

For AVI files, try to force non-interleaved mode with the -ni option.

Pos: 130.8s   3159f ( 2%) 29.73fps Trem:  79min 2775mb  A-V:0.000 [3875:0]

Too many audio packets in the buffer: (4096 in 10485760 bytes).

Maybe you are playing a non-interleaved stream/file or the codec failed?

For AVI files, try to force non-interleaved mode with the -ni option.

File not found: 'crop=0:0:0:0,hqdn3d=2:1:2,harddup'

Failed to open crop=0:0:0:0,hqdn3d=2:1:2,harddup.

Cannot open file/device.

Exiting...

video filters used for second pass: crop=0:0:0:0,hqdn3d=2:1:2,harddup

MEncoder SVN-r31947-4.4.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x55b27800

TS file format detected.

VIDEO VC1(pid=4113) NO AUDIO!  NO SUBS (yet)!  PROGRAM N. 1

Searching for VC1 sequence header... found

VIDEO:  VC-1  1920x1080, 23.976 fps, header len: 33

[V] filefmt:29  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

==========================================================================

Requested video codec family [wmvvc1dmo] (vfm=dmo) not available.

Enable it at compilation.

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

x264 [info]: using SAR=1/1

x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT

x264 [error]: bad frame number (3137) at stats line 3133

x264_encoder_open failed.

FATAL: Cannot initialize video driver.

Exiting...

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 41.

movie title is war.mkv

using war.mkv.avi as source

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1229.

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1232.

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1235.

Use of uninitialized value in division (/) at /usr/local/bin/toolbox_fangorn line 1236.

Use of uninitialized value in division (/) at /usr/local/bin/toolbox_fangorn line 1236.

Illegal division by zero at /usr/local/bin/toolbox_fangorn line 1236.

```

And this is from .fanghorn/config

```
profile                        = nq

containerformat                = mkv

debug                          = yes

bluray_repeats                 = 1

bluray_seconds                 = 300

bluray_dups                    = 1

bluray_chapter                 = no

bluray_subtitleconvert         = no

bluray_fps                     = 0

bluray_videoformat             = keep

bluray_reduce_streams          = yes

bluray_extract_core            = no

bluray_start_tsMuxeR           = no

avi2mkv_audiotarget            = copy

avi2mkv_normalize_audio        = no

avi2mkv_setaudiovolume         =

avi2mkv_usestereo              = no

avi2mkv_pan                    = 

avi2mkv_channels               = 

blu2mkv_resolution             = 1280:720

blu2mkv_bitrate                = 6000 

blu2mkv_cropborders            = yes

blu2mkv_expandvideo            = no

blu2mkv_extractcorestream      = no

blu2mkv_interlaced             = no

blu2mkv_process_subtitles      = no

blu2mkv_convert_sup            = no

blu2mkv_TMPPATH = 

blu2mkv_OUTPUTPATH = 

riptoh264_noisereduction       = no

riptoh264_interlaced           = no

riptoh264_crop                 = no

riptoh264_expandvideo          = no

riptoh264_expandif             = no

riptoh264_secondaudiofirst     = no

riptoh264_subtitles            = no

riptoh264_processallsubs       = no

riptoh264_ripall               = no

riptoh264_min_title_length     = 120

riptoh264_TMPPATH              = 

riptoh264_OUTPUTPATH           = 

riptoh264_FORMAT               = PAL

riptoh264_BITRATE              = 1200

riptoh264_audiotarget          = copy

riptoh264_singleaudio          = no

riptoh264_directory            = no

riptoh264_TELECINE_METHOD      = 25p telecined to 25i

riptoh264_rawcommand = 

riptoh264_override_video_encoder    =

```

This is using an updated mplayer ebuild with a new snapshot as of today. (31947) and perl-5.12.1-r1.

I should explain what happens.  It appears to make the first pass fine, but when it comes to the second pass is when it crashes.  I can play the temporary file during the initial run, as it is still encoding.  However, the resolution is still 1920x1080.  As I understand the config file, I've requested that it be resized to 1280x720 with the matted black bars to be cropped.     I'm assuming when it comes to the second run, it fails and the temporary AVI is deleted and recreated with a 0 byte size.

So, my big question is: what am I doing wrong?   Why is it failing, why is the temporary file still 1080p instead of 720p?

----------

## fangorn

 *Quote:*   

> blu2mkv 00004.m2ts 1 --on war.mkv 

 

I do not see what you are trying to do with this command. AFAIK I did not program an option --on 

and the 1 (which did address an audiostream in earlier versions) does not address an audio stream

 in MPEG Transport STream format. Also, in my experience, mencoder did have problems with

 reencoding M2TS files directly. Also there is the problem that most Bluray productions compose 

the Titles of multiple containers and that M2TS has no information of language codes or chapter

 marks or such things. For such cases I have written bluray-info. It reads information from 

AVCHD/Bluray Productions (the playlists) and can extract titles to .ts containers, preserving

 information about languages, chapter, subtitles, ...

the tested procedure would be:

rename the source directory to something meaningful (in your case (war) 

process the directory containing the BDMV directory with bluray-info

extract the main feature (mostly, but not always the longest item in the playlist)

blu2mkv <file.ts>

[/code]

If you just want one language, edit the config file and bluray-info will extract only audio and 

subtitle streams of that language.

As a further tip: mencoder had problems using twopass encoding with the mbtree option before. 

see the <moviename>_mencoder.log for detailed information what went wrong. 

If the problems continue, post the mencoder.log. 

edit: those darn long lines

fangorn

----------

## PraetorZero

```
    --specify-output-name|--on

         specify output name for the video file

```

This is what I was after regarding that trigger.  The .mt2s has 6? audio streams.  I have english selected as the default on the config file.  IIRC, it fails regardless if I specify the audio track at the command line.   I did use tsmuxer to change from .mt2s to .ts as I re-read your original post regarding blu2mkv without much success.

I will try again leaving the config file settings as I noted without any command line switches activated.

----------

## PraetorZero

 *Quote:*   

> edit: those darn long lines

 

I found this little scriptlet on a forum a few years back that works perfect in cases like this.  Just save it as a bookmark and hit it when you run into pages like this.

```
javascript:(function(){var%20D=document;F(D.body);function%20F(n){var%20u,r,c,x;if(n.nodeType==3){u=n.data.search(/\S{45}/);if(u>=0){r=n.splitText(u+45);n.parentNode.insertBefore(D.createElement('wbr'),r);}}else%20if((n.tagName!='STYLE')&&(n.tagName!='SCRIPT')){for(c=0;x=n.childNodes[c];++c){F(x);}}}D.body.innerHTML+='%20';})();
```

----------

## PraetorZero

With only one modification to my posted config, I'm still experiencing the same issue with a muxed .ts file.

Executing "blu2mkv clones.ts"

```
ls -lh tmpdir_clones/

total 16M

-rw-r--r-- 1 me me    0 Aug 10 21:56 clones.avi

-rw-r--r-- 1 me me  16M Aug 10 21:56 clones_2pass.log

-rw-r--r-- 1 me me 1.5K Aug 10 21:56 clones_blu2mkv_command.log

-rw-r--r-- 1 me me  307 Aug 10 20:32 clones_x264_encoding_parameters.txt
```

clones_2pass.log  First line only.

```
#options: 1920x1080 fps=24000/1001 timebase=1001/24000 cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1 

psy_rd=0.00:0.00 mixed_ref=0 me_range=16 chroma_me=0 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 

threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=6 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 

weightb=0 weightp=0 keyint=240 keyint_min=24 scenecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=4000 ratetol=1.0 qcomp=0.60 

qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.40 pb_ratio=1.30 aq=2:1.00
```

Remaining snipped.

clones_blu2mkv_command.log

```
Available audio streams: 4352 4353 4354 4355 4356 4357 4358 4359 4360

/usr/bin/mplayer  -aid 4352 clones.ts -identify -frames 0 -vc null -vo null -ao null  2>&1

Detecting crop window: 

0:0:0:0

/usr/local/bin/choose_video_parameters    -f 23.976 -o tmpdir_clones/clones_x264_encoding_parameters.txt -p lq  -w 1280  -h 720 -W 1920 -H 1080 -c 0:0:0:0 -B 4000

nice -n 10  /usr/bin/mencoder clones.ts  -aid 4352 -oac copy   -nosub  -ovc x264 -x264encopts nomixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=6:weightp=0:me=dia:aq_mode=2:noweight_b:cabac:keyint=240:

nochroma_me:b_pyramid=normal:bitrate=4000:direct_pred=spatial:subq=4:dct_decimate:frameref=2:nofast_pskip:trellis=0:level_idc=41:b_adapt=1:threads=auto:ssim:psnr:pass=1:turbo=2 -passlogfile tmpdir_clones/clones_2pass.log crop=0:0:0:0,hqdn3d=2:1:2,harddup -fps 

24000/1001 -ofps 24000/1001 -o tmpdir_clones/clones.avi

nice -n 10  /usr/bin/mencoder clones.ts  -aid 4352 -oac copy  -nosub  -ovc x264 -x264encopts 

nomixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=6:weightp=0:me=dia:aq_mode=2:noweight_b:cabac:keyint=240:nochroma_me:b_pyramid=normal:bitrate=4000:direct_pred=spatial:subq=4:dct_decimate:frameref=2:nofast_pskip:trellis=0:level_idc=41:b_ad

apt=1:threads=auto:ssim:psnr:pass=2 -passlogfile tmpdir_clones/clones_2pass.log crop=0:0:0:0,hqdn3d=2:1:2,harddup -fps 24000/1001 -ofps 24000/1001 -o tmpdir_clones/clones.avi

/usr/local/bin/avi2mkv        -p lq     -t clones clones.avi 
```

clones_x264_encoding_parameters.txt

```
x264encoptions nomixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=6:weightp=0:me=dia:aq_mode=2:noweight_b:cabac:keyint=240:

nochroma_me:b_pyramid=normal:bitrate=4000:direct_pred=spatial:subq=4:dct_decimate:frameref=2:nofast_pskip:trellis=0:level_idc=41:b_ad

apt=1:threads=auto:ssim:psnr
```

All of this terminates with:

```
ODML: Starting new RIFF chunk at 3071MB.

Pos:5904.6s 141571f (99%) 27.92fps Trem:   0min 3254mb  A-V:-0.051 [3979:640]

TS_PARSE: COULDN'T SYNC

Pos:5904.6s 141572f (99%) 27.92fps Trem:   0min 3253mb  A-V:-0.047 [3979:640]

File not found: 'crop=0:0:0:0,hqdn3d=2:1:2,harddup'

Failed to open crop=0:0:0:0,hqdn3d=2:1:2,harddup.

Cannot open file/device.

Exiting...

video filters used for second pass: crop=0:0:0:0,hqdn3d=2:1:2,harddup

MEncoder SVN-r31947-4.4.4 (C) 2000-2010 MPlayer Team

success: format: 0  data: 0x0 - 0x12a2b204

TS file format detected.

VIDEO VC1(pid=4113) AUDIO A52(pid=4352) NO SUBS (yet)!  PROGRAM N. 1

Searching for VC1 sequence header... found

VIDEO:  VC-1  1920x1080, 23.976 fps, header len: 33

[V] filefmt:29  fourcc:0x31435657  size:1920x1080  fps:23.976  ftime:=0.0417

==========================================================================

Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

AUDIO: 48000 Hz, 2 ch, s16le, 640.0 kbit/41.67% (ratio: 80000->192000)

Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)

==========================================================================

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

==========================================================================

Requested video codec family [wmvvc1dmo] (vfm=dmo) not available.

Enable it at compilation.

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffvc1] vfm: ffmpeg (FFmpeg WVC1)

==========================================================================

audiocodec: framecopy (format=2000 chans=2 rate=48000 bits=16 B/s=80000 sample-1)

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

x264 [info]: using SAR=1/1

x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT

x264 [error]: bad frame number (141554) at stats line 141548

x264_encoder_open failed.

FATAL: Cannot initialize video driver.

Exiting...

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 41.

movie title is clones

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1229.

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1232.

Use of uninitialized value in scalar chomp at /usr/local/bin/toolbox_fangorn line 1235.

Use of uninitialized value in division (/) at /usr/local/bin/toolbox_fangorn line 1236.

Use of uninitialized value in division (/) at /usr/local/bin/toolbox_fangorn line 1236.

Illegal division by zero at /usr/local/bin/toolbox_fangorn line 1236.
```

As you can see, the temporary file is 3071MB before it starts drops out with the divide by zero error.  Somewhere, it's zeroing out the temp file.

----------

## fangorn

The problem why the encoding is not happening is that the mencoder line misses a "-vf " swtich before the crop= and other

 filter options. I did not run into such an error for a long time (and I use this script multiple times a week). I will have to look into it. 

Also the crop parameters are empty, so it seems your source is already in full 16:9 format without black borders. But normally 

it does not use crop parameters then. Besides that the scale= parameters are missing to go from 1080p to 720p. Your settings

 in config file seem to be correct. I will have to test this. 

As for audio streams: blu2mkv prefers audio streams with the language information set. (all of them, not just the ones you want).

 If none are set, it takes the first <number_of_audio_streams_wanted>, which is most likely not what you wanted - besides 

you specially prepared the source.

If only some of the streams have language information, blu2mkv will most probably fail.

----------

## PraetorZero

 *fangorn wrote:*   

> The problem why the encoding is not happening is that the mencoder line misses a "-vf " swtich before the crop= and other
> 
>  filter options. I did not run into such an error for a long time (and I use this script multiple times a week). I will have to look into it. 
> 
> Also the crop parameters are empty, so it seems your source is already in full 16:9 format without black borders. But normally 
> ...

 

The source does have black bars.  I can do a crop detect in mplayer and it provides me with -vf crop=1920:784:0:150.  The text in the config file states:

```
# automatically expand video geometry to reach 16/9 aspect ratio

# (by appending black borders)? (yes or no)
```

so I was under the impression that this should be set to 'no' since I'm trying to avoid said black bars.

I appreciate any help you can give me.   :Smile: 

----------

## fangorn

As said, I think your settings in the config file are valid. 

I will look into the problem at the weekend. It seems I did not test this case.

----------

## fangorn

I just released fixed versions of blu2mkv, toolbox_fangorn and choose_video_profile. 

PraetorZero please test. 

These versions of the helper scripts is widely untested with the other programs!

----------

## bssteph

Kind of new to the whole encoding thing, but using these scripts (version from a couple days ago, I haven't tried the Friday update yet), any ideas why the .mkv output of riptoh264 would play fine in mplayer but not in xine? xine complains about dropped frames and only has a black screen until it seeks a bit and then "finishes". Interested in any suggestions.

Also, when I used riptoh264 -l jpn -l eng and had the order the other way in my config (language = eng, language = jpn), it extracted the audio in the command line order, but labeled them in the config file order (so jpn was labeled eng, and vice versa). Bug?

----------

## PraetorZero

 *fangorn wrote:*   

> I just released fixed versions of blu2mkv, toolbox_fangorn and choose_video_profile. 
> 
> PraetorZero please test. 
> 
> These versions of the helper scripts is widely untested with the other programs!

 

Well, it completes this time around.  This is a huge improvement!   :Smile: 

I'm puzzled with the dimensions of the resulting video, but I think that's just me misunderstanding something.   Thank you for the updates!

----------

## fangorn

@PraetorZero

The dimensions result from my scripts trying to be as compatible as possible. So they use geometry in a 16x16 block design. 

This is not  really necessary most of the time, but it does not hurt (much).  :Rolling Eyes: 

@bssteph

I dont really know anything about xine. I have given up on every application using it a long time ago. There are alternatives that "just work".

For your language order question: That is also a case I did not think of for testing. I will look into it.

----------

## fangorn

New versions of blu2mkv, menc and riptoh264 are available that are now finally able to pass 

language selections given on the command line to avi2mkv.

I should start testing promised functionality more thoroughly.  :Wink: 

Have fun,

fangorn

----------

## Korhul

```
 blu2mkv title01.mkv

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 43.

Source file is of Type Matroska

Width = 1920

Height = 1080

Aspect = 1.77777777777778

Aspect should be 1.77777777777778

Source Framerate: 23.976

Input Framerate used: 23.976

Output Framerate used: 23.976

No audio stream specified. Trying to use specified languages if available in source file.

If not, default stream will be used.

extracting audio stream  for later usage

MPlayer 32128-4.4.3 (C) 2000-2010 MPlayer Team

Playing title01.mkv.

Cache fill:  0.00% (0 bytes)   

libavformat file format detected.

[matroska,webm @ 0x1deade0] Unknown EBML doctype '(none)'

[matroska,webm @ 0x1deade0] Estimating duration from bitrate, this may be inaccurate

[lavf] stream 0: video (h264), -vid 0

[lavf] stream 1: audio (dca), -aid 0, -alang ger

VIDEO:  [H264]  1920x1080  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

Core dumped ;)

Exiting... (End of file)

Resolution = 1920:1080

Do not scale is yes

video is interlaced: no,

dynamic noise reduction is active: 

calling external program choose_video_parameters

unknown_path    -f 23.976 -o tmpdir_title01/title01_x264_encoding_parameters.txt -p nq  -w 1920  -h 1080 -W 1920 -H 1080  -B 6000

external call failed

unknown_path    -f 23.976 -o tmpdir_title01/title01_x264_encoding_parameters.txt -p nq  -w 1920  -h 1080 -W 1920 -H 1080  -B 6000

video filters used for first pass:  -vf hqdn3d=2:1:2

AUDIO channel used  -aid 0

MEncoder 32128-4.4.3 (C) 2000-2010 MPlayer Team

Option x264encopts: turbo option is deprecated; use slow_firstpass to disable turbo

success: format: 0  data: 0x0 - 0x2f370a0a

libavformat file format detected.

[matroska,webm @ 0x2860b30] Unknown EBML doctype '(none)'

[matroska,webm @ 0x2860b30] Estimating duration from bitrate, this may be inaccurate

[lavf] stream 0: video (h264), -vid 0

[lavf] stream 1: audio (dca), -aid 0, -alang ger

VIDEO:  [H264]  1920x1080  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)

[V] filefmt:44  fourcc:0x34363248  size:1920x1080  fps:23.976  ftime:=0.0417

Input fps will be interpreted as 23.976 instead.

Opening video filter: [expand osd=1]

Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1

Opening video filter: [hqdn3d=2:1:2]

==========================================================================

Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family

Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)

==========================================================================

audiocodec: framecopy (format=2001 chans=6 rate=48000 bits=0 B/s=0 sample-0)

Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V: -nan [0:0]

1 duplicate frame(s)!

Writing header...

ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Writing header...

ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Pos:   0.0s      2f ( 0%)  0.00fps Trem:   0min   0mb  A-V: -nan [0:0]

Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.

x264 [info]: using SAR=1/1

x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT

x264 [info]: profile Main, level 4.0

1 duplicate frame(s)!

Writing header...

ODML: vprp aspect is 16:9.

Pos:   0.1s     16f ( 0%)  0.00fps Trem:   0min   0mb  A-V: -nan [0:0]

Writing header...

ODML: vprp aspect is 16:9.

Pos:  43.1s   1047f ( 1%) 22.33fps Trem:  77min 3320mb  A-V: -nan [6464:0]

Too many audio packets in the buffer: (4096 in 21222288 bytes).

Maybe you are playing a non-interleaved stream/file or the codec failed?

For AVI files, try to force non-interleaved mode with the -ni option.
```

Too many audio packets in buffer? What is the cause for this and how to get rid of it, please?

----------

## ktsaou

Hi,

I am trying to use these scripts, but I get this error:

```
tux fangorn # ./avi2mkv

Can't locate feature.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/vendor_perl/5.8.8/i686-linux /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/local/lib/site_perl .) at ./avi2mkv line 220.

BEGIN failed--compilation aborted at ./avi2mkv line 220.

```

The offending line is this:

```
use feature 'switch';
```

I read this is a feature of perl 5.10 but I have perl 5.8.8 installed. Is this right? We should install an unstable version of perl for these to work?

Regards,

Costa

[/quote]

----------

## ExElNeT

I am trying to use your recent version of avi2mkv and get the following error:

```
mencoder not available in path unknown_path. Please correct this.
```

whereis mencoder gives:

```
mencoder: /usr/bin/mencoder /usr/local/bin/mencoder /usr/share/man/man1/mencoder.1.gz
```

greetings

----------

## msalerno

I'm also having issues with these scripts.  I have a bunch of small clips with different bitrates, some SD and some HD.  I was and still am hoping that menc is the best way for me to batch encode these, but I'm getting too many errors.

```
menc ./foo.mp4 

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 43.

File Type: MP4/3GP/3G2 ISO Media

FPS: 59.750

width: 384

height: 288

aspect: 1.33333333333333

calling external program choose_video_parameters

-> Using "Normal Quality" preset

nice: unknown_path: No such file or directory

Switch will be removed from the Perl core distribution in the next major release. Please install it from CPAN. It is being used at /usr/local/bin/toolbox_fangorn, line 43.

movie title is foo

mplayer not available in path unknown_path. Please correct this.

```

Running the script with perl -d shows me that my first error is here:

```
my $command = sprintf "%s  -identify -frames 0 -vc null -vo null -ao null %s 2>&1", $progs->{mplayer}, $opt->{file};

 print $command . "\n" if $opt->{debug};

 @mplayer_info = `$command`;

 chomp @mplayer_info;
```

The script does not locate my mplayer, although like 370 is "$progs->{mplayer} = "/usr/bin/mplayer";"  which is the correct path.

Are these scripts still maintained?

----------

## angry_vincent

Hi!

How to work with scripts? , i have DVD copied to harddrive, for example, ~/video/eraserhead with audio_ts and video_ts subdirectories. I want to create a single eraserhead.mkv with highest quality possible. I can't find any documentation and examples for those scripts. Thx in advance

----------

## devsk

avi2mkv script doesn't seem to like whitespace in file name. There are some quoting issues.

----------

## fangorn

 *devsk wrote:*   

> avi2mkv script doesn't seem to like whitespace in file name. There are some quoting issues.

 

Yes, this is the case for most of my scripts. Whitespace and other crude characters are not officially supported   :Twisted Evil: 

Sorry for the long time out. I somehow lost track of this thread.   :Rolling Eyes: 

I will now start develop the scripts again after just using them for quarter of a year.

----------

## fangorn

I don't know if this is still relevant, but hey  :Rolling Eyes: 

 *Korhul wrote:*   

> 
> 
> ```
>  blu2mkv title01.mkv
> 
> ...

 

This is only a following error. Either your input file has some strange settings or your mplayer/ffmpeg does not recognize its special format.

----------

## fangorn

 *ktsaou wrote:*   

> Hi,
> 
> I am trying to use these scripts, but I get this error:
> 
> ```
> ...

 [/quote]

Sorry, but yes. I originally intended to make this compatible to perl 5.8, but in the end it did not work. 

Perl 5.10 is marked unstable because perl is a major core package. Many many scripts depend on it. I decided to use 5.10, but you always can install a 5.10 version in /usr/local in parallel and use this if you don't want to make it system wide.

----------

## fangorn

 *ExElNeT wrote:*   

> I am trying to use your recent version of avi2mkv and get the following error:
> 
> ```
> mencoder not available in path unknown_path. Please correct this.
> ```
> ...

 

Is any of the two executables /usr/bin/mencoder /usr/local/bin/mencoder referenced in your ~/.fangorn/config file? You have to give the full path in there, not just "mencoder".

```

>grep mencoder ~/.fangorn/config

mencoder                = /usr/local/bin/mencoder

```

----------

## fangorn

 *msalerno wrote:*   

> I'm also having issues with these scripts.  I have a bunch of small clips with different bitrates, some SD and some HD.  I was and still am hoping that menc is the best way for me to batch encode these, but I'm getting too many errors.
> 
> ```
> menc ./foo.mp4 
> 
> ...

 

I did not run into a problem like this ever. Something seems to be wrong with your environment. Please check your perl installation (perl 5.10 or higher) and the ~/.fangorn/config file. Maybe move ~/.fangorn/config somewhere else and let it generate a new one.

----------

## fangorn

 *angry_vincent wrote:*   

> Hi!
> 
> How to work with scripts? , i have DVD copied to harddrive, for example, ~/video/eraserhead with audio_ts and video_ts subdirectories. I want to create a single eraserhead.mkv with highest quality possible. I can't find any documentation and examples for those scripts. Thx in advance

 

See the project page for a brief introduction. Use 

```
riptoh264 <directoryname>
```

 for standard encoding options for the main movie (way good enough for normal dvds if you ask me). 

use -b <bitrate> to set a higher bitrate and -p uhq to change default x264 preset.

or use 

```
--override_video_encoder "-ovc copy"
```

 to skip video transcoding completely and use the original dvd MPEG2 video stream. Audio is copied by default anyway.

----------

## fangorn

By the way: 

I am looking for a more or less helpfull project to train my QT programming skills. 

An idea was a GUI tool for batch encoding with all my encoding scripts. 

This means in a first step: Select the application and pull the files/directories to encode 

into the program window. Encoding happens with the default settings from ~/.fangorn/config.

In a second step there could be a possibility to configure command line options from the GUI.

As I prefer the command line, this project would be completely for you. So please, raise a hand 

if you are interested in having such a tool.

----------

## bobspencer123

I would definitely be interested in this ... would love it to be GTK but beggars can't be choosers  :Smile: 

----------

## fangorn

I just uploaded a new version of riptoh264. 

As I just had to encode some DVDs recently I discovered there is a problem with audio sync

when copying audio streams while encoding video with recent mplayer/mencoder. 

riptoh264 now uses a workaround of encoding a fake MP3 audio stream while encoding the video 

portion and later throw the MP3 stream away and replace it with the original streams. 

While at it, I also uploaded new versions of avi2mkv and toolbox_fangorn.

----------

## HolgerB

Hi there,

I have been trying to get the fangorn toolbox running on a Debian-based distrib. Linux Mint 10 x64 (which is based on Ubuntu 10.04 LTS more precisely).

I grabbed all the scripts from http://fangornsrealm.eu, made them executable and copied them to /usr/lib/

Just for experimenting I was trying to convert a 720p MP4 file (game test review) into an MKV container with MP3 audio. Unfortunately avi2mkv bombs out with this error messages:

```
avi2mkv deusexhrtest-hd.mp4 -a3

Use of uninitialized value in scalar chomp at /usr/bin/avi2mkv line 526.

Movie deusexhrtest-hd.mp4 with title deusexhrtest-hd has a geometry of 1280 x 720 and a framerate of 30.000

Video stream is 0, audio stream(s) are 1 

muxing to Matroska container

file type is AVI

language not found. trying to match languages with list of known translations

file type is AVI

Use of uninitialized value in split at /usr/bin/avi2mkv line 1043.

Use of uninitialized value in substitution (s///) at /usr/bin/avi2mkv line 1045.

Use of uninitialized value in string eq at /usr/bin/avi2mkv line 1308.

Use of uninitialized value in string eq at /usr/bin/avi2mkv line 1315.

Use of uninitialized value in string eq at /usr/bin/avi2mkv line 1335.

Argument "-aid 1" isn't numeric in subtraction (-) at /usr/bin/avi2mkv line 1342.

MEncoder SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team

-1 is not an MEncoder option

Exiting... (error parsing command line)

joining internal and external audio streams

Use of uninitialized value in sprintf at /usr/bin/avi2mkv line 1661.

Use of uninitialized value in sprintf at /usr/bin/avi2mkv line 1782.

sh: unknown_path: not found

cleaning up temporary files

```

The error in the mencoder commandline comes from a -1 as parameter. 

I am really no perl expert but the error messages seem to be related to some audio related stuff,

Any ideas on this ?

TIA,

Holger

----------

## fangorn

@HolgerB

Welcome to the forum.

I am sorry, but MP4 is not well tested as input for avi2mkv. Especially when not all optional parameters

are set (language codes for audio, video parameters, ...) or some non standard conformant formats

are used. 

The script is mainly designed as a helper script for the encoding scripts to convert the mencoder output - 

which is best done as AVI - to other containers. It also works well with AVI containers from other sources, 

containing MPEG4 video and of some kind. 

It should work without problems when you repackage the video with menc first. 

If you don't want to degrade the video quality or invest the trancoding time, you can disable the 

reencoding process with the menc option 

```
--override_video_encoder "-ovc copy"
```

.

I hope you get a better user experience that way.   :Rolling Eyes: 

Have fun, 

fangorn

Edit: I just recognize: 

According to the help function options (-a3 for example) have to be placed between the program name and 

the input filename. I don't have an idea what happens if the option is put after the filename. I have some 

options that expect and use parameters that come after the inputfile. This is not good style, I know that, 

but it was not doable in another way when the scripts were still shell scripts. 

Best guess is, the behaviour of the script is undefined. Please, try the same command line with the -a3 before

the filename.

----------

## fangorn

For the other users a quick information. 

I am in the process of testing all scripts under Windows and have removed some errors that also

affect Linux systems. I will release the best tested versions of all times (TM)  :Twisted Evil:  soon. 

Stay tuned. 

fangorn

----------

## HolgerB

Hello fangorn,

thanks for your quick replies both to my e-mail and here in the forum.

 *Quote:*   

> 
> 
> I am sorry, but MP4 is not well tested as input for avi2mkv. Especially when not all optional parameters
> 
> are set (language codes for audio, video parameters, ...) or some non standard conformant formats
> ...

 

No big issue here. I could hack together a quick script for mencoder / ffmpeg myself for converting mp4 source to mkv.

It was just a quick experiment and I had the MP4 laying around in my download folder but no AVI available.

 *Quote:*   

> 
> 
> The script is mainly designed as a helper script for the encoding scripts to convert the mencoder output -
> 
> which is best done as AVI - to other containers. It also works well with AVI containers from other sources,
> ...

 

As the name avi2mkv implies avi should give the best user experience *ggg*

 *Quote:*   

> 
> 
> I hope you get a better user experience that way. 
> 
> 

 

If your toolset helps me to shrink the roughly 30 DVDs which sit on my external HDD to MKV files with h264 / AC3 in then, I am more than happy  :Smile: 

 *Quote:*   

> 
> 
> Have fun,
> 
> fangorn
> ...

 

I already have. Thanks for your toolkit !

Best regards,

Holger

----------

## HolgerB

Just some short note about using ripttoh264:

As it seems ripttoh264 uses the turbo option for the first pass of mencoder.

My mencoder version complains about this:

```

MEncoder 1.0rc4-4.4.5 (C) 2000-2010 MPlayer Team

Option x264encopts: turbo option is deprecated; use slow_firstpass to disable turbo

```

I have no clue if my Mencoder version (1.0rc4) is the most recent one. I am running my encoding job on an x64 Ubuntu 10.04-based mint system.

----------

## HolgerB

Just another question / bug report:

After successfull encoding of a DVD riptoh264 died with the following message:

 *Quote:*   

> 
> 
> Can't use an undefined value as an ARRAY reference at /usr/local/bin/riptoh264 line 1283.
> 
> 

 

Line 1283 seems to process the subtitle streams:

```

   [b]for (my $iter = 0; $iter < @{$opt->{SUB_LANGUAGE}}; $iter++) { [/b]

       foreach my $twodigit (keys %usedlangs) {

      print STDERR "2-digit code is $twodigit\n" if $opt->{debug};

      print STDERR "stream language is " . @{$opt->{SUB_LANGUAGE}}[$iter] . "\n" if $opt->{debug};

      if (@{$opt->{SUB_LANGUAGE}}[$iter] eq $twodigit) {

          print STDERR "found matching sub stream for language $twodigit with sub stream id " . @{$opt->{SUB_SID}}[$iter] . "\n" if $opt->{debug};

          push @subids, $iter;

          $substreams++;

      }

       }

```

From the processing log I would say that riptoh264 died during ripping the subtitles:

```

/usr/bin/mplayer  -dvd-device ZOMBIES_ANONYMOUS dvd://1 -aid 128 -dumpaudio -dumpfile tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_128.ac3

/usr/bin/mplayer  -dvd-device ZOMBIES_ANONYMOUS dvd://1 -aid 130 -dumpaudio -dumpfile tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_130.ac3

skip telecining detection, using preset Method: 25p telecined to 25i

Detecting crop window: 

704:576:10:0

/usr/local/bin/choose_video_parameters  -f 25.000 -p nq  -w 720  -h 576 -W 720 -H 576 -c 704:576:10:0 -B 1200 "tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_x264_encoding_parameters.txt" 

using seleted preset nq

geometryfilteroptions 

Using filterset: 

common filters: crop=704:576:10:0

first pass:  -vf crop=704:576:10:0

second pass:  -vf crop=704:576:10:0

nice -n 10 /usr/bin/mencoder  -dvd-device ZOMBIES_ANONYMOUS dvd://1   -vf crop=704:576:10:0  -nosub  -ovc x264 -x264encopts mixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=10:weightp=1:me=hex:aq_mode=2:weight_b:cabac:keyint=250:chroma_me:b_pyramid=normal:bitrate=1200:direct_pred=spatial:subq=5:nodct_decimate:frameref=3:nofast_pskip:trellis=1:level_idc=41:b_adapt=1:threads=auto:ssim:psnr:pass=1:turbo=2 -passlogfile tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_2pass.log  -oac mp3lame -lameopts vbr=0:br=128:mode=0  -o "tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_tmp.avi"

First encoding pass done

nice -n 10 /usr/bin/mencoder  -dvd-device ZOMBIES_ANONYMOUS dvd://1   -vf crop=704:576:10:0  -nosub  -ovc x264 -x264encopts mixed_refs:nombtree:partitions=p8x8,b8x8,i4x4:deblock:no8x8dct:bframes=10:weightp=1:me=hex:aq_mode=2:weight_b:cabac:keyint=250:chroma_me:b_pyramid=normal:bitrate=1200:direct_pred=spatial:subq=5:nodct_decimate:frameref=3:nofast_pskip:trellis=1:level_idc=41:b_adapt=1:threads=auto:ssim:psnr:pass=2 -passlogfile tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_2pass.log  -oac mp3lame -lameopts vbr=0:br=128:mode=0  -o "tmpdir_ZOMBIES_ANONYMOUS/ZOMBIES_ANONYMOUS_tmp.avi"

Second encoding pass done

Now muxing Output file

Ripping subtitles

```

I manually muxed the AC3 track plus the video track with fake MP3 via Matroska Mux Gui and the resulting file played back nicely.

Edit: OK, I cross-checked the source files. The DVD has subtitles:

```

eems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 25.00 (50/2)

Input #0, mpeg, from 'VTS_01_0.VOB':

Duration: 00:00:29.96, start: 0.280000, bitrate: 10914 kb/s

Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9000 kb/s, 25 tbr, 90k tbn, 50 tbc

Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

Stream #0.2[0x20]: Subtitle: dvdsub

Stream #0.3[0x21]: Subtitle: dvdsub

Stream #0.4[0x22]: Subtitle: dvdsub

```

----------

## fangorn

There are some news:

blu2mkv gets it’s last service release. It is disontinued. menc can do all it does and more.

There is a new download page at http://blog.fangornsrealm.eu/downloads that 

is a central point to get the programs.

All other programs are now installable a lot more comfortable.

For Gentoo users ebuilds are available at 

http://progs.fangornsrealm.eu/ebuilds.tar.bz2

that install all the denpendencies automatically.

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.

Biggest change: The programs are now also working under Windows! Windows users find a 

compressed archive at http://progs.fangornsrealm.eu/fangorn.zip containing the 

scripts and installation instructions.

In the process of testing the scripts on Windows a number of bugs was corrected that also 

affect the linux usage.

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

these scripts.

Also welcome to the completely new users group working on Windows. The installtion process 

is a little complicated due to the missing central package manager and the sub-optimal support 

for command lines. You have to do many things by hand on Windows.  I hope the installation 

instructions are clear enough. If you have comments to the documentation or any bug reports, 

et me know on progs@fangornsrealm.eu.

Have fun,

fangorn

----------

## HolgerB

Great to hear ! I just grabbed your package and will do a few test encodes on my machine from TV recordings.

----------

## Akovia

Hi,

First off, I just found your scripts yesterday and I think they are brilliant! Thanks for all the hard work.

If there is one thing I think your avi2mkv script could use, it would be a way to regex parse the filename to extract metadata. I realize that you can set the "title" via command line option, but if you could use a regex instead, it could batch apply titles with the correct episode number etc.. 

I have a large collection of files that formats the filenames with a lot of [Bracketed] information that is great to keep in the filename, but is distracting and not needed in the title displayed from a player. I realize that there are a good many considerations to implement this, but it really would be a very useful and outstanding feature.

As far as usage, I can  foresee a few things.

1. a seperate command like..

--title_regex|-tr <perl-regex> 

a perl compatible regular expression that will parse the filename for a match and set the title from match

            user will be prompted with results before processing files or use the "--title_regex_fail|-trf" switch to fallback to filename as title if no match

            (Command fails if no match, prompting user to correct the regex:

             Possibly return a prompt with the matches it finds for the user to accept before processing?)

ie..

```
Title Matches....

DVD Episode - 01 [Xvid-AC3][11ADD24D].avi   Title =>   DVD Episode - 01

DVD Episode - 02 [Xvid-AC3][F56EE4DD].avi   Title =>   DVD Episode - 02

DVD Episode - 03 [Xvid-AC3][7C19F70C].avi   Title =>   DVD Episode - 03

Process files with these matches? (y/n/q) y
```

Preferably bringing up just the faulty regex for editing if user presses n

2. maybe a separate command or a way to format the above command to accept a file or setting from the .fanghorn.config for regex presets.

You could even include a couple useful regex that would remove any brackets and their contents, underscores to spaces, etc...

Anyway, I already have a Bash script that does this for me using mkvpropedit, so it's no big deal to call it after I run your script. I just think it would be a nice addition to your very thorough script. 

Cheers

----------

## fangorn

Not a bad idea. 

But I see two problems: 

Each user will have different feeling what is "relevant information" and for sure have 

different ways to express them

The "ask the user for the unrecognized tokens" approach does not match with my principles 

of "no questions asked" and "just do the right thing"

----------

## Akovia

Thanks for the reply fanghorn.

 *Quote:*   

> Each user will have different feeling what is "relevant information" and for sure have 
> 
> different ways to express them

 

I agree when it comes to mp4, as it has many fields that are supported across many clients. With mkv, I've only seen players that support the title tag, which is the most relevant in each container anyway. I also recognize that these scripts aren't really the right approach to detailed tagging for any container, but being able to set the title on conversion would cover the most important while being very convenient. I would hazard to guess that most people are only setting the title field anyway and this would be a great way to do that. As far as supporting other metadata fields, I knew it would be great for my needs and figured if you don't ask it will never happen. =D

 *Quote:*   

> The "ask the user for the unrecognized tokens" approach does not match with my principles 
> 
> of "no questions asked" and "just do the right thing"

 

Personally I am just fine with this approach, which is why I made the suggestion of a fallback to use the filename as title if a match isn't found. I was just trying to give suggestions for usability of users not quite comfortable with regex, and avoid the inevitable of converting a 4gb folder full of files that don't get tagged they way you thought. I would be fine with just an echo as it's processing, (or into the avi2mkv_command.log) so you could Ctl+C if it's not what you expected.

On another note, as I stated I am still quite new to your scripts and I've run into a snag. For some reason I am unable to batch process of all things. Everything I try only processes the first file then quits.

```
avi2mkv *.avi
```

I've even tried xargs, but nothing seems to work. Any suggestions?

----------

## fangorn

Yes batch processing multiple files is in the queue for menc at the moment. 

Including running multiple jobs in parallel to max. out serious hardware.   :Twisted Evil: 

avi2mkv at the moment does not support multiple input files. 

But you can always let the shell do the job for you. (as long as you are not on Windows, that is)

```
for i in * ; do avi2mkv "$i" ; done
```

Take care of the syntax. And only use avi2mkv options that you want to apply to all files.

----------

## Akovia

 *fangorn wrote:*   

> Yes batch processing multiple files is in the queue for menc at the moment. 
> 
> Including running multiple jobs in parallel to max. out serious hardware.  
> 
> avi2mkv at the moment does not support multiple input files. 
> ...

 

Thank you fangorn. I finally got a chance to try it out and it works great. Just what I needed.  :Very Happy: 

----------

## Akovia

Well I ran into some trouble now =/

Tried to batch convert a folder of ogm files, and a few ended up without audio. (Glad I checked them) I can't tell if it's a script problem or not, but I can ogmdemux manually and re-mux with mkvmergeGUI without any trouble.

I captured the terminal output, but it seems to have conflicting information that I can't decipher.

Here is part of the output:

```
$ avi2mkv Seikai\ no\ Monshou\ -\ 06.ogm

using Seikai no Monshou - 06.ogm as source

video stream is 1

audio streams are 0

Movie Seikai no Monshou - 06.ogm with title Seikai no Monshou - 06 has a geometry of 640 x 480 and a framerate of 23.976

Video stream is 1, audio stream(s) are 1 
```

And the logfile:

```
Logfile created at 2012-03-27 19:37:56

dumping necessary information listings

/usr/bin/mkvmerge  -i "Seikai no Monshou - 06.ogm"  2>&1

/usr/bin/mplayer "Seikai no Monshou - 06.ogm" -identify -frames 0 -vc null -vo null -ao null -nocache 2>&1

avi2mkv_audio_test_codec 1 Seikai no Monshou - 06.ogm

avi2mkv_audio_test_codec 1 Seikai no Monshou - 06.ogm -aid 0

/usr/bin/mkvmerge  --output "Seikai no Monshou - 06.mkv"  -v --title "Seikai no Monshou - 06"    --default-duration 0:24000/1001fps   --default-track 1:yes --forced-track 1:no  --language 1:eng --default-track 1:yes --forced-track 1:no  -a 1 -d 1 "Seikai no Monshou - 06.ogm"   --track-order 0:0,1:0
```

I can post the rest of the terminal output if you wish, just leery of over spamming code if not asked to.

Any thoughts?

Edit: Also wanted to ask if there was a way to have the script exit on a fail?

----------

## fangorn

I did not test ogm that much. But the command line you posted uses a

 track order that needs external audio file. If avi2mkv did not extract the 

audio to an extra file there is something wrong.

As A shot from the hip I would replace 0.1,1.0 by 0.1,0.0

Why it does not use this I have to test.

----------

## Akovia

The command line I used was 

```
for i in *.ogm ; do avi2mkv "$i" ; done
```

I didn't insert any extra options.

After doing some more research I did stumble upon something that may be related. I ran ffprobe on all the files and noticed a pattern.

On the files that muxed correctly, ffprobe shows 2 errors/warnings.

```
[ogg @ 0x9a88b80] Page at 202 is missing granule

[vorbis @ 0x9a8f7a0] Extradata missing.
```

On the ones it skipped muxing the audio I only get a single error/warning

```
[ogg @ 0xb03bb80] Page at 143 is missing granule
```

The hex addresses vary per file, but the errors are identical otherwise. I did a google search on the errors and found a reference to a ffmpeg bug

http://www.mail-archive.com/ffmpeg-issues@lscube.org/msg08585.html

but I can't see how it would be related. I was thinking your script was just demuxing with ogmdemux, then re-muxing with mkvmerge which I am able to do manually without any problems. I don't see where ffmpeg would play any part.

I am using a freshly compiled version of ffmpeg from git less than 2 weeks old following the instructions here.

http://ubuntuforums.org/showpost.php?p=9868359&postcount=1289

As I said before, it may have nothing to do with your script, but I thought you should know. I would just like to figure out a way to know if the muxing failed somehow so I don't end up deleting my sources thinking they were converted properly. If there is any way I can help, just let me know.

Thanks

----------

## fangorn

The error is a little bit more complex. I cannot reproduce. 

I do not use OGM movies and just created one using avi2mkv. It does not show such errors. 

avi2mkv uses ffmpeg only for media type detection (simple audio streams).

That is most likely not the problem. 

When writing MKV it uses mkvmerge, which can thanks to Moritz Bunkus read OGM 

directly. ffmpeg would only be part of the process if you had external audio (a second

audio stream or replacement audio) to identify the audio format. For the rest of the 

detection process it uses mplayer. If you wanted to convert the audio streams before 

muxing the process would get a little bit more complex.   :Rolling Eyes: 

As I cannot reproduce: How were the OGM files created? What formats do video 

and audio streams have (mediainfo can give a good list). As you talked of a 

ffmpeg bug, were they written by ffmpeg? Do you know the command line that 

created them?

Edit: Do you use the default settings for avi2mkv (in /home/<username>/.fangorn/config)?

----------

## Akovia

 *Quote:*   

> I do not use OGM movies and just created one using avi2mkv. It does not show such errors.

 

I'm sure there is something about the files I'm using that is the problem. They are many years old and I have no idea what the encode settings were when it was created.

 *Quote:*   

> avi2mkv uses ffmpeg only for media type detection (simple audio streams).

 

If ffmpeg is being used to detect audio streams and throws that error, might that not explain why it excludes it?

 *Quote:*   

> When writing MKV it uses mkvmerge, which can thanks to Moritz Bunkus read OGM 
> 
> directly. ffmpeg would only be part of the process if you had external audio (a second 
> 
> audio stream or replacement audio) to identify the audio format. For the rest of the 
> ...

 

I didn't realize that mkvmerge could handle OGM directly. After reading this I tried to mux the offending files directly by dropping them into mkvmergeGUI without demuxing first and it worked fine. The only noticeable hitch was that it puts the audio as the first track instead of the video.

It also says here that ffmpeg is only used when there are external audio files. Am I missing something from that statement above where you say it's used for media detection?

 *Quote:*   

> What formats do video 
> 
> and audio streams have (mediainfo can give a good list).

 

```
General

Complete name                    : /Seikai no Monshou - 06.ogm

Format                           : OGG

File size                        : 211 MiB

Duration                         : 25mn 5s

Overall bit rate                 : 1 177 Kbps

Video

ID                               : 0 (0x0)

Format                           : MPEG-4 Visual

Format profile                   : Advanced Simple@L3

Format settings, BVOP            : Yes

Format settings, QPel            : Yes

Format settings, GMC             : No warppoints

Format settings, Matrix          : Default (H.263)

Codec ID                         : XVID

Codec ID/Hint                    : XviD

Duration                         : 25mn 5s

Bit rate                         : 1 010 Kbps

Width                            : 640 pixels

Height                           : 480 pixels

Display aspect ratio             : 4:3

Frame rate                       : 23.976 fps

Resolution                       : 8 bits

Colorimetry                      : 4:2:0

Scan type                        : Progressive

Bits/(Pixel*Frame)               : 0.137

Stream size                      : 181 MiB (86%)

Writing library                  : XviD 0.0.09 (UTC 2003-03-25)

Audio

ID                               : 1 (0x1)

Format                           : Vorbis

Format settings, Floor           : 1

Duration                         : 25mn 5s

Bit rate mode                    : Constant

Bit rate                         : 112 Kbps

Channel(s)                       : 2 channels

Sampling rate                    : 48.0 KHz

Stream size                      : 20.1 MiB (10%)

Writing library                  : libVorbis 1.0 (UTC 2002-07-17)
```

 *Quote:*   

> Do you use the default settings for avi2mkv (in /home/<username>/.fangorn/config)?

 

The only change I made was to the language section.

I really doubt that your script is the cause of the problem here. If anything I'd bet it's one of the tools being used. Maybe this isn't worth troubleshooting much further. The only real issue I see is not getting any feedback when a stream fails to mux properly. This obviously hasn't been a problem in the past, so this might an isolated case. Either way I wanted you to be aware that it can happen.

I appreciate the time you've taken to help me troubleshoot this but I certainly don't expect you to take it any further unless you want to out of curiosity. If so I would be happy to make the source file available to you on my file server. Otherwise, I'll just do my OGM files manually one at a time with mkvmergeGUI. If I run into any other snags with my AVI files I'll be sure to let you know.

Many Thanks,

Ako

----------

## fangorn

Sync problem from .ts source files

mencoder seems to have a serious problem with MPEG Transport Stream (.ts) source files. 

The audio sync is lost completely (due to an increase in video stream playtime). 

Workaround: mux the .ts source files to .mkv using avi2mkv and run menc on the .mkv. 

This seems to get around this problem. 

I am still in the process of developing some new features (processing multiple inputs in 

parallel in menc and riptoh264, bluray-info to optionally feed avi2mkv and output 

anything avi2mkv can directly, ...) 

I did not test anything of this on anything but gentoo so far and testing is pretty slow 

when you test encoding three 1080p fulltime movies in parallel.   :Twisted Evil:  So it will be 

some time until these features hit the streets.

----------

## fangorn

Hi,

after a long break some new features for my scripts.

menc and riptoh264 can now process lists of input files,  and even can process more than one input in parallel to utilize faster machines fully using the –jobs <num> option.

menc can use about any input and call riptoh264 with your configuration for DVD directories/ISO images or bluray-info with your configuration for BluRay directories. Lists of input can be generated by shell expansion on Linux or by menc on Windows. Optionally all subdirectories are searched for input recursively.

avi2mkv can now process multiple inputfiles, one after the other. Wildcards are usable on UNIX/Linux as the shell will process them.

bluray-info now calls avi2mkv at the end if an output container different from TS is requested.

menc and riptoh264 are now capable to convert only parts of the input source. If chapter information is available (internally or in an external file) you can specify  chapter ranges. Or you can specify start and/or end time.

Also there are more little improvements.

Have fun with the tools. And if there are still some problems in the code, don’t hesitate to Email me.

Further improvements for avi2mkv are in progress now, but will take a while. 

fangorn

----------

## wannabegeekster

So how do I use these program's together?  Do I have to run the choose_video_parameters before I convert each video?  The help of the application says that it is mandatory to specify the input video width and height.  Not all videos have the same width and height.

Is it possible to convert all of my videos to 480p?

I ultimately want to do something like this and have all of the videos converted in one go:

find /path -size +800M -exec menc {} \;

While I do enjoy the ability to run something like for f in *.avi; do menc $f; done.  I don't really need that for the most part.

Thanks for the scripts!  Can't wait to try them all out.

----------

## fangorn

You only think of the video type you want to convert. 

For video conversion: 

DVD -> riptoh264

BluRay -> bluray-info (maybe followed by menc)

everything else -> menc

For Container format changes and/or audio conversion: 

avi2mkv

These programs call the others if needed. With exception of bluray-info that does at the moment not 

call menc automatically for recompression of the HD video.

To convert to 480p you have three choices: 

[list=][*]--targetheight 480

keeps the aspect ratio and forces 480 lines

[*]--targetheight 480  --expand_if_cropped

forces a 16/9 video with black borders added if necessary

[*]--targetwidth 854 --targetheight 480

forces an aspect ratio. with --crop you can remove black borders before scaling. [/list]

Your command line is absolutely possible. I would just set the necessary parameters on the command 

line or in the configuration file (~/.fangorn/config). 

One problem with this approach: menc does by intention not delete the original. With this method you 

will double your movies on the harddisk and maybe will not find them again. Use the --outputpath to 

redirect the converted movies to one directory. --tmppath will restrict the temporary files to a location 

you can easily clean if something does not work as expected. 

have fun, 

fangorn

----------

## fangorn

Hi,

after about six months of development I have decided to do an open Beta of avi2mkv and menc version 4.0.0. 

avi2mkv was rewritten next to completely and after that the feature list has tripled. Not counting all the 

automatic glue that makes it convenient. I have tested the basic functionalities on my Gentoo box. The DVD

muxing capabililty aside they are working so far. But I cannot test all the combinations possible. So I will 

be thankful for any bug reports. 

The possibilities are next to endless now. So if you can't figure out how to do something, just ask. The documentation 

most likely can be improved also. 

There is a new installation process that is more convenient (and should work on more distribtuions). This 

was necessary as the number of dependencies has also increased. You can find the new instructionns here: http://blog.fangornsrealm.eu/install/. 

To give a hint what I am so excited about, here is the list of new features for avi2mkv-4.0.0:

 *Quote:*   

>  Version 4.0.0
> 
>  Major redesign of next to anything. Previous functions should still work, though. 
> 
>  General usage changes: 
> ...

 

----------

## _______0

do these scripts have their full-version non-scripted commands?? I find those more interesting.

Let's say I do some conversion, do the script show the original ffmpeg (whatever uses) command on the console?

----------

## fangorn

Yes they do, but not on the console as it would pass by very quickly. 

They write a log file that contains each and every command line to call an external tool. 

This log file is deleted by default when the program run ends. You have to activate the 

--debug option to keep the tools from deleting their temporary files/directories.

----------

## fangorn

Finally I found the time to create a full set of ebuilds. 

http://progs.fangornsrealm.eu/install/ebuilds.tar.bz2

If you need any further instructions, go to the install page. 

http://blog.fangornsrealm.eu/install

menc is out of beta in the meantime, as I managed to reduce the known bugs to zero. 

riptoh264 has gotten some love also, after a long time. 

avi2mkv has had some bugfixes and is really stable for "normal" usage. But a few of the 

new features are still widely untested or known to be buggy, so it's official status stays beta.

Have fun, 

fangorn

----------

## gabrielg

Can anybody tell me which version of imagemagick they are successfully running with menc? It fails compiling after I activated the truetype flag, which is required, this is the error:

```

libtool: link: (cd ltdl/.libs/libltdlc.lax/dlopen.a && x86_64-pc-linux-gnu-ar x "/var/tmp/portage/media-gfx/imagemagick-6.7.8.7/work/ImageMagick-6.7.8-7/ltdl/.libs/dlopen.a")

libtool: link: x86_64-pc-linux-gnu-ar cru ltdl/.libs/libltdlc.a ltdl/loaders/.libs/ltdl_libltdlc_la-preopen.o ltdl/.libs/ltdl_libltdlc_la-lt__alloc.o ltdl/.libs/ltdl_libltdlc_la-lt_dlloader.o ltdl/.libs/ltdl_libltdlc_la-lt_error.o ltdl/.libs/ltdl_libltdlc_la-ltdl.o ltdl/.libs/ltdl_libltdlc_la-slist.o ltdl/.libs/lt__strl.o ltdl/.libs/libltdlcS.o  ltdl/.libs/libltdlc.lax/dlopen.a/dlopen.o 

libtool: link: x86_64-pc-linux-gnu-ranlib ltdl/.libs/libltdlc.a

libtool: link: rm -fr ltdl/.libs/libltdlc.lax

libtool: link: ( cd "ltdl/.libs" && rm -f "libltdlc.la" && ln -s "../libltdlc.la" "libltdlc.la" )

{standard input}: Assembler messages:

{standard input}:11005: Warning: end of file in string; '"' inserted

x86_64-pc-linux-gnu-gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://bugs.gentoo.org/> for instructions.

make[1]: *** [wand/wand_libMagickWand_la-mogrify.lo] Error 1

make[1]: Leaving directory `/var/tmp/portage/media-gfx/imagemagick-6.7.8.7/work/ImageMagick-6.7.8-7'

make: *** [all] Error 2

```

and my version is 6.7.8.7, tried ~amd64 as well with similar luck (different error).

I may just need to open a bug, but want to make sure it isn't me.

Thanks!

----------

## fangorn

imagemagick is a dependency of avi2mkv only if you want to use the dvd USE flag. 

Which is known not to work properly, yet. The test cases I used produce a DVD with 

menus, but the menus do not work correctly at the moment. DVD without menus 

is still not implemented. I am a little stuck with these features for a while now.

So if you can't get it to compile, deactivate dvd support in avi2mkv and it should work. 

I am concentrating on getting audio conversions to work stable on all platforms and 

am at the moment evaluating the best ways to convert multichannel audio streams 

into all other formats. In this resort the platforms are quite different, and I want to have 

the same features on all of them. The current version is working on Linux and Windows, 

but not on Mac OS. And Windows version has compeletely different feature set.

----------

## gabrielg

Thanks, fangorn - just for completeness, while my problem started with the truetype use flag, that was pulled by the dvd use flag, so removing those solved the emerge issue.

Now, sadly, I get an error at runtime:

```

$ menc --help

Bareword found where operator expected at /usr/bin/toolbox_fangorn.pm line 4650, near ") unl"

        (Missing operator before unl?)

syntax error at /usr/bin/toolbox_fangorn.pm line 4650, near ") unl

"

Missing right curly or square bracket at /usr/bin/toolbox_fangorn.pm line 4650, at end of line

Compilation failed in require at /usr/bin/menc line 200.

BEGIN failed--compilation aborted at /usr/bin/menc line 200.

```

My perl is pretty non existent, so I tried to add a } before the last unl, but that created another error, so I thought I'd post it here before playing any further.

----------

## fangorn

I had problems with my provider and the last transfer of the toolbox was never finished. 

So the version you have might be incomplete. 

In doubt download / emerge the toolbox again.

----------

