Simple Howto for re-encoding (bluray) MKV's (linux)

MKV playback, recompression, remuxing, codec packs, players, howtos, etc.
crowfax
Posts: 972
Joined: Thu Feb 18, 2010 5:55 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by crowfax »

You'll notice I said "last supported version" and not "latest version". Currently watching the development on the nightly PPA from here:

Code: Select all

## handbrake snapshots - Maintainer: John Stebbins
deb http://ppa.launchpad.net/stebbins/handbrake-snapshots/ubuntu lucid main
deb-src http://ppa.launchpad.net/stebbins/handbrake-snapshots/ubuntu lucid main
Most of the changes appear to be GUI-centric, I can't speak as to how up-to-date the x264 encoder is, but building it yourself will always give you a newer revision! :D
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
ridewithstyle
Posts: 9
Joined: Wed Jan 20, 2010 8:22 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by ridewithstyle »

yep, I did. Should've been clearer though ;-)

I'm using the stebbins ppa as well, seem like I somehow googled too sloppy. Thanks for pointing that out
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

handbrake is ok, but i prefer to have latest x264 and really the CLI is not that hard to use anymore!
aravenel
Posts: 14
Joined: Sat Jul 03, 2010 4:44 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by aravenel »

I'm getting the following error when trying to compile ffmpeg. Any ideas?

Code: Select all

/home/ravenel/source/ffmpeg/libavformat/libavformat.a(id3v2.o): In function `read_ttag':
/home/ravenel/source/ffmpeg/libavformat/id3v2.c:142: undefined reference to `ff_id3v1_genre_str'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

Hi, I am able to reproduce the error, which is probably a bug in ffmpeg. in the mean time, checkout a previous version of ffmpeg!
revision from 2010-06-01 works for me

Code: Select all

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk --revision {2010-06-01} ffmpeg
Of course your welcome to try newer revision until it breaks :p
aravenel
Posts: 14
Joined: Sat Jul 03, 2010 4:44 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by aravenel »

That did it! Thanks for the help... Don't know why I didn't think to try an older version, I feel a bit silly now.

FYI, looks like there is a bug listed by ffmpeg for just this error: https://roundup.ffmpeg.org/issue2042

Hopefully they'll fix it soon!
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

talking with ffmpeg dev's, its likely because of so much disabled stuff. So try to fix it, i disable everything by default and enable only what we want!
please try the new command line in the first post!
aravenel
Posts: 14
Joined: Sat Jul 03, 2010 4:44 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by aravenel »

The updated ./configure seems to work for me. FYI, you have a typo in it though--it says "--enable-ecoder", when it should be "--enable-encoder".

Thanks for the quick response!

A couple of quick questions:
  • If we're only calling x264 in the encode (not resizing or piping), does ffmpeg still need to be installed? Just trying to figure out how all this works.
  • I've seen other guides where folks called ffmpeg or mencoder to do a similar encode. What's the difference between doing that and using x264 like this?
  • Where does x264 generate it's log file? The first file I tried this one seems to have quit about 2/3 through the film, but there was no useful error on the terminal--it just said "Killedframes", listed the number of encoded frames, and then dumped back to console.
Here's the output from x264:

Code: Select all

ravenel@Galadriel:/myth/video/MakeMKV/Quantum of Solace$ x264 title01.mkv --preset slow --crf 20 --tune film --level 41 --output Quantum\ of\ Solace-x264.mkv
[matroska @ 0x1c82420]Estimating duration from bitrate, this may be inaccurate
lavf [info]: 1920x1080p 1:1 @ 24000/1001 fps (vfr)
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT
x264 [info]: profile High, level 4.1
Killedframes: 3.68 fps, 12379.96 kb/s  
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

To be more clear, we are compiling x264 with ffmpegsource2, which depends on ffmpeg. x264 by its self can only read raw files. ffms2 provides frame accurate input for x264. So we only want to compile ffmpeg for decoding video tracks, and disable everything else. If you want to pipe from mplayer to x264, then you can skip the whole ffmpeg process :)
http://code.google.com/p/ffmpegsource/

and actually it should be --enable-decoder
thanks for finding the typo!

edit3: the new command line:

Code: Select all

./configure --disable-everything --enable-gpl --enable-postproc --enable-protocols --enable-demuxer=matroska,ogg,avi,h264,mov,m4v,mpegts,mpegvideo --enable-decoder=h264,vc1,wmv*,mpeg2video,mpeg1video,mpeg4,theora,vp8 --enable-parser=h264,mpeg4video,mpegvideo,vc1,vp8
now works.

The culprit was --enable-protocols, sorry for all the trouble!
aravenel
Posts: 14
Joined: Sat Jul 03, 2010 4:44 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by aravenel »

Thanks, I'll give that a shot.

Is there a logfile created anywhere that I can look at to get more info as to why this might be failing 2/3 through? Any idea why x264 could be having so much trouble with the MakeMKV generated file?
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

x264 does not log by default.

Code: Select all

--log-level <string>    Specify the maximum level of logging ["info"]
                                  - none, error, warning, info, debug
then redirect console output to a file. i think though, that it is likely because of previous broken x264 build with the previous bad command line!

if it still doesnt work after update please use x264 --version and x264 --fullhelp to make sure that:
a)x264 was compiled by you
b)compiled correctly with ffms2 support
aravenel
Posts: 14
Joined: Sat Jul 03, 2010 4:44 pm

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by aravenel »

Knock on wood, but I *think* it worked--at the least, it made it all the way through without failing, and there's no obvious distortion/artifacts--far better than the last time around!

So my next question is this--we compiled ffmpeg with almost everything disabled. Why not just enable everything? What if I were to recompile with everything enabled? Would it still work? I ask because I'm concerned that in the future, some other application will require a part of ffmpeg that we disabled. I haven't noticed anything failing right now, but I'm just trying to figure out how all of this works.

Thanks again, this is a fantastically helpful guide!
skittle
Posts: 349
Joined: Thu Jan 14, 2010 4:23 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by skittle »

You can safely delete/over write the ffmpeg binaries with a full ffmpeg install in the future if you want. ffms2 and x264 do not need ffmpeg binaries once they are compiled.

as for turning options off, its for two reasons:
WAY smaller/faster binary, and we absolutely do not want ffms2 to be compiled with audio. plus the other options reccommneded here: http://ffmpegsource.googlecode.com/svn/ ... 2-api.html
In the past most people explicetely turn off a lot of options (this leads to a huge unreadable command line) but this recently broke with ffmpeg. I think its easier and more readable to disable everything, and explicetely enable only the stuff you want!

ps: i thought that the bad ffmpeg config might be the issue, im surpised it compiled at all for you :|
pss: If your encoding from bluray, please please use --colormatrix bt709
ccc38941
Posts: 4
Joined: Mon Aug 23, 2010 8:55 am

Re: Simple Howto for re-encoding (bluray) MKV's (linux)

Post by ccc38941 »

Can you post files need and the file to run?
Post Reply