17
votes

If I don't make a mistake, Safari currently need MP4 (H.264/AAC) video encoded for the HTML5 <video> element.

So I tried to convert a video to this format with ffmpeg. However when I enter the shell command ffmpeg -i video.flv video.mp4, the returned error is :

Seems stream 0 codec frame rate differs from container frame rate: 2000.00 (2000/1) -> 29.92 (359/12) Input #0, flv, from 'video.flv':
Duration: 00:05:01.20, start: 0.000000, bitrate: 66 kb/s Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 66 kb/s, 29.92 tbr, 1k tbn, 2k tbc Stream #0.1: Audio: aac, 22050 Hz, stereo, s16 Output #0, mp4, to 'video.mp4': Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 29.92 tbc Stream #0.1: Audio: 0x0000, 22050 Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0
Stream #0.1 -> #0.1 Unsupported codec for output stream #0.1

An AAC codec is required but I'm quite newbie with ubuntu and I dont really now how to fix this problem. I'm using Ubuntu 9.10 Karmik Koala (for amd64).

Thank you very much. :)

8
I think this link could be useful: ubuntuforums.org/showthread.php?t=786095Maciek Sawicki
Your video is already encoded with H.264/AAC, you just need to copy it to a new container: ffmpeg -i video.flv -codec copy video.mp4mark4o

8 Answers

17
votes

http://handbrake.fr is a nice high level tool with a lot of useful presets for mp4 for iPod, PS3, ... with both GUI and CLI interfaces for Linux, Windows and Mac OS X.

It comes with its own dependencies as a single statically linked fat binary so you have all the x264 / aac codecs included.

  $ HandBrakeCLI -Z Universal -i myinputfile.mov -o myoutputfile.mp4

To list all the available presets:

  $ HandBrakeCLI -z
14
votes

Software patents led Debian/Ubuntu to disable the H.264 and AAC encoders in ffmpeg. See /usr/share/doc/ffmpeg/README.Debian.gz.

So go install x264, mplayer/mencoder, and Nero's AAC encoder. (Or, if you want to use all Free software, and don't care so much about audio quality, then sudo aptitude install faac.)

I don't remember if the medibuntu package of mencoder includes x264 vid encoding, since I build my own from git x264 and svn mplayer sources. (x264 is very actively developed, with significant quality and speed improvements frequently added.) http://git.videolan.org/?p=x264.git;a=summary

x264 is also packaged, but you should check that it's up to date enough to include weightp with recent bugfixes, and even more recent speed improvements...

Or if you're already willing to convert from .flv, instead of going from the high-quality source the flv was made from, then probably whatever recent version of x264 you can find will be fine.

4
votes

You're trying to convert a (rather rare) .flv file that (already) contains H.264 video and AAC audio.

Formatting your console's output as FFmpeg brings out these details.

 Input #0, flv, from 'video.flv':
   Duration: 00:05:01.20, start: 0.000000, bitrate: 66 kb/s
    Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 66 kb/s, 29.92 tbr, 1k tbn, 2k tbc 
    Stream #0.1: Audio: aac, 22050 Hz, stereo, s16

The original flv is converted to an .mp4 file with H.264 video and AAC audio (just like the original .flv):

Output #0, mp4, to 'video.mp4': 
    Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 29.92 tbc 
    Stream #0.1: Audio: 0x0000, 22050 Hz, stereo, s16, 64 kb/s

Because the audio and video data in the .flv are already in the format/codecs you need for the .mp4, you can just copy everything to the new .mp4 container. This process will be massively faster than decoding and reencoding everything:

ffmpeg -i video.flv -vcodec copy -acodec copy video.mp4

or more simply:

ffmpeg -i video.flv -codec copy video.mp4

The real error you're getting is:

Unsupported codec for output stream #0.1

Which means FFmpeg can't convert audio (stream #0.1) to AAC.

You can skip the error by:

  • copying the audio data since it's already AAC encoded (use the copy command above)

or you can solve the error by:

For more details you should also read Converting FLV to MP4 With FFmpeg The Ultimate Guide

3
votes

You need to recompile ffmpeg (from source) so that it supports x264. If you follow the instructions in this page, then you will be able to peform any kind of conversion you want.

1
votes

You can also try adding the Motumedia PPA to your apt sources and update your ffmpeg packages.

1
votes

Had this problem recently with converting nasty WMV into Final Cut Pro X for editing. Flow player can do it but it leaves a water mark, so I fiddled a bit with ffmpeg till I got something going.

First install ffmpeg - I used brew install ffmpeg Obviously you need brew installed first, google that bit.

Next I wrote a simple command line script with the following content - you can substitute the $1 for an input / output file or just create a shell script file... vi convert.sh Paste.

echo "Pass one" ffmpeg -y -i "$1" -c:v libx264 -preset medium -b:v 1555k -pass 1 -c:a libfaac -b:a 256k -f mp4 /dev/null && echo "Pass two" ffmpeg -i "$1" -c:v libx264 -preset medium -b:v 1555k -pass 2 -c:a libfaac -b:a 256k "$1.mp4"

Then to convert your video... sh convert.sh myvideofile.wmv If all went well you should see a new file called myvideofile.wmv.mp4.

Hope that works for you.

0
votes

You need to compile ffmpeg with an AAC encoder. You can find one at AudioCoding.

0
votes

Try This one:: Libav in Linux

Installation: run command  
               sudo apt-get install libav-tools 

Video conversion command::Go to folder contains the video and run in terminal
               avconv -i oldvideo.flv -ar 22050 convertedvideo.mp4