Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO conveniently convert videos using mencoder, x264
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3, 4, 5, 6, 7  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 6:43 am    Post subject: HOWTO conveniently convert videos using mencoder, x264 Reply with quote

Edit 2011-0917
Some News:


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

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

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

Hi,

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

The purpose of this thread is to

  • create a location where to easily find the most recent version
  • answer question and requests in one place


Why use these scripts?

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

So I designed my scripts around two principles:
  1. 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
    Code:
    for i in * ; do <programname> <options> $i ; done

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

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


  1. 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.
  2. 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.
  3. 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

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


    Code:
    ffmpeg -i <filename>

  • All my scripts have a block with the default settings directly after the big commented block.
    Settings intended to be adjusted by the user are up front and specially marked. You have to set your
    preferred language(s), your preferred containerformat, ...
  • My scripts assume that file and directory names to not include "weird" characters. For achieving
    this goal I use the script dejunk presented further down on this page. But be careful. It assumes
    that you know what you are doing and renames any files and subdirectories in the current working
    directory. So please be sure that you have moved all files to rename into an own directory and are
    actually there on the command line.



Important
I use handcompiled versions of mencoder, ffmpeg and x264 that I install to /usr/local/bin to not
distract installed programs depending on those packages every time I build a new version. If you
use packages maitained by portage or another way where only one version of the package is installed,
change the variables in the beginning of the script to
Code:
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
Code:
export LINGUAS="en"
or
export LINGUAS="en <something_other>"


So use
Code:
export LINGUAS="en" emerge mplayer

or if you build by hand
Code:
LINGUAS="en" ./configure <options>

to build your version of mplayer.

Dependencies:
yet to come :roll:

Finally! The programs:

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


_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sat Sep 17, 2011 1:18 pm; edited 38 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 6:53 am    Post subject: Any -> mkv Reply with quote

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.
Code:
avi2mkv --reverse_audio_streams --title <new_title> <inputfile>


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

Code:
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)

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


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

Finally, the program

http://progs.fangornsrealm.eu/avi2mkv/avi2mkv
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sun Apr 18, 2010 2:38 pm; edited 26 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 6:54 am    Post subject: Convert SD material to MKV Reply with quote

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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sun May 09, 2010 10:04 am; edited 24 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 6:54 am    Post subject: Rip DVDs to MKV Reply with quote

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/riptoh264


Last edited by fangorn on Sun Mar 07, 2010 8:36 am; edited 33 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 6:56 am    Post subject: Converting HD Material (BluRay, HDDVD, DVB-HD) to MKV Reply with quote

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

  1. 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!
  2. Hit the "Copy to Clipboard" button at the bottom of the windows
  3. 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
  4. in the linux command line run
    Code:
    wine tsMuxeR.exe <commandfile> outputfile.ts

  5. 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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Fri Apr 02, 2010 5:32 am; edited 34 times in total
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2152

PostPosted: Sun Mar 08, 2009 1:46 pm    Post subject: Reply with quote

I don't know about the hand-compiled version, but mplayer from portage also brings /usr/bin/midentify, which looks like this
Code:
#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.

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 :)
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 08, 2009 2:33 pm    Post subject: dejunk Reply with quote

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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Thu Apr 01, 2010 11:08 am; edited 6 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sat Mar 14, 2009 7:28 am    Post subject: choose_x264_encoding_parameters.sh Reply with quote

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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sun May 09, 2010 10:07 am; edited 9 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 15, 2009 6:44 am    Post subject: bluray-info Reply with quote

bluray-info

Finally here it is, my very first Perl program :D

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

Usage

go into the BluRay directory (or the BDMV directory) and call the program.
for example:
Code:
bluray-info BDMV/PLAYLIST/*

will list the durations of all the available titles. As does
Code:
bluray-info .


Code:
bluray-info --filter_short .

will display all titles longer than x seconds (default is 300 seconds).
Code:
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.

Code:
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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sun Apr 18, 2010 2:41 pm; edited 10 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Mar 22, 2009 7:06 pm    Post subject: toolbox_fangorn Reply with quote

And another program to handle. :roll:

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
_________________
Video Encoding scripts collection | Project page


Last edited by fangorn on Sun May 09, 2010 10:11 am; edited 3 times in total
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sat Mar 28, 2009 11:22 am    Post subject: Reply with quote

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.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Fri Apr 10, 2009 9:35 am    Post subject: Reply with quote

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)
Code:
# 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

_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Fri Apr 24, 2009 2:27 pm    Post subject: Reply with quote

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. :roll: 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.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
shebang_line
n00b
n00b


Joined: 18 Jul 2004
Posts: 24

PostPosted: Mon Apr 27, 2009 12:43 pm    Post subject: Reply with quote

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 :-)
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Tue May 05, 2009 2:37 pm    Post subject: Reply with quote

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


I am sorry, but this option still isn't available for .ts sources. For these you still have to demux/mux by hand. But now muxing is possible with avi2mkv instead of mmg.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun May 17, 2009 5:19 am    Post subject: Reply with quote

I have posted a script to clean up file- and directorynames from various sources from special characters and other stuff.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
mikioma
n00b
n00b


Joined: 22 Jul 2007
Posts: 16

PostPosted: Fri Oct 09, 2009 2:32 pm    Post subject: Reply with quote

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!!! :D

Thanks for you effort!!!
Back to top
View user's profile Send private message
lordcris
Apprentice
Apprentice


Joined: 09 Jul 2002
Posts: 248

PostPosted: Fri Oct 09, 2009 7:47 pm    Post subject: Reply with quote

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)
Homepage: http://h264enc.sourceforge.net
Description: Script to encode H.264/AVC/MPEG-4 Part 10 formats


in portage now.
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sat Oct 10, 2009 11:25 am    Post subject: Reply with quote

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.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sat Oct 17, 2009 12:17 pm    Post subject: Reply with quote

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

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.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Sun Oct 18, 2009 4:58 pm    Post subject: Reply with quote

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.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Sun Oct 18, 2009 5:38 pm    Post subject: Reply with quote

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
Code:
 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
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Mon Oct 19, 2009 9:04 am    Post subject: Reply with quote

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?
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
SlashBeast
Retired Dev
Retired Dev


Joined: 23 May 2006
Posts: 2922

PostPosted: Mon Oct 19, 2009 11:52 am    Post subject: Reply with quote

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.

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

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

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


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

Yeah, I adding hardsubs because I like subs with transparent background and android still dont have good movie player what will be able to play movie with subs with background.
Back to top
View user's profile Send private message
fangorn
Veteran
Veteran


Joined: 31 Jul 2004
Posts: 1886

PostPosted: Wed Oct 21, 2009 6:30 pm    Post subject: Reply with quote

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

Also I just released a new version of blu2mkv that does not hardcode forced subtitles from Matroska sources anymore but instead copies all available subtitle streams and chapter information to the new file.
_________________
Video Encoding scripts collection | Project page
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7  Next
Page 1 of 7

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum