Best way to recode video and/or audio in ripped MKV from dvd

MKV playback, recompression, remuxing, codec packs, players, howtos, etc.
Post Reply
mnt_schred
Posts: 5
Joined: Fri May 07, 2010 9:20 pm

Best way to recode video and/or audio in ripped MKV from dvd

Post by mnt_schred »

I have made .mkv's of a few DVD's, but I don't want to keep them in the shitty mpeg2 codec. Is there a (preferable linux command line based) easy way to (batch) recode them?
crowfax
Posts: 972
Joined: Thu Feb 18, 2010 5:55 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by crowfax »

Hi!

Skittle did an AWESOME guide on re-encoding from the command line (works for both dvd and bluray):
http://www.makemkv.com/forum2/viewtopic.php?f=6&t=1313

Read the whole thing before you start, you need to check out a specific date from the ffmpeg svn which isn't covered in his first post but is covered about half way down.

As for batching... I'd just join them commands together with && so when it finishes the first it'll move to the next.
Home Theater PC: Assassin HTPC, XBMCbuntu 12.0 (Frodo), Intel i5 3570k 3.4 GHz Ivy Bridge w/ HD 4000, LG BD-ROM
Playback Devices: Mede8er MED600X3D, MyGica EnjoyTV 120, Xtreamer SideWinder 3, Crystal Acoustics MediaMatchBox
mnt_schred
Posts: 5
Joined: Fri May 07, 2010 9:20 pm

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by mnt_schred »

That's kinda awesome indeed- To only recode the command

x264 <input>.mkv --preset slow --crf 18 --tune film --colormatrix bt709 --output <output>.mkv

should be enough?
and the mpeg2 stream is recoded into H.264?

I'll try that.. and report.
crowfax
Posts: 972
Joined: Thu Feb 18, 2010 5:55 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by crowfax »

It'll recode ONLY the video from the source MKV.

Once the new "video only" file is made, you use MKVmergeGUI to merge the two together - unselecting the MPEG2 stream (so it doesn't appear in the new MKV file that is made) but keeping the audio/chapters/subtitles from the source MKV.

Here's the code you need to run (I'm assuming you're using something apt based with sudo) just to get the tools in place:
(taken from skittle's thread and altered the svn command for ffmpeg & some minor alterations)

Code: Select all

## get some stuff from the repo's
sudo apt-get install yasm libgpac-dev subversion git

## create source directory
cd ~
mkdir source

## get and install ffmpeg from April 21st
cd ~/source
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk --revision {2010-04-21} ffmpeg
cd ffmpeg
./configure --enable-pthreads --enable-gpl --enable-postproc --enable-memalign-hack --enable-runtime-cpudetect --disable-devices --disable-filters --disable-encoders --disable-muxers --disable-network --disable-outdevs --disable-decoder=aac,ac3,adpcm_*,alac,als,ape,atrac?,cook,dca,dsicinaudio,dxa,eac3,flac,interplay_dpcm,mlp,mp1,mp2,mp3,mp3*,mpc?,pcm_*,qcelp,ra_*,sipr,truehd,truespeech,tta,vorbis,wavpack,wma*,twinvq --disable-demuxer=aac,ac3,pcm_*,ape,amr,ass,au,avs,dts,eac3,flac,mp3,mpc,mpc8,truehd,tta,w64,wav,wv --disable-parser=aac,ac3,dca,mlp,mpegaudio
make
sudo make install

#get and compile ffms2
cd ~/source/
svn checkout http://ffmpegsource.googlecode.com/svn/trunk/ ffms2
cd ffms2
./configure
make
sudo make install

#get and compile x264 with ffms2 input
cd ~/source/
git clone git://git.videolan.org/x264.git x264
cd x264
./configure
make
sudo make install
Home Theater PC: Assassin HTPC, XBMCbuntu 12.0 (Frodo), Intel i5 3570k 3.4 GHz Ivy Bridge w/ HD 4000, LG BD-ROM
Playback Devices: Mede8er MED600X3D, MyGica EnjoyTV 120, Xtreamer SideWinder 3, Crystal Acoustics MediaMatchBox
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by skittle »

--colormatrix bt709 is ONLY for bluray/HD content, for standard def (dvd) use --colormatrix bt470bg.

Also note that using x264 directly on the source file does not allow for filtering, so if it is telecined or interlaced you need to pipe through and filter with mplayer/avisynth/ffmpeg.

read "man ffmpeg/mplayer" and "x264 --fullhelp" for more information on encoding parameters.

also ffmpegsource was updated so its no longer needed to check out older revision of ffmpeg to build ffmpegsource.
crowfax
Posts: 972
Joined: Thu Feb 18, 2010 5:55 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by crowfax »

Do I just run the svn and compile commands again and it'll overwrite the old binaries, or is there something I have to do first to remove the old ones?
Home Theater PC: Assassin HTPC, XBMCbuntu 12.0 (Frodo), Intel i5 3570k 3.4 GHz Ivy Bridge w/ HD 4000, LG BD-ROM
Playback Devices: Mede8er MED600X3D, MyGica EnjoyTV 120, Xtreamer SideWinder 3, Crystal Acoustics MediaMatchBox
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by skittle »

i like to clear out the source folder or new subfolder for different revisions, but when you "make install" it will overwrite the old binaries.
ffms2 change log here:
http://code.google.com/p/ffmpegsource/source/list

And of course you can always just update x264 without updating ffmpeg or ffms2, as those are less likely to gain new features.
mnt_schred
Posts: 5
Joined: Fri May 07, 2010 9:20 pm

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by mnt_schred »

Thanks, but I already had the x264 command on my machine.

I'm only looking for the command which:
  • extracts the video stream
  • recode's it
  • merges it back again
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by skittle »

if x264 is compiled with ffms2/lavf input you do not need to extract the video stream at all.
The basic syntax is this:

Code: Select all

x264 <input> <options> --output <output>
read x264 --fullhelp for detailed x264 options.

Use mkvmerge to merge streams together.
mnt_schred
Posts: 5
Joined: Fri May 07, 2010 9:20 pm

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by mnt_schred »

Ah, I'm beginning to understand. I can use x264 to extract the video file and recode it, then use mkvmerge to remerge it?

for example:

x264 input.mkv output.mkv && mkvmerge input.mkv output.mkv (more or less off course)
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by skittle »

Hi, basically yes.

Please read the mkvmrege and x264 help/man/docs for more information though.

for mkvermge its more like
mkvmerge x264output.mkv source.mkv -o muxed.mkv

again, read the help files!

edit: mkvmerge also has a nice gui if you want to use that
mnt_schred
Posts: 5
Joined: Fri May 07, 2010 9:20 pm

Re: Best way to recode video and/or audio in ripped MKV from dvd

Post by mnt_schred »

No, I rip them on my Win7 machine and upload them to my Suse machine to process them further.
Yes, I know I should read the docs, but I'm very lazy ;) But will do. Thanks!
topfer
Posts: 1
Joined: Tue Jul 27, 2010 6:08 am

Re: Best way to recode video and/or audio in ripped MKV from

Post by topfer »

crowfax wrote:Do I just run the svn and compile commands again and it'll overwrite the old binaries, or is there something I have to do first to remove the old ones?
I completely agree with you.You have done an great job.. Such an informative and well formed post !
Thanks for sharing that, it was wonderful of you.
Good luck!
Post Reply