Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Currently I have a mic and a webcam connected to my computer. I am running ffmpeg on CentOS 6.3.

When I try to record a video without audio by:

ffmpeg -y -f video4linux2 -t 15 -s 640x480 -r 25 -i /dev/video0 /home/irdb/Desktop/out2.mp4

it runs perfectly and I get a nice video. However when I try to run with audio included by:

ffmpeg -y -f video4linux2 -t 15 -s 640x480 -r 25 -i /dev/video0 -f alsa -ar 22050 -ab 64k -ac 2 -i default /home/irdb/Desktop/out2.mp4

It errors out and prints:

[NULL @ 0x1e33fc0] Codec is experimental but experimental codecs are not enabled,      see -strict -2
Output #0, mp4, to '/home/irdb/Desktop/out2.mp4':
Stream #0:0: Video: h264, yuv420p, 640x480, q=-1--1, 90k tbn, 25 tbc
Stream #0:1: Audio: none, 22050 Hz, 2 channels, flt, 128 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
Stream #1:0 -> #0:1 (pcm_s16le -> aac)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such    as bit_rate, rate, width or height

I assume this has to do with the first error as when I use something like mpg it works just fine. However I plan on streaming this live and want mp4 format as that is pretty much supported by all browsers (Firefox with flash fallback).

Does anyone know how to get the audio to work without additional processing (as I want to stream live and not write to a file eventually).

share|improve this question

migrated from stackoverflow.com Mar 3 '13 at 19:26

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer 1

up vote 4 down vote accepted

Short answer: add -strict experimental (or the alias -strict -2) before the output file name.

Longer answer: mp4 usually contains H.264 video and AAC audio. For the H.264 video you will want to encode it using the GPL-licensed libx264 (which you are doing).

There are multiple AAC encoders that can be used with ffmpeg. There is a native ffmpeg AAC encoder, but it is experimental and the quality is not as good as other AAC encoders. The -strict experimental option can be used to enable it. The Fraunhofer encoder libfdk_aac has the highest quality; it was released in 2012 as part of the Android Jelly Bean source code release under a custom copyleft license. Because the GPL only permits redistribution of binaries containing GPL-licensed code if the entire work is released under the GPL, your ffmpeg is probably not configured with this encoder unless you compiled it yourself.

You can find further details in ffmpeg's AAC encoding guide.

share|improve this answer
    
Thanks so much! Worked great. There is a clicking scratching noise in the audio. Not sure if its the codec or not, as it doesn't change with quality level. However, I will give recompiling with a new ACC codec a try. –  Brianjs Mar 3 '13 at 18:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.