Log in

View Full Version : Mkv H264 to Mpeg2


atzplzw
15th June 2008, 10:56
Hi!

I want to convert a MKV Mpeg4/H264 movie trailer to Mpeg2 with ffmpeg, so that it plays with the same good quality on my Philips LCD which sadly isn't able to handle Mpeg4. The LCD is connected to the network and is able to play Mpeg2 through Twonky Media Server. Mainly this is for fun and testing only.

So I guessed that ffmpeg would be the best solution as it understands all the formats I need. I got the compiled version from from http://arrozcru.no-ip.org/ffmpeg_builds/

FFmpeg version SVN-r13712, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-memalign-hack --enable-avisynth --enable-libxvid --ena
ble-libx264 --enable-libgsm --enable-libfaac --enable-libfaad --enable-liba52 --
enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-pthreads --enab
le-swscale --enable-gpl
libavutil version: 49.7.0
libavcodec version: 51.57.2
libavformat version: 52.14.0
libavdevice version: 52.0.0
built on Jun 8 2008 21:33:14, gcc: 4.2.3



First I want the video to work smoothly before I'm going to convert the audio.
So I got some info on the movie:

ffmpeg.exe -i movie.mkv
Input #0, matroska, from 'movie.mkv':
Duration: 00:02:26.56, start: 0.000000, bitrate: N/A
Stream #0.0: Audio: liba52, 48000 Hz, 5:1
Stream #0.1(eng): Video: h264, yuv420p, 1280x544 [PAR 1:1 DAR 40:17], 23.98
tb(r)



So I guessed because I wanted the same quality this would work:

ffmpeg.exe -i movie.mkv -vcodec mpeg2video -an -sameq movie.mpg

While the video was ok sadly timestamps where completely wrong and no forward or rewind was possible!
If I don't use -sameq then the video is broken and unwatchable.


Any hints how to achieve a correct Mpeg2 conversion?

Thanks!

45tripp
16th June 2008, 01:56
possibly start with this

ffmpeg.exe -i movie.mkv -vcodec mpeg2video -an -sameq -f vob movie.mpg

also if you're looking at anything without a constant framerate, you're using the wrong tool.

atzplzw
16th June 2008, 16:39
Aha! Thanks for your hint!

So how can I find out if there is a constant framerate?

The bitrate is not displayed as you can see in the first post.


Which program, preferably with a cmdline interface and compileable for windows & linux, do you suggest?

45tripp
16th June 2008, 18:36
well you can read up on vfr here:
http://avisynth.org/mediawiki/VFR

you'll know, it's when things turn ugly.
basically you'll lose sync.

there's a mkv2vfr commandline tool to give timecodes,
from the haali package, for windows.

for general info on media files,
you can use mediainfo, cli available for win and linux

suggested tool, mencoder,
available for win and linux.

it should work ok by duplicating or decimating frames to keep sync.
can be handy if you want to keep sanity levels.

in it's basic form:
mencoder vfr.mkv -ovc lavc -oac lavc -lavcopts
vcodec=mpeg2video:vqscale=4 -ofps 30000/1001 -of mpeg -o omo.mpg

atzplzw
19th June 2008, 17:44
After days of searching I found the problem: The LCD doesn't play any mpg file without audio! How stupid is that! Don't buy any Philips products!

So the video encoding with ffmpeg is fine if I use audio also. Sadly I get some buffer underruns with the "-f vob" switch. Avi isn't the correct container for mpeg2video.
Any other suggestions on a container?