Skip to main content

x264 transcode

Script for automated backup of DVDs, SD vob and HD m2ts files for GNU/Linux and MacOS X. It works in unattended mode and is designed to run in the background. It rips ALL subtitles and ALL audio tracks and transcodes video to x264, profile 3.1, crf mode, with b-frames. Video stream is cropped to get rid of black borders. Chapters work. The container is MKV. Allows you to easily format shift to more portable form.

Because of the way NTSC DVDs are mastered (Telecine), it is very likely that you will encounter audio drift in the encodes. They mostly contain mixed material (Telecine/Progressive/Interlaced) and will NOT consistently convert. This is why transcoding NTSC DVDs is discouraged. It's not a problem with this script or an issue with IVTC but the inconsistent way in which the NTSC DVDs are mastered. PAL sources are much better as it is almost always progressive.

MacOS X dependencies are all available via http://macports.org.

Quickstart guide:

Unpack, edit config (directories where to store temporary and transcoded files -- do not make that the same directory, as temporary directory is cleaned after transcode), save config to ~/.autoripper.conf (note the dot), run "sh x264transcode.sh file.iso".

The current version is available at:

x264transcode-0.3.1.tar.gz
Please note that there are newer branches available at Github where the code is hosted since January 2011.

Working link to the cd-ripper script:

cdripple-0.06b.tar.bz2

Please note, historical releases have been moved to the attic.



Dependencies

  • mplayer/mencoder that supports x264 encoding
  • mkvtoolnix (provides mkvmerge)
  • lsdvd
  • dvdxchap (part of ogmtools)
  • perl

Legal disclaimer

This software may be in violation of patent law in Germany, USA and South Korea. Your problem, not mine.

Changelog:

All further changes available in Github repository. This section will no longer be updated.

19/01/2011 v0.2.9
- b_pyramid now strict (tested with sigma-based players)
- Profile-strict reframes calculation (was: safest value)
- Main profile for SD encodes, High for HD. Level strict:
576p: Main@3.1, 720p: High@4.0, 1080p: High@4.1
- adding --compression :none for a/v tracks -- most
hardware players die when zlib is used. This
is to allow mkvtoolnix 4.2+ compatibility.
- BUGFIX: SUBTITLE_SUCCESS_COUNT now correctly created
when using existing files (s/cat/wc -l)
- Allow resume if there is not enough space for mkvmerge phase
- BUGFIX: Protect against whitespace in variables
- removed defunct email of SevenOf29
- welcome new contributor (GS), copyright notice updated

16/04/2010 v0.2.8 (not released for some bizarre reason)
- further optimisations for ripping directly from DVDs:
* cache metadata
* eject when dumpstreams are done
- minor tweak to drive unlocking (now playing 0 frames)
- preliminary support for resuming: RESUME=1 to enable
(see README FAQ:2 for more details)
- crop detection moved back to the encoding step
- SHORTEST_FIRST=2 now preserves the title numerical order
- EXIT_AFTER_DUMP=[0|1] and EJECT_AFTER_DUMP=[0|1] now control
what happends when dumping finishes.

15/04/2010 v0.2.7
- script checks for $PREDEFINED_CROP and if present, skips crop
detection (useful for overrides) ="X:Y:W:H"
- BUGFIX: eject command for Mac minor issue fixed

13/04/2010 v0.2.6
- speed improvement when ripping directly from a disk (dumpstream)

02/02/2010 v0.2.5
- No longer loading autoripper.conf from current directory (./)
- Bugfix - more cleanup mess (oh the irony)
- ripper.sh: added "drutil eject" compatibility for MacOS X

07/01/2010 v0.2.4a
- Bugfix - variable evaluation at the end of encode, affects cleanup.
- Bugfix - removed overzealous cleanup

15/12/2009 v0.2.4
- fully implemented seq compatibility for MacOS X
- if no ~/.autoripper.conf found, it will be created
using built-in defaults
- base CRF is now a configuration option (default 18)

07/12/2009 v0.2.3
- error handling for bizarre frame rates (thanks Lionel!)
- corrected rounding error for 41.(6)ms (41.667 now)
- changed variable order in autoripper.conf, added comment which ones
to edit at minimum (backwards compatible)
- added quickstart guide in README
BUGS: README still rubbish (help anyone?).

27/11/2009 v0.2.2
- changed config file loading order to something more sane (~/.dotfile
has highest priority now. local dir -> etc -> dotfile.
- upsampling/downsampling now stable and merged in the config file.
- THREADS (default "auto") controls the number of x264 encoding threads

11/11/2009 V0.2.1b
Bugfix release
- gseq doesn't work on MacOS X. Removed.

11/11/2009 v0.2.1a
Bugfix release
- removed old workaround in configuration (never used)
- fixed ionice command leftover options

10/11/2009 v0.2.1
- b_pyramid syntax now a configuration option (default: new syntax)
- now compatible with MacOS X (seq/gseq/builtin function), use
http://macports.org to get the dependencies.
- ionice now used only if present, otherwise ignored
- both input and output FPS now defined and enforced
- added FORCE_PULLUP=2 (now default). It will now pull entire movie
down first using "softpulldown" and then do a strict pullup
using ivtc=2, _should_ work better for completely messed up
NTSC DVDs and since ivtc=2 enforces 5:4 ratio, in theory there
should be no audio<->video drift.

27/10/2009 v0.2.0
- 1080p -> 720p downsample option
- crswallow moved to http://code.google.com/p/crswallow/
- change in b_pyramid syntax (was: nob_pyramid, is: b_pyramid=none)
in mencoder >= SVN-r29796

15/10/2009 v0.1.9
- added further tool output surpression with optional crswallow tool
(included).

15/10/2009 v0.1.8
- more variable quoting fixes
- added m2ts transcoding (supports both 720p and 1080p)
NOTE: Audio/Sub tracks will not have correct
language information in this mode -- there isn't any data to
process. There is no chapter support in this mode either
(same as vob mode).

08/10/2009 v0.1.7
- vob file processing (concaternate multiple vobs first), no language
codes support (all "und")
- grep '[CROP]' bugfix
- suppress the progress output of mplayer, mencoder, mkvmerge (-quiet)
(NOPROGRESS=1)
- cropdetect loop changed from [sample_points]+1 to -1, don't define
SAMPLE_POINTS < than 3.
- .partial filenames, that will get renamed only after a command
completes
- keep and reuse dump files from a previous aborted run. NOCLEANUP=1
- moved the crop detection further up
- SAMPLING_DIVIDER allows using a fraction of title length to sample
cropping. Useful for dd_rescue'd isos.
- multiple variable quoting bugfixes.
- files have neater permissions now.

05/10/2009 v0.1.6
- Preliminary support for automatic CRF adjustment based on the
source bitrate. See README for more details. Off by
default. You must define DEFAULT_SOURCE_BASED_CRF
in your autoripper.conf.
- Handling of badly mastered DVDs that report subtitles
present, but don't contain any.

25/09/2009 v0.1.5a
- Fixed NTSC pulldown bug, added FORCED_PULLUP variable (on by
default). Disable if you're ripping truly interlaced
content (instead of pulled down NTSC).

25/09/2009 v0.1.5
- Backwards compatibility broken, re-create your autoripper.conf!
- Changed configuration settings priority (export -> config ->
script built in)
- Command output redirected to STDERR
- Added detection of incorrectly mastered DVDs with 0 audio tracks
in the structure (but with default track working)
- Minor quoting fixes
- SID and AID indexes now only incremented on successfull extract
BUGS: pulldown (NTSC) encodes still need work

24/09/2009 v0.1.4
- added second parameter (optional) to supply TITLE_PREFIX
- improved handling of "Unknown" disk titles (now using DISC_ID)
for both x264transcode and ripper.sh
- removed hardcoded /usr/bin paths

17/09/2009 v0.1.3b
- bugfix (-noautosub needs to be before dvd:// otherwise subs get
hardcoded into the stream)

16/09/2009 v0.1.3a
- bugfix (type'o)

16/09/2009 v0.1.3
- Quality setting (HIGH is default, MEDIUM and LOW producing smaller
files)
- README cleanup
- Fixed that bizarre non-printing character in me=umh string (AGAIN!)

14/09/2009 v0.1.2
- config file (preliminary)
- very simple deinterlacing (on/off via config)


14/09/2009 v0.1.1: Merged changes/fixes from SevenOf29. Last version
distributed inline on the forum.
- non-subbed rips finally work
- support for multiple episodes added
- large amount of bugfixes
- Licensing change (from PD -> GPLv3+)
- First numbered release: v0.1.0

29/11/2008 v0.0.1 - 12/09/2009 v0.1.0
- Added avidemux2_cli remuxing of video stream to work around buggy
mencoder muxer
- Fixed the "don't mess with the IFS" bug
- Fixed stuttering on b-frames (=0 now) and changed bitrate control to
crf=18, removed remuxing step - no longer required
- Fixed /etc/inittab entry for ripper.py
- Moved -nosound -noautosub in video encode line to the beginning,
(thanks Epon!)
- ARccOS note, minor cleanups in ripping script -- added -vo null -ao
null there
- Re-enabled b-frames (mplayer muxer is evil), added
pullup,softskip,harddup
- Fixed bug in sp -> spa (possibly others) language selection code,
(thanks bliss!)
- Added workaround for mkvmerge 2.4.0 always muxing video as 25fps
unless --default-duration (in miliseconds) is specified
- Removed no-longer-available "bime" option from the h264 encode
- Added x264 capability check for mencoder (thanks bogolisk!)
- Added handling of non-subtitled DVDs
- Added -ofps in mencoder section (required for pulled-up encodes)
- Added 24.000fps (real), finally changed x264 threads to auto (doh!)
- Fixed that bizarre non-printing character in me=umh string
- Added the "-noautosub" bug warning.
- Added (disabled by default) upsampling option. 720p, crf=20, prof=4.0