PDA

View Full Version : nrip - dvd to matroska converter


Sujao
12th February 2005, 14:54
Title: nrip
Version: 0.0.3
Last change: 21.02.2005
Purpose: Rip DVD, reencode video and audio tracks and multiplex into matroska container.
Author: removed for privacy reasons, see README file
Contact: removed for spam reasons, see README file
Download: http://nforum.de/forum/topic,726.html
License: GPL v2


########
FEATURES
########

nrip does in detail:

-Rip main title of dvd and reencode the video track with XVID codec in two pass mode, quality is made top priority. The xvid parameter can be changed by the user (interactive variables).
-Rip and reencode: ac3 5.1 --> user defined bitrate or keeping original, ac3 stereo --> ogg vorbis, mpeg1 --> left original to avoid further quality loss.
-Rip userdefined subtitle tracks.
-Multiplex everything into a matroska container.

nrip was designed for high quality rips thus target size shouldnt be less than. 2,18GB what is 1/2 of DVD-5. Since version 0.0.3 the target size is variable and can be specified by the user.

The encoding duration strongly depends whether you choose to use GMC(Global Motion Compensation) or not, the lenght of the movie and of course your CPU. I need about 26h for a 02h10m movie with GMC turned on and a 1000Mhz Athlon Thunderbird.


##############
REQUIEREMENTS
##############

The script needs the following programs to work:

- mplayer/mencoder
- lsdvd
- mkvmerge which is part of mkvtoolnix-1.0.1 (maybe also earlier versions but definetely later than 0.8.8. I upgraded directly to 1.0.1 and didn't test the packages inbetween. Gentoo users have to unmask the newest package. I did too and it works just fine.)
- oggenc which is part of libvorbis
- a arbitrary image viewer for viewing of crop preview. Default is "xv". You can change the path in the beginning of the script. Scroll down to the "interactive variables" section.

And optionally "dvdbackup" in order to be able to cache the DVD on harddrive.

More utils are required but they are all part of coreutils which are installed on 99.9% of all linux systems by default. There will be a check in the beginning so just start and you will see if something is missing.

Upgrade all packages to the newest version if possible. These are the packages I use so they should work for sure:

mplayer-1.0_pre5-r5
mkvtoolnix-1.0.1
lsdvd-0.10
dvdbackup-0.1.1-r1
libvorbis-1.0.1

If you are unsure whether your programms will work or not activate one-chapter-mode to perform a quick part conversion and test the resulting video for functions. If one-chpater-mode works than normal mode will work for 95%. One-chapter-mode is also activated at interactive variables in the script. Scroll down to this section. Its pretty obvious.

###########
LIMITATIONS
###########

-Can handle only single title DVDs, that means DVDs with ONE movie. Later versions will be able to handle several DVD titles per DVD disc. This is needed for DVDs with shows. At the moment only the main title is ripped.
-Can handle at most 10 audio/subtitle tracks.
-Can only handle ac3 and mpeg1 audio stremas, no dts/aac.
-Can't determine whether audio track is usual track or commentary. The tracks will apear identical. If that is so you have to find out yourself which one is the right ine. But in 98% of all cases the comentary is the last audiotrack.
-Only simple deinterlacing is possible. Inverse Telecine is not yet implemented. That means NTSC DVDs with 29,97 that were interlaced for DVDs will not be encoded very effectively. You probably wont see a difference but about 33% addition space will be wasted. I have not been able to figure out how the invert telecine filter works in mencoder and as I only have one NTSC DVD that was not made for theathers I have nothing to test with. So you would propably not want to use this script for NTSC DVDs as you wont get optimal results. And to be honest I dont know if I will investigate this issue at all... I mean, in the beginning I just wanted to write some lines of script to automate my ripping process. Some lines means 5-10! I didn't want to make a ~1300 line script. This thing here is much too complex for a bash script.
For more information about inverse telecine see here: http://www.divx-digest.com/articles/vhs_capture2.html

####
BUGS
####

-If temporary folder had been created and has to be deleted then deletes only last level of folder hirarchy. If /home/user was present and /home/user/movies/output/ was created as temporary folder than only "output" will be deleted afterwards and not "movies".
-At the time of this realease I wasnt able to track down the reason for a malfunction of xvid. It doesnt produce files with correct sizes. This bug might only appear when GMC is activated but I havent done enough testint to ensure this. If you produce final files with about 2.1GB please contact me and tell me whether you used GMC and which version of xvid and mplayer you use.

Please report further bugs as soon as discovered. Launch the script with the --debug option and send me the whole output with an description of what happended and what didn't work.

####
TIPS
####

- Pressing ENTER while entering a path makes nrip chose the default folder.
- You can edit some default values at the beginning of the script. Most important are default paths. Be careful with changing. Don't change a mount pount to a device ex. /home/user-->/dev/dvd and vice versa as this might break the script.
- There is a one-chapter-mode avaiable for quick testing. With this option activated only the first chapter of the first DVD title is converted. Depending on the DVD its duration is 10s to 5min. As all steps of the conversion are performed you can be pretty sure that if the one-chapter-mode conversion was successful the normal will be too.

#########
THANKS TO
#########

- The users of the Gentoo Forums for helping me with various problems. (forums.gentoo.org)
- "chris aka ctt" for lots of help with scripts.
- "booiiing" for testing.

Have fun!

#########
CHANGELOG
#########

0.0.3

- dvd cache is now really working
- dvd cache is now really left on harddrive if wanted
- overall target size is variable
- bitrate of ac3 5.1 streams is variable and can be left original
- ac3 stereo (2.0) is converted to ogg. new dependency "oggenc"
- added interactive variable "delete_temp_dir"
- added interactive variable "xvid_parameter". You can now change the parameters for the xvid codec if you want.

0.0.2a

- audio/subtitle listing uses longest track as it should (thanks to kKDu)
- changed volume normalisation to fit closer to original
- tuned target size to fit 1/2 DVD-5 more.
- no errors during listing anymore if no audio/subtitle tracks are in title

0.0.2

- implemented workaround for mencoder bug that displaces ac3 channels (thanks to brancaleone)
- mpeg2 audio is processed
- some minor bugs fixed
- some video encoding improvements
- preview also for manual crop mode
- some internal reorganisation

Be sure to download the latest package by all means.

Sujao
15th February 2005, 10:37
New version avaiable! Don't use the old one anymore.

KpeX
18th February 2005, 18:04
Thanks for posting that. A few questions while I'm giving it a try:

Is it possible to use nrip to keep the original AC3 (no reencoding)?

What are your future plans for nrip (codecs support, other audio options, etc.)?

(edit) there's a minor spelling error in nrip on line 1073: "gcm" should be "gmc"

Sujao
18th February 2005, 23:11
It is possible to leave the tracks as is you would only have to change some lines. I can implement this feature in the next version if you like.
I dont think I will add support for more codecs, as I only choose the best and that is xvid at the moment. (OK, I dont know how to encode with Neros new codec and I dont think its free.) Furthermore a bash script is not the perfect language for complex programs, to my mind it is much more complex than I bash script should be :) Of course I will improve the features and remove bugs but before new features will be added I will change the programming language.

KpeX
19th February 2005, 03:24
I just finished my first nrip encode and I'm impressed with the script. The only other codec that I think would be interesting would be x264, and the AC3 direct-stream-copying I mentioned above. Also it would be nice to have the option of IVTC-ing NTSC film material. I'll work on some changes to the script if I get around to it ;)

Sujao
19th February 2005, 03:43
How big was your mkv-file? And which version of xvid do you use. My version of xvid doesnt produce files with the correct target size.

KpeX
19th February 2005, 05:50
xvid 1.0.3, mplayer cvs, 1.7G (1,686,834 kilobytes)

Sujao
19th February 2005, 09:40
Hmm, that is strange. Actually the resulting file should be about 2.1GB. Someone else (http://forums.gentoo.org/viewtopic-p-2105382.html#2105382) reported to me, that his version of xvid produces too small version too. My version makes the file too big. Instead of 2.1GB I get 3.7GB.

shevegen
20th February 2005, 00:10
here comes the ultimate killer question in response of sujao's last post


why? :)

Sujao
22nd February 2005, 02:38
New bugfixing version!

Teegedeck
27th February 2005, 21:11
I'm very happy to see that an easy-to-use tool that aims at the high-quality end only is available for Linux, now. Though I still use a pet Windows PC for encoding (AviSynth...), I'm surely gonna try this one and direct some people to it. Thanks!

unixfs
28th February 2005, 11:07
I successfully used avisynth in wine to encode with HC.
I didn't feel a perceivable performance decrease, either

shevegen
28th February 2005, 12:19
AviSynth was my most loved Windows app back then :)

It really rules, i hope other projects learn from
the flexible AviSynth approach

six6
7th March 2005, 07:48
Argh, I just lost everything I wrote because my forum cookie expired :angry:

Anyway,

@Sujao

I'm in awe of your script; that's a lot of bashing :). Thanks for allowing for community use!

I looked through it quick and noticed you hadn't touched on

-framerate conversion (-ofps)
Is this an small oversight or because audio/video sync issues? It would help save bits for video in some cases.
-scaling
I'm more familar with perl than bash, but porting calcbpp.pl (MPlayer cvs/tools) into nrip wouldn't be too tough I'd bet, but then again, I haven't tried it :) This would be a nice addition though.


Lastly, are you correcting for channel mappings with '-af channels=6:6:0:0:4:1:1:2:2:3:3:4:5:5,volume=11' in line 1212? Maybe 'volnorm' would be better than 'volume=11', too.

Of course, it's always easier to suggest than do, so I have sympathy for you if my requests/questions are passed up :)

Edit: Oops, noticed Kpex already mentioned IVTC.

Sujao
8th March 2005, 04:56
Hi six6,

thx for your feedback.

What exactly is the use of framerate converseion? I only know IVTC where you actually drop some frames cause they are identical. I wasnt able to use this filter in mplayer yet so I didnt implement it. I am working on it at the moment.

I dont use scaling but only croping cause I want to keep the most possible resolution of the movie.

What exactly does calcbpp.pl do?

BTW: I made more conversions and the size of the resulting file is now always about 2.1GB as it should be. At the moment I am converting the one movie that always became to big in order to find out if this problem is fixed now. I will release a new version soon. There are some new features like "keeping original ac3 track" and "variable target size" and "dvd cach" now really works :) .

six6
10th March 2005, 21:17
@Sujao

By framerate conversion, I meant IVTC. It won't save that many bits, but it's still useful for those of us using NTSC :)

calcbpp.pl was written by Mosu and calculates bits per pixel. Other than bitrate, no other setting affects quality more.

Check out his original statement (http://web.njit.edu/all_topics/Prog_Lang_Docs/html/mplayer/tech/encoding-tips.txt) if you're interested.

Of course, bpp is just a guide, and one step better would be a compression test like Gordian Knot et al does. For that you can use countquant.pl.

Sujao
6th April 2005, 12:22
New version available. See changelog for changes.