I am trying to convert different files to a flash compatible .mp4
file with ffmpeg, but I can't seem to get it to work. Of course the objective is to get the greatest quality with the smallest file size.
So far I have this, which works, but it doesn't play in a flash player for some reason. The result isn't that great, how can I improve this conversion?
This is the command I'm using:
ffmpeg -i input.file -f mp4 -vcodec mpeg4 -r 25 -b 560000 -s 610x340 -acodec aac -ac 2 -ab 64 -ar 44100 output.file
FLV and MP4 are media containers.
MPEG-4 part 2 and H.264 are video codecs. (and H.264 gives much better quality)
libx264 is an encoder for H.264 codec.
mpeg4 is an encoder for MPEG-4 part 2 codec.
Flash can only play video codec H.264 in FLV container.
So the params should be like that:
I use a sequence of commands to do this, starting with mencoder. (see script below). The trick is that ffmpeg's (and mencoder's) mp4 file output is not generally flash compatible due to the way it's interleaved and they don't offer good control over this behavior. So, I produce an AVI file and then use mp4box to remux it the way I want. Here's my complete script, that expects to be given an .avi file, and produces a flash-playable .mp4 file.
In my snippet collection I have the following for this task.
ffmpeg first pass:
ffmpeg second pass:
The quality setting are 2000k = video bitrate, 128k = audio bitrat and 300 = GOP. Don't ask me what the other parameters are. :)
Interleaving with MP4Box:
Create a thumbnail / poster image (play around with 5 to obtain your desired image)
Hope this helps.
To create the interleaving metadata (which will allow for mid stream resumes, and rewinds/fforwards), use the gpac utilities (included in medibuntu for example) to re-interleave the file. Convert to mp4 as follows, with FFmpeg version 0.5 or better:
then
Tada! Done! This will stream properly in JW Flv or other flash players.
Actually you shouldn't be using maxrate, especially not a maxrate of 10000k when you have your bitrate explicitly set to 200k. In fact looking at this even closer I really don't think you understand what most of that stuff is for :)
For starters you're calling the input file output.mp4, plus the output file (which should actually be /dev/null for pass 1) is called yourinfile.avi and you haven't actually set a container format so what you would end up with is an h264 encoded avi file.
Try this for high quality 1080p HD flash compatible h264 encoded MPEG-4 videos, first create a file with the following contents in the same directory as the video you're encoding and name it something like flash-mp4.ffpreset
then from the command line:
That should play perfectly with flash 10+
I found this (very verbose, i'm not sure what half of it even does) snippet somewhere on the web. It's made for doing two passes, so it won't output any video on the first pass, you'll need to set it to do -pass 2 to run the second pass and output the actual video.
To get progressive playback during download you will also need to move the metadata to the start of the file. ffmpeg puts this at the end and flash needs this before it can start playing. A useful tool for this is QTIndexSwapper