How To Use FFMPEG To Transcode Video For The PS3

10 10 2009

So, it seems my last post actually wasn’t the best solution. Although using Mediatomb and VLC worked some of the time, often I found that the audio and video was out of sync, making it impossible to watch the movie.

ffmpeg-logo

So, I looked for another alternative. I already use HandBrakeCLI to transcode my videos, but that is essentially a front end to ffmpeg and x264. They are moving away from providing decent support for transcoding videos on the Playstation 3, so I decided to use ffmpeg directly. I used this guide to install the latest svn versions of ffmpeg and x264 on my Ubuntu 8.04 server. I then spent about two weeks trying to find an up-to-date command to actually use ffmpeg to create a PS3 compatible file. It seems most of the instructions on the web are way out of date and use commands that ffmpeg no longer accepts. Finally, after lots of trying I finally asked on the IRC channel #ffmpeg. This very nice dude called relaxed suggested the following:

ffmpeg -t 120 -i $input -vcodec libx264 -level 41 -vpre hq -crf 24 -threads 0 -acodec libfaac -ab 128k -ac 2 output.mp4

Sadly I had problems with this code, since the .mpg files I was using (I am now using MythTV instead of MediaPortal, but that’s another post) were not accepted by the libfaac codec.

However, with a little modification, I got the perfect command. So, without further ado, the best command I have found to convert ANY video accepted by ffmpeg into a PS3 compatible file using x264 that is good quality and low file size is:

ffmpeg -y -i "$1" -vcodec libx264 -level 41 -vpre normal -crf 24 -threads 0 -acodec libfaac -ab 128k -ac 2 -ar 48000 "$1".mp4

Obviously change $1 into your input file and “$1”.mp4 into your output file. If you want to send the command line output to a log file so you can see what is going in, use:

ffmpeg -y -i "$1" -vcodec libx264 -level 41 -vpre normal -crf 24 -threads 0 -acodec libfaac -ab 128k -ac 2 -ar 48000 "$1".mp4 > /where/you/store/your/logs/ffmpegprog.log 2>&1

Now, when I first saw this I thought, hey, its got hardly any switches (all the -XYZ stuff), therefore it must be cack.  However, the key is the “-vpre normal” switch.  This tells ffmpeg to use some of its built-in presets, or in this case built-in x264 presets that are created when you build x264 from SVN. I was initially told, as you can see from above, to use the “hq” preset, but I found this resulted in files that were quite big. Using the “normal” preset seemed to produce files that were of great quality compared to my original source (SD DVB-T transport streams in MPG format) but much smaller files size, for example, a .mpg transport stream movie that is originally 2.5GBs in size gets reduced to around 650 MBs, awesome.

X264_Logo

So, this is the command I now use to convert all my videos. I also use comskip run via Wine to check for commercials and mp4box to mux in the chapter markers from comskip. Weirdly, I do find that when playing these resultant files via VLC they appear to have their audio and video out of sync, but on the PS3 they are fine. Whether this is due to me using an old VLC or my PC being too slow to play em, I don’t know, but hey, if it works.

So, if you are looking for the best ffmpeg command to transcode video files for the PS3 using ffmpeg and x264, I am pretty sure this is it.

As an aside, I also built HandBrakeCLI from SVN and it now also has a basic preset, called Normal, that also produces PS3 compatible files. I will play with them to see how they do, though I find that occasionally HandBrake can crash, and get stuck, so I try to avoid it. Sadly though, the HandBrake dev’s wont help you with this, since you are using the HandBrakeCLI and it is not the CLI that is crashing so they wont look into it for you. In fact (<rant>) I am really shocked at the rudeness and arrogance that the HandBrake devs demonstrate on their forum. I have read so many well worded and polite posts from confused people on their forums, where the devs (mainly a guy called jbrake) just answers back incredibly sarcastically and very rudely, providing little to no help. Maybe they get loads of annoying whiny posts from people who haven’t RTFM, but still, there is no need to be rude about it. In fact, that is the main reason I don’t want to use HandBrake, since I don’t like the attitude those guys have (</rant>).

Anyway, hope this awesome command for a recent SVN ffmpeg and x264 version to convert video files for PS3 works for you!

Advertisements

Actions

Information

11 responses

14 12 2009
Dustin

Hi! I recently got a PS3 (in the States) and have had a near impossible time finding a way to rip DVD's into a PS3-compatible format. It plays most VOB files that I've created just fine, but I'm looking for a file that would work on other media devices as well (iPhone mostly). I've also found that forwarding and rewinding VOB files on the PS3 is like force-feeding a frog. I've been able to create small clips in various formats that play OK on the PS3, but the quality is seriously lacking.

My question to you is, as a total newbie in this realm, can you translate your preset into what I would choose from the GUI ffmpeg interface? Or can you offer a quick solution as to how I would import your preset?

From an incredibly frustrated user, many thanks!

– Dustin

15 12 2009
prupert

Hi

In the end, I gave up trying to get files working for my PS3, it was soooo picky about what it wanted, and since I didn't wanna store them all on the PS3, but use a UPnP server instead, that added even more stress to the situation. So, instead I decided to buy a separate computer, install XBMC (http://www.xbmc.org) on it and that has been the perfect solution ever since. However, this doesn't help you.

There are two solutions I can offer, one is free, but not so easy, the other costs, but is very easy.

The Free Option:
Use Handbrake: http://handbrake.fr/ It has versions for most OS out there, you can rip a DVD using the program (though you need to sort out copy protection before hand), or it can covert files you give it. If you just choose the 'normal' preset and choose an MP4 container, it should create a PS3 compatable file. However, the handbrake devs don't seem that keen on the PS3 and don't officially support it, so I don't know how long this will work. Also, the options in handbrake are pretty confusing for the beginner.

The Non-Free Option:
Use DVDFab 'DVD to Mobile' (http://www.dvdfab.com/dvd-to-mobile.htm) This is about $30, but they are running a 20% discount till 20th December. Using this program is so easy, simply bung in your DVD, choose the PS3 option, select the Title you wanna copy and off you go. It does everything for you, creates decent sized files and most importantly, they work on your PS3. Its the option I use to rip my DVDs since it is so easy. Note, you have to buy the DVDFab DVD to Mobile, since just DVDFab on its own wont create a PS3 compatable file.

If you can work out how to use Handbrake (and it aint that difficult, reading the FAQs and Docs helps) it is a great solution. But if you are lazy and want to use something that you know will always work, use DVDFab DVD to Mobile.

Hope that helps you out.

If you did still want to use my command, I am not sure how to use the GUI for ffmpeg and you might make the wrong selection, so the easiest thing to do is, once you have installed ffmpeg in windows (since I am assuming you are using Windows) open a command prompt (Start>Accessories>Command Prompt) and then type the following:

ffmpeg -y -i "C:/full/path/to your file/here.mpg" -vcodec libx264 -level 41 -vpre normal -crf 24 -threads 0 -acodec libfaac -ab 128k -ac 2 -ar 48000 "C:/full/path/to where you want/the new file/to go.mp4"

So, after the -i part, you write the full path to your input file, so for example "C:/pruperting/My Videos/video.mpg" and then after the -ar 48000 you write the full path to where you want the output file to go, so something like "C:/pruperting/For My PS3/video.mp4" (you must keep it as .mp4 here).

15 12 2009
Dustin Moskowitz

Prupert,

Thanks so much for the advice. Truth told, I'm a Mac user, but as such keep Windows in a boot camp partition for just such occasions. And I'm using a UPnP NAS device to serve up the files as well.

I've used Handbrake for years and playback on a Mac or PC is fool proof, or even feeding through to a TV hasn't been an issue at all. But trying to create an acceptable file for the PS3 is downright painful… as you said, the developers don't seem concerned about it, even though their newest version is supposed to have a preset that "just works". Only it *never* does, for me at least.

I'll check out the DVDFab info, and thanks for the discount tip. Last night I tried one of ffmpegX's basic MP4 presets, and it created a file that the PS3 accepted, but it was rather pixel-y on my 46" TV. I then ran through the same movie and selected Hi Quality in the encoding, changing NOTHING else, and the PS3 laughed at me, like how dare I try to stream THAT kind of file to it. That's what blows my mind about this as a media server – it's consistently inconsistent in what files it will play.

I'll try running FF in Windows and try out your code. Cut and paste is easy enough for this Mac head!

Thanks again, and I'll let you know how it works out.

15 12 2009
Dustin Moskowitz

Hi, me again. One quick question – how good does the DVD-to-Mobile file look when played back on a good-sized TV? Is it very pixellated?

Thanks!

15 12 2009
prupert

Sadly I am stuck with a horrible old CRT TV, so it only goes up to a maximum of about 570×480 or something naff. So it looks fine on my TV, and also on my 19" LCD PC screen, but I couldn't say what it is like in 1080p, ask me next Xmas, by which time I should have "accidently" dropped the TV requiring me to buy a decent one 😉

I would imagine the quality is pretty good, the file sizes are larger than the ones my ffmpeg command makes, since it seems to be using a higher quality setting.

Personally, I think the major issue is in the UPnP implementation in PS3, it seems to be very picky and I think that is where I was getting lots of trouble. I was using both mediatomb and PS3MediaServer, but gave up on both as they were really killing my PC and the audio kept on going out of sync. I am sure it is possible to get it working, but I just got so p!ssed off with trying to, I gave up and resorted to XBMC.

If I was you, I would try the files directly on the PS3 first and once you have a solution that works well, then see what it is like streaming it via UPnP. When playing these files, the bitrate can hit up to 3 MB/sec it seems on some movies, and considering I can never get files to transfer faster than about 1 MB/sec over my network, I would imagine that causes a lot of pixelation and lag when it comes to UPnP.

15 12 2009
Dustin

You know, that's the one thing I know I have to try but haven't yet… just dumping the files on the PS3 drive instead of trying to stream everything. Of course, that's the final point in all of this – instant access from the NAS. But I have heard that between the NAS, router, switch, etc., something can turn a perfectly acceptable file into something that simply won't work.

Either way, I'll keep you posted – if nothing else, maybe someone else as frustrated as I am digging through the web to find an answer will be able to find one in this little thread, so I appreciate your input.

Hope Santa has a nice big box for you!

15 12 2009
prupert

Best of luck, it's a toughie to be sure, but I hope you get it and let me know your results 😉

15 12 2009
Dustin

Thanks! Fortunately we wired the main rooms last year, so conceivably I can hit gigabit transfers. But I still think the PS3 would rather just not play a file, so Sony can sell it to me digitally!

31 12 2011
Albert

I tried serveral options with ffmpeg – your suggestion works great – thanks a lot

Greets, Albert

6 08 2012
daxrush

Hi
Very nice post, however on my distro (arch) the “-vpre normal” is not accepted, this because the preset file is missing, can you post your preset files?
The location of this files is described here:
http://ffmpeg.org/ffmpeg.html | ch 5.14
Thanks!

6 08 2012
prupert

@Daxrush Unfortunately I haven’t had time to use ffmpeg for an age what with kids and stuff!

The preset / code I used most recently was:
-vpre libx264-lossless_fast
using x264. However, having just compiled FFmpeg from source and checking, this no longer works, but it seems this does:
-preset fast -qp 0

This is the command I use most often when I do have the time:
ffmpeg -deinterlace -y -i “INPUTFILE” -vcodec libx264 -level 41 -vpre libx264-lossless_fast -crf 24 -threads 0 -sn -acodec libfaac -ab 128k -ac 2 -ar 48000 -vsync 1 -async 1000 “OUTPUTFILE”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s