Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As a little experiment I thinking of converting some video/movies/tv-series into a format that could be playable on my K850, but to be a little bit more generic in this question let's say "mid range Sony Ericsson" phone since they all more or less behave the same and has the same screen resolution (240 x 320).

I am looking for command line based tools (for Ubuntu), since I am thinking about writing a "convert and move" script later if it is successful.

A lot of the video I have is encoded in mkv/h264, but since that is not supported by the phone I guess that I need to convert it into some mp4/mpeg4 low quality video.

After some googling it seems like a good candidate for the job is ffmpeg, but that seems to be a very versatile tool with a lot of magic tricks.

Am I on the right track? And if so how do I use ffmpeg to do this?

Thanks Johan


Update: After plating a little bit with ffmeg I noticed that it only uses 1 of my 4 cores, so the transcoding takes forever. I found a arg called -threads but that did not change much, maybe I got it wrong.

I also found that something like this plays in the phone.

ffmpeg -i Mythbusters\ S1D1_1.mkv -threads 4 -t 180 -vcodec mpeg4 -r 15 -s 320x240 Mythbusters\ S1D1_1_mini.mp4

It was possible to use 3gp/h263, but the quality was really useless.

ffmpeg -i Mythbusters\ S1D1_1.mkv -t 180 -vcodec h263 -acodec libfaac -s cif  Mythbusters\ S1D1_1_cif.3gp

And it seems like mp4/h264 is also possible and the result is ok, thanks to this question, this one seem to use more than one core as well so it was a little bit faster for me.

ffmpeg -i Mythbusters_S1D1_1.mkv -t 180 -acodec libfaac -ab 60k -s 320x240 -vcodec libx264 -b 500k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me_method umh -subq 6 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 500k -maxrate 768k -bufsize 2M -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -threads 0 -f mp4 Mythbusters_S1D1_1_qvga.mp4

Update: I have tried to use HandBrakeCLI and it is no problem creating a new file that seem to be the same as the one created with ffmpeg with something like this.

HandBrakeCLI -i Mythbusters_S1D1_1.mkv --size 100 -E faac -B 60 --maxHeight 240 -r 15 -e x264 -o Mythbusters_S1D1_1_hand.mp4

But that one did not play in the phone...


I found this in the official manual:

If you transfer video clips using another program than Media Go™, we recommend that you select H.264 Baseline profile video, up to QVGA at 30 fps, VBR 384 kbps (max 768 kps) with AAC+ audio at 128 kbps (max 255 kbps), 48 kHz and stereo audio in mp4 file format.

So the idea to use H264 seems to be correct.

share|improve this question

Why not try Handbrake? It's available for Linux, Mac Os and Windows and also has a command line interface, if you want.

Here's a guide to the Handbrake CLI.

share|improve this answer
    
I use Handbreak when I rip and encode dvd:s, thou I have not used the cli part of the program. – Johan Aug 29 '09 at 10:47
    
Maybe you could try now :). Handbrake's a very good video conversion app; this should do exactly what you need. – alex Aug 29 '09 at 10:51
    
I'm giving Handbreak a try as well. – Johan Aug 29 '09 at 12:26
    
Have not found the right settings for Handbrake yet, the new video is playable on the computer with vlc.. but not in the phone... – Johan Aug 29 '09 at 21:35
up vote 1 down vote accepted

I cant get it any better than this ffmpeg example:

ffmpeg -i Star_Wars.mkv -acodec libfaac -ab 60k -s 320x240 -vcodec libx264 -b 500k -flags + loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -m e_method umh -subq 6 -trellis 1 -refs 5 -coder 0 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 500k -maxrate 768k -bufsize 2M -qcomp 0 .6 -qmin 10 -qmax 51 -qdiff 4 -level 13 -threads 0 -f mp4 Star_Wars.mp4

This converts a 50min tv-episode (4:3) into a 70Mb file (was 700Mb before)

and a 2h movie (16:9) into a 470Mb file (was 1700Mb before)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .