First of all, if you haven't already done so, check out this ffmpeg h.264 encoding guide - it applies to avconv as well, just change every instance of ffmpeg
to avconv
. Also, consider upgrading to a more recent version of avconv or ffmpeg - since you're on Ubuntu, you could use this PPA, or compile it yourself (this last option will give you access to fdk_aac, which is a much better AAC encoder than FAAC).
Unless you know exactly what you're doing & have a specific reason, you probably shouldn't use -bufsize 20M -maxrate 4000k -threads 12 -same_quant
. In fact, going by the input in that pastebin, you should probably just use -codec:v copy
, which won't touch the video stream.
As for your stated problem... I don't think libfaac is your problem. Look here (from your pastebin):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from \'/var/www/up/up50eefce404e4f.mp4\': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isomavc1mp42 creation_time : 2007-12-08 19:28:08 Duration: 00:46:47.64, start: 0.000000, bitrate: 308 kb/s Stream #0.0(und): Audio: aac, 44100 Hz, stereo, s16, 111 kb/s Metadata: creation_time : 2007-12-08 19:28:08 Stream #0.1(und): Video: h264 (Baseline), yuv420p, 320x240 [PAR 1:1 DAR 4:3], 195 kb/s, 11.99 fps, 11.99 tbr, 11988 tbn, 23976 tbc Metadata: creation_time : 2007-12-08 19:28:11
FFmpeg thinks your input audio is stereo. Much later on:
Input stream #0:0 frame changed from rate:44100 fmt:s16 ch:2 to rate:44100 fmt:s16 ch:8 Resampling output channel count must be 1 or 2 for mono input; 1, 2 or 6 for stereo input; or N for N channel input. Can not resample 8 channels @ 44100 Hz to 2 channels @ 44100 Hz
The video stream is also throwing up a hell of a lot of errors. I suspect that your input may be corrupted.
It's possible that the following command will work:
avconv -ac 8 -i input.mp4 -c:v copy -c:a libfaac -b:a 128k -ac 2 output.mp4
-ac
sets the number of audio channels: if the AAC stream isn't corrupted, it's possible that the container format is just providing incorrect data to avconv, and putting -ac 8
before the input overrides the setting provided by the MP4 container (and putting -ac 2
before the output tells ffmpeg to output to 2 audio channels).