Converting FLV files for Xbox 360 playback with ffmpeg and PowerShell
I recently stumbled upon a bunch of FLV files that I would like my daughter to be able to watch on our Xbox 360. Unfortunately, Xbox does not support these files, so I had to figure out how to convert them.
There are several commercial tools available for the job and I’m sure many of them can pull this off nicely but I wanted to check whether any of the free alternatives could do it.
The tool I successfully used is FFMPEG command line tool. You may download the latest binaries for Windows here: http://ffmpeg.zeranoe.com/builds/ I used the static 64-bit package.
Ffmpeg has a huge selection of command line options to select different codecs and standards for video. With trial and error I figured the following works to convert Video.FLV to Video.MOV.
ffmpeg -i Video.flv -y -vcodec libx264 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq ‘blurCplx^(1-qComp)’ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -refs 3 -bf 3 -trellis 1 -ab 128k -b:v 1321k -f mov Video.mov
Note that Xbox does not recognize files with MOV-extension. You first need to rename it to AVI in order for it to work! That’s right: rename the MOV file as AVI and it works on Xbox! Xbox does not even show MOV-files on the list but plays them happily. Go figure…
Now, the command above converts just one file, but I had 100+ FLV files and finally used the following PowerShell script to convert them all from the current directory to MOV-files that were renamed to AVI files:
dir *.flv | foreach-object {$fn = $_.Name.split(‘.’)[0]; ffmpeg -i $fn”.flv” -y -vcodec libx264 -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq ‘blurCplx^(1-qComp)’ -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -refs 3 -bf 3 -trellis 1 -ab 128k -b:v 1321k -f mov $fn”.avi”}
Ffmpeg is a powerful tool and uses multicore processors effectively but it still might take several hours to convert dozens of files. Luckily the quality of the resulting video files is sufficiently high.
On my Xbox, the player did not immediately start playing the MOV file. It first had to download additional codecs from Microsoft.