You are not logged in.

#1 2007-08-02 10:15:12

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

1080p-and-720p-h264-mkv to 720p-mpeg2

does anyone use or know a command for ffmpeg or mencoder for convert a 1080p or 720p mkv file to 720p mpeg2? cause in linux i havent coreavc and cant decode 720p h264, i want to convert to mpeg for watch them

tnx!


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#2 2007-08-02 12:42:52

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: 1080p-and-720p-h264-mkv to 720p-mpeg2

Why do you need CoreAVC to decode these films? MPlayer, FFPlay, and VLC, should do it just fine providing your computer is powerful enough.

Last edited by skottish (2007-08-02 12:43:12)

Offline

#3 2007-08-02 14:15:27

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: 1080p-and-720p-h264-mkv to 720p-mpeg2

in (argh tongue) windows with coreavc my computer can decode 720p h264 very well, but without it, vlc mplayer and xine cant achieve that level of decoding speed and i have stuttering and audio synch issues, so i need to transcode them so my computer can decode and play them


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#4 2007-08-03 00:50:27

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: 1080p-and-720p-h264-mkv to 720p-mpeg2

The simplest way to do it is something like this:

ffmpeg -i <your input video> -b 5000k -vcodec mpeg2video -acodec copy <new output>.mpg

Depending on the bitrate of your input video, this may create a much larger file than the original. The '-b 5000k' flag will make a MPEG2 video about half the maximum bitrate allowable for DVD. This will simply copy the audio. It will also keep the video size as well as the frame rate. Fortunately, you're using progressive scan, so interlacing won't double your frames.

This is a good place to start, but transcoding from H264 to MPEG2 is going to lower the quality of the video a lot. As an alternative, you can try using x264 to lower the bitrate. Support is compiled into the current Arch release of FFMPEG, and FFMPEG should generate ISO compliant MPEG4 files (hopefully the version in the repos in new enough for that). Writing Matroska files right now isn't implemented, but you can use MKVToolnix to do that.

Anyway, get the bitrate from your original:

ffmpeg -i <input video>

Under the 'Duration' line, you'll see the total bitrate for video and audio.  You can simply guess on the audio. If it's AC3, it's probably 448kb/s. Subtract that out, and what's left is the video.

So, say the bitrate is 5000kb/s. Try knocking it down to 3000k and see if that produced useful results:

ffmpeg -i <input video> -b 3000k -vcodec h264 -acodec copy -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me hex -subq 5 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 <output video>.mp4

A bunch of that stuff is x264 flags that I don't understand real well, but it produces very good results.

You can also cut a bunch off of the sound. FAAC is a great choice for that, and it will produce ISO compliant MP4 files:

ffmpeg -i <input video> -b 3000k -vcodec h264 -ab 256k -ar 44100 -acodec mpeg4aac -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me hex -subq 5 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 <output video>.mp4

In this case, the audio bitrate will drop to 256kb/s (FAAC will report 128kb/s, but that's per channel). It will also lower the audio frequency to 44100KHz. Note: the version of FFMPEG in the repos may still just use 'aac' as the audio codec, and not 'mpeg4aac'.

Last edited by skottish (2007-08-03 00:51:03)

Offline

#5 2007-08-03 01:34:23

FeatherMonkey
Member
Registered: 2007-02-26
Posts: 313

Re: 1080p-and-720p-h264-mkv to 720p-mpeg2

I posted this little script seems what your after. h264enc http://aur.archlinux.org/packages.php?d … hans=&SeB=

Perhaps it'll help does more than I need. As for mpeg2 avidemux does it something like

avidemux2_cli --load Test.file --output-format ES --video-codec XDVD --video-conf 2pass=1000 --save mpeg2.mpg --quit

Offline

#6 2007-08-03 13:30:40

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: 1080p-and-720p-h264-mkv to 720p-mpeg2

thank you all for the answers!

tnx!


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

Board footer

Powered by FluxBB