The first thing you need to know is that to stream a video to the iPhone using progressive downloading you will need to use 2 pass encoding. There is something called the MOOV atom which needs to be at the beginning of the file, but can't be created until after the encoder has been through the entire source file at least once. Pres
umably bitrates, metadata etc, need to be pre-calculated, but that's just a guess. If you come across something called qt-quickstart which will move the MOOV atom, avoid it, just take the time/cpu cycles to do a 2 pass encoding, the videos look better anyway.
Make sure you have a recent build of ffmpeg which has the ffpresets directory. I'm currently using Rev 18639 from Tripp's unofficial win32 builds. One thing to note, on Windows, you have to specify the full path to the preset file, in the -vpre parameter, and put it in double quotes, like in my example below.
On the first pass ffmpeg will create a log file in the current directory that it uses during the second pass. You will see examples on the internet for 2 pass encoding that have an output file for the first pass, but it is unnecessary, we only need the log file so you should specify NUL to save the hard drive I/O. On Linux you’d use /dev/null.
For this little test, I have downloaded a 60 second public domain newsreel clip from 1967 discussing the opening of the world expo held in Montreal that year. Head on over to the National Film Board (NFB) website to get any number of videos you can try converting. The NFB video was 720x480, but the iPhone supports only 640x480 video up to 1500k bitrate. In my example I’m scaling the video down to 640x428 and padding the top and bottom with 26 pixels.
Here is the command for pass 1:
ffmpeg -y -i Expo67.mpg -f ipod -pass 1 -vcodec libx264 -s 640x428 -padtop 26 -padbottom 26 -r 30000/1001 -vpre "D:\utils\ffmpeg\ffpresets\libx264-fastfirstpass.ffpreset" -vpre "D:\utils\ffmpeg\ffpresets\libx264-ipod640.ffpreset" -b 250k -bt 50k -bf 0 -an -threads 0 NUL
The b and bt parameters are bitrate and bitrate tolerance, which you might want to increase for your video. The –bf 0 parameter turns b-frames off, the iPhone does not support H.264 b-frames. Adding it here prevents an error when encoding the 2nd pass. The –an parameter turns audio off, which we won’t encode until the second pass.
Here is the command for pass 2:
ffmpeg -y -i Expo67.mpg -f ipod -pass 2 -vcodec libx264 -s 640x428 -padtop 26 -padbottom 26 -r 30000/1001 -vpre "D:\utils\ffmpeg\ffpresets\libx264-hq.ffpreset" -vpre "D:\utils\ffmpeg\ffpresets\libx264-ipod640.ffpreset" -b 250k -bt 50k -acodec libfaac -ab 56k -ac 2 -ar 22050 -async 1 -threads 0 Expo67.mp4
The trick here is to use two ffmpeg presets at the same time, fastfirstpass/ipod640 then hq/ipod640 for the second pass, always specifying the ipod640 preset second.
Here is a link to the Expo67.mp4 video, which should stream directly to your iPhone using progressive download.