User avatar
rpdom
Posts: 15587
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Convert Mpeg2 to Mpeg4/h.264 [SOLVED]

Tue Jun 25, 2013 5:38 am

I have a number of files in mpeg2 format that I would like to convert to mpeg4/h.264 format. (I have the MPEG2 licence, but I would like to save space if I can).

I remember that some people were looking at writing a program to do this using the hardware decoders/encoders on the Pi, and wonder if anyone has got a working program that I can just run from the command line with input/output file names as arguments?

Ideally it would autodetect the framerate, size and aspect ratio of the original file and handle at least stereo audio too. Speed is not critical - it doesn't have to be real-time on anything like that. I'd rather have a Pi sitting quietly doing the job for a few hours per file, than a noisy, power-hungry PC doing it in half the time. :)
Last edited by rpdom on Tue Jun 25, 2013 3:52 pm, edited 2 times in total.

geekinthesticks
Posts: 97
Joined: Fri Feb 08, 2013 7:22 pm

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 6:12 am

There are a number of options:

HandbrakeCLI - uses ffmpeg internally. Easy to use with a useful range of presets.

ffmpeg - ultimate flexibility. Expect to waste the rest of your life figuring out the constantly changing command line syntax and range of options. Produces very good results.

mencoder - probably less flexible than ffmpeg, but still works fine for most things.

Edit: Handbrake doesn't seem to be available on the Pi. Not sure if you can compile it yourself.

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 6:48 am

omxtx is what you want. It is usable , but still rough at the
edges.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
rpdom
Posts: 15587
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 10:44 am

ghans wrote:omxtx is what you want. It is usable , but still rough at the
edges.
Thank you ghans, that was exactly what I was looking for. I didn't realise it was fully functional yet.
I grabbed the source, compiled it without any problems and converted a file to test it.

A 45 minute video took 26 minutes to convert :)

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 11:53 am

geekinthesticks wrote:There are a number of options:

HandbrakeCLI - uses ffmpeg internally. Easy to use with a useful range of presets.

ffmpeg - ultimate flexibility. Expect to waste the rest of your life figuring out the constantly changing command line syntax and range of options. Produces very good results.

mencoder - probably less flexible than ffmpeg, but still works fine for most things.

Edit: Handbrake doesn't seem to be available on the Pi. Not sure if you can compile it yourself.
Yes you can build and run HandbrakeCLI, but its very slow. There's a config option to disable the assembly instruction stuff in Handbrake. Can;t remember where / what it is, but google should find it.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 12:09 pm

As far as I'm aware there isn't a video encoder that makes use of hardware accelerated h.264 encoding so if anything you'll be in for a long wait, however if you insist on using the Pi then you can install ffmpeg via apt-get.
Personally I would just download a copy of WinFF (ffmpeg front-end) on your PC and let it convert all your videos in one run over night.

Richard S.

User avatar
rpdom
Posts: 15587
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 12:41 pm

redhawk wrote:As far as I'm aware there isn't a video encoder that makes use of hardware accelerated h.264 encoding so if anything you'll be in for a long wait, however if you insist on using the Pi then you can install ffmpeg via apt-get.
Personally I would just download a copy of WinFF (ffmpeg front-end) on your PC and let it convert all your videos in one run over night.
WinFF? Is that for Windows? If so, it's totally useless, as I have no windows PC.

omxtx does the job very nicely on the Pi with its hardware decode and encode it is converting the file in about a quarter of the time ffmpeg takes on an Athlon XP3200+ with 1.5GB RAM, uses a fraction of the power and makes no noise :-)

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Convert Mpeg2 to Mpeg4/h.264

Tue Jun 25, 2013 12:56 pm

WinFF is multi-platform so it runs on Windows and various different Linux distros but not Macintosh as far as I can tell - http://winff.org/

Richard S.

Return to “Media centres”