[FFmpeg-devel] Could this be a SOC project? mkv to mp4 ps3 tweaks
Thu Mar 19 16:52:55 CET 2009
I just joined this list to ask questions about how to do the following
work on ffmpeg but I stumbled on the thread about GSOC projects.
Here is the description of what I want to do but perhaps this is a good
candidate for SOC?
On a thread on ffmpeg-users, I've been discussing using ffmpeg to remux
mkv files to mp4 for playback on the PS3.
This should be trivial because typically the mkv already contains an
h264 video stream which is playable on the PS3 so no transcoding is
needed. Audio on the other hand typically needs to be transcoded to AAC
since it's usually dts or sometimes ac3.
However, there are a number small problems with this that actually make
it quite difficult.
1) For some reason ffmpeg will not remux mkv to mp4 in one step. For
# ffmpeg -i input.mkv -vcodec copy -acodec libfaac -y output.mp4
Should work but it fails:
[NULL @ 0x66bff0]error, non monotone timestamps 267 >= 233
av_interleaved_write_frame(): Error while opening file
However, if you first demux the file with mkvextract into a video and
audio track, it works:
# mkvextract tracks input.mkv 1:input.video 2:input.audio
# ffmpeg -i input.video -i input.audio -vcodec copy -acodec libfaac output.mp4
2) Unfortunately the resulting file often will still not play on the PS3
because for some reason almost all mkv files have their h264 video set
to level 5.1 even though they contain nothing that requires this high
setting. In my testing I've found that in many cases a simple hex edit
of the source h264 stream to change it to 4.1 fixes this problem and it
then plays just fine.
Unfortunately there is no way to change the level with ffmpeg unless you
transcode the entire h264 stream. So instead of taking a few seconds or
minutes it can take days.
I'm thinking the solution might be to allow "-vcodec copy" to still
accept options which don't require transcoding. So for example:
# ffmpeg -i input.mkv -vcodec copy -level 41 output.mp4
Alternatively, if libx264 is handed a h264 stream but isn't passed any
options that require transcoding, it should not transcode but instead
just do a raw copy. e.g.:
# ffmpeg -i input.mkv -vcodec libx264 -level 41 output.mp4
That's how close ffmpeg is to being able to repackage mkv video to mp4
for the ps3. Just a few tweaks...
By the way; when you use ffmpeg for transcoding for the PS3 it seems to
work great. I've had good results so far with the following:
# ffmpeg -i $srcfile -vcodec libx264 -vpre hq -crf 18 -acodec libfaac -y $dstfile
So thank you ffmpeg developers for that! I see that the hq preset does
not have a "level" set so libx264 must default to 4.1?
More information about the ffmpeg-devel