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

Use Google instead of Bing with Windows 10 search

I want to use Google Chrome and Google search instead of Bing when I search in Windows 10. Google Chrome is launched when I click on web, but it's Bing search. (My default search engine on Google and Edge is http://www.google.com ) I haven't found how to configure that. Someone can help me ? Answer There is no way to change the default in Cortana itself but you can redirect it in Chrome. You said that it opens the results in the Chrome browser but it used Bing search right? There's a Chrome extension now that will redirect Bing to Google, DuckDuckGo, or Yahoo , whichever you prefer. More information on that in the second link.

linux - Using an index to make grep faster?

I find myself grepping the same codebase over and over. While it works great, each command takes about 10 seconds, so I am thinking about ways to make it faster. So can grep use some sort of index? I understand an index probably won't help for complicated regexps, but I use mostly very simple patters. Does an indexer exist for this case? EDIT: I know about ctags and the like, but I would like to do full-text search. Answer what about cscope , does this match your shoes? Allows searching code for: all references to a symbol global definitions functions called by a function functions calling a function text string regular expression pattern a file files including a file

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

networking - Windows 10, can ping other PC but cannot access shared folders! What gives?

I have a computer running Windows 7 that shares a Git repo on drive D. Let's call this PC " win7 ". This repo is the origin of a project that we push to and pull from. The network is a wireless network. One PC on this network is running on Windows 10. Let's call this PC " win10 ". Win10 can ping every other PC on the network including win7 . Win7 can ping win10 . Win7 can access all shared files on win10 . Neither of the PCs have passwords. Problem : Win10 cannot access any shared files on win7 , not from Explorer, nor from Git Bash or any other Git management system (E-Git on Eclipse or Visual Studio). So, win10 cannot pull/push. Every other PC on the network can access win7 shared files and push/pull to/from the shared Git origin. What's wrong with Windows 10? I have tried these: Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings\ File sharing is on, Discovery is on, Password protected sharing is off Adapte