Can't convert FLV to MP4 for iPhone with ffmpeg

1

I'm having issues with converting an FLV to an MP4 that will play on iPhone/iPad via Video-js.

It seems that the ffmpeg commands are not converting properly.

Here's one of the original commands that the software, cumulusclips, is running on conversion:

/usr/bin/ffmpeg -i /var/www/html/cumulus/cc-content/uploads/temp/M2q9rmYjSkElrCJA34Cr.avi -s 640x480 -vb 800k -ac 2 -ab 96k -ar 44100     -f flv /var/www/html/cumulus/cc-content/uploads/flv/M2q9rmYjSkElrCJA34Cr.flv

Output similar to the following:

Input #0, avi, from '/var/www/html/cumulus/cc-content/uploads/temp/M2q9rmYjSkElrCJA34Cr.avi':
  Metadata:
    ISFT            : MEncoder 2:1.0~rc2-0ubuntu13
  Duration: 00:09:56.45, start: 0.000000, bitrate: 9586 kb/s
    Stream #0.0: Video: msmpeg4v2, yuv420p, 1920x1080, 24 tbr, 24 tbn, 24 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, 2 channels, s16, 160 kb/s
Output #0, flv, to '/var/www/html/cumulus/cc-content/uploads/flv/M2q9rmYjSkElrCJA34Cr.flv':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: flv, yuv420p, 640x480, q=2-31, 800 kb/s, 1k tbn, 24 tbc
    Stream #0.1: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 96 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1

After this, it's running the following for mobile:

/usr/bin/ffmpeg -i /var/www/html/cumulus/cc-content/uploads/temp/M2q9rmYjSkElrCJA34Cr.avi -s 480x360 -vb 600k -ac 2 -ab 96k -ar 44    100 -f mp4 /var/www/html/cumulus/cc-content/uploads/mobile/M2q9rmYjSkElrCJA34Cr_temp.mp4

Output:

Input #0, avi, from '/var/www/html/cumulus/cc-content/uploads/temp/M2q9rmYjSkElrCJA34Cr.avi':
  Metadata:
    ISFT            : MEncoder 2:1.0~rc2-0ubuntu13
  Duration: 00:09:56.45, start: 0.000000, bitrate: 9586 kb/s
    Stream #0.0: Video: msmpeg4v2, yuv420p, 1920x1080, 24 tbr, 24 tbn, 24 tbc
    Stream #0.1: Audio: mp3, 48000 Hz, 2 channels, s16, 160 kb/s
Output #0, mp4, to '/var/www/html/cumulus/cc-content/uploads/mobile/M2q9rmYjSkElrCJA34Cr_temp.mp4':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: mpeg4, yuv420p, 480x360, q=2-31, 600 kb/s, 24 tbn, 24 tbc
    Stream #0.1: Audio: libfaac, 44100 Hz, 2 channels, s16, 96 kb/s

billabongrob

Posted 2014-07-25T14:47:34.607

Reputation: 13

Not sure, but are you first converting to flv from avi and then trying to convert to mp4 from avi? Why both? What do you want? A file to play on iOs from a server/on-device? – Rajib – 2014-07-25T16:50:54.587

Next time please include the full log output, not just the parts you think are relevant. This helps us troubleshoot your issue better. We have special code formatting – indent it by 4 spaces or select the code and press Ctrl-K. Also, you need to tell us what you mean by "not working properly". I am quite sure I see the problem, but it might not always be so obvious. – slhck – 2014-07-25T16:54:37.193

Answers

1

I'm fairly certain that the ffmpeg version you're using is quite outdated. Please download a static build for your system from the official homepage and use the path to the new ffmpeg instead of the old /usr/bin/ffmpeg.

For example, if you downloaded your static build, you could put it to /usr/local/bin/ffmpeg, make it executable (chmod ugo+x /usr/local/bin/ffmpeg) and then use that.

Then, you want a command like this to convert a video to an MP4 that's HTML5-ready and playable by all kinds of mobile devices:

ffmpeg -i input.avi -c:v libx264 -c:a aac -strict experimental -b:a 128k \
-crf 23 -profile:v baseline -movflags faststart output.mp4

Vary the CRF depending on what quality you want (18–28 is a good range, lower means better), or choose -b:v 2M for fixed-bitrate encoding at 2 MBit/s, for example.

The original conversion was using MPEG-4 Part 2 video instead of MPEG-4 Part 10, which should be supported by mobile devices, but doesn't necessarily have to be. It's safer that way.

Also, these days, you really do not need to create FLV videos. I am not aware of any device or playback technology that would require this (a little antique) format.

You may be interested in this, too: What bunch of ffmpeg scripts do I need to get HTML5-compatible "Video for everybody"?

slhck

Posted 2014-07-25T14:47:34.607

Reputation: 182 472

Thanks a lot. I'll give it try for future videos. The main problem with my method has turned out to be the server and running over https. For some reason the video will not play over SSL but will without. So, yeah. I've chosen yours because it's good information. – billabongrob – 2014-07-25T17:53:22.037