Skip to main content

video - Unable to re-encode audio stream with different bitrate using ffmpeg


A similar question has been asked elsewhere without a satisfying answer for me.


The following ffmpeg command results in error. When "-c:a copy" is added to just copy the audio stream, the video stream is nicely re-encoded with the requested bitrate.


I'm running this on OS X Yosemite 10.10.2.


How should this error be resolved?


ffmpeg -i input.mp4 -b:v 8M  -b:a 10k output.mp4
ffmpeg version 1.0.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 7 2012 09:31:51 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2015-02-06 08:37:52
Duration: 00:00:48.04, start: 0.000000, bitrate: 12332 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x960 [SAR 1:1 DAR 2:1], 12201 kb/s, 14.98 fps, 14.99 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2015-02-06 08:37:52
handler_name : Core Media Video
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, s16, 125 kb/s
Metadata:
creation_time : 2015-02-06 08:37:52
handler_name : Core Media Audio
[libx264 @ 0x7fbbba009c00] using SAR=1/1
[libx264 @ 0x7fbbba009c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x7fbbba009c00] profile High, level 4.0
[libx264 @ 0x7fbbba009c00] 264 - core 128 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=14 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=8000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[NULL @ 0x7fbbba00aa00] Codec is experimental but experimental codecs are not enabled, try -strict -2
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
Stream #0:0(und): Video: h264, yuv420p, 1920x960 [SAR 1:1 DAR 2:1], q=-1--1, 8000 kb/s, 90k tbn, 14.99 tbc
Metadata:
creation_time : 2015-02-06 08:37:52
handler_name : Core Media Video
Stream #0:1(und): Audio: none, 44100 Hz, mono, flt, 10 kb/s
Metadata:
creation_time : 2015-02-06 08:37:52
handler_name : Core Media Audio
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> aac)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Answer



Here's your error:



Codec is experimental but experimental codecs are not enabled, try -strict -2



When converting to MP4, ffmpeg tries to choose an AAC audio encoder. Since your ffmpeg is not compiled with libfaac, libfdk-aac or libvo-aacenc, all of which are third party encoders, it defaults to the internal AAC encoder (called aac).


However, this encoder is considered experimental and will only run when you add -strict -2 or -strict experimental to the options.


Some notes:




  • You are trying 10 kBit/s as audio bitrate which is much too low for the built-in AAC-LC encoder. This bitrate would only work for HE-AAC v2, which libfdk-aac could do. And it'd still sound bad.




  • In general, I would always explicitly specify the encoder you want to use. Saves you a bit of trouble when the defaults are not sane.




  • I'd recommend you update your ffmpeg version to something more recent, either by downloading a static build, or compiling it yourself. When you compile, you have the choice of using libfdk-aac, which offers better quality than aac, and also has a proper VBR option.




  • Please read the AAC encoding guide for more info.




Comments

Popular Posts

How do I transmit a single hexadecimal value serial data in PuTTY using an Alt code?

I am trying to sent a specific hexadecimal value across a serial COM port using PuTTY. Specifically, I want to send the hex codes 9C, B6, FC, and 8B. I have looked up the Alt codes for these and they are 156, 182, 252, and 139 respectively. However, whenever I input the Alt codes, a preceding hex value of C2 is sent before 9C, B6, and 8B so the values that are sent are C2 9C, C2 B6, and C2 8B. The value for FC is changed to C3 FC. Why are these values being placed before the hex value and why is FC being changed altogether? To me, it seems like there is a problem internally converting the Alt code to hex. Is there a way to directly input hex values without using Alt codes in PuTTY? Answer What you're seeing is just ordinary text character set conversion. As far as PuTTY is concerned, you are typing (and reading) text , not raw binary data, therefore it has to convert the text to bytes in whatever configured character set before sending it over the wire. In other words, when y...

linux - Extract/save a mail attachment using bash

Using normal bash tools (ie, built-ins or commonly-available command-line tools), is it possible, and how to extract/save attachments on emails? For example, say I have a nightly report which arrives via email but is a zip archive of several log files. I want to save all those zips into a backup directory. How would I accomplish that? Answer If you're aiming for portability, beware that there are several different versions of mail(1) and mailx(1) . There's a POSIX mailx command, but with very few requirements. And none of the implementations I have seem to parse attachments anyway. You might have the mpack package . Its munpack command saves all parts of a MIME message into separate files, then all you have to do is save the interesting parts and clean up the rest. There's also metamail . An equivalent of munpack is metamail -wy .

Desktop reboots itself on sleep or hibernate

I have been using an ASUS M2NPV-VM motherboard for main home desktop workstation, operating Windows Vista x64. This computer has right from day one not been able to enter hibernate or standby; after Windows performs its final actions and brings the machine down, it would automatically revive itself for a reboot. Updating to the second latest BIOS (1201)has not helped (the latest BIOS revision would induce video refresh problems rendering it unusable). I have been reading related discussions on incidents similar to mine to no avail of a true workable solution. They appear to be more speculative guesses rather than actual knowledge on the inner workings of motherboard hardware. Does anybody have any electronic engineering experience on PC energy-saving standards to provide a more informed opinion how to go about getting this to work? More stories: this motherboard could not even reboot properly the first thing i used it. It was due to refresh rate of the onboard GPU, which had no influe...

keyboard - Is there any utility/method to change Windows key bindings to type rare chars to currently empty bindings?

I'm currently typing this post with my windows XP machine and (Spanish) keyboard, and I'd like to add some extra symbols to my text. I could open the "char map" windows utility, look for the desired symbols, and paste them. But I'd like something quickier. For example, when I'm using my OSX Mac at work, I can easily add a ©, ™, ® or similar symbols, just pressing some weird ALT-GR + G / H / J, key combinations. In my (Spanish) keyboard mapping, these combinations are empty, as they don't produce any char at all, which, on the other hand, is perfectly normal and desirable. So, I thought: Why couldn't I add some extra key mappings on top of my currently empty ALT-GR + G/J/H Keys in my Spanish keyboard, and thus, being able to quickly type these special symbols? So that's my question: Is there any utility/method to achieve that effect under windows? (My version is XP). I've even googled this for some time but no luck. I've been a long term Hot...