I am using following command to encode my video to h264 and aac audio codec :

ffmpeg -i sample.mp4 -codec:v libx264 -profile:v high -level:v 4.0 -codec:a libvo_aacenc -b:a 128k output_file.mp4

Following is a trace of the error i am getting at the console.

Input #0, mpegts, from 'sample.mp4':
  Duration: 00:00:58.08, start: 1.000033, bitrate: 17290 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1
080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fl
tp, 448 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090)
[libx264 @ 003dc660] using SAR=1/1
[libx264 @ 003dc660] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 003dc660] profile High, level 4.0
[libx264 @ 003dc660] 264 - core 130 r2274 c832fe9 - H.264/MPEG-4 AVC codec - Cop
yright 2003-2013 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 de
block=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 chr
oma_qp_offset=-2 threads=12 lookahead_threads=2 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=25 scen
ecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmi
n=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libvo_aacenc @ 03c3c640] Unable to set encoding parameters
Output #0, mp4, to 'output_file.mp4':
    Stream #0:0: Video: h264, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 90
k tbn, 29.97 tbc
    Stream #0:1: Audio: aac, 48000 Hz, 5.1(side), s16, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (ac3 -> libvo_aacenc)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters
such as bit_rate, rate, width or height

I am really not able to find what possibly could be wrong. I dont want to copy audio codec , i wish to encode it from ac3 to aac

Also any suggestion to make it lossless

  • 1
    Try adding -a:c 2 after -b:a 128k – Gyan Jul 15 '15 at 11:53
  • Thanks !! that kinda worked for me... :) But next step now for me is to make it less lossy. – akki_2891 Jul 16 '15 at 4:49
  • Your source audio is 448kbps in 6 channels i.e. ~75kbps per channel, and your target codec is AAC (a lossy codec), so it won't be lossless. Most you can do is increase the target bitrate to something like 192k or higher from 128k. You'll, of course, lose the channel separation from 6 to 2. – Gyan Jul 16 '15 at 5:28
  • Yeah i got to know that libvo_aacenc supports two channels only, so i thought to give a try for 'libfdk_aac' . But its says Unknown Encoder 'libfdk_aac' I am quite novice to ffmpeg world :) Your help is much appreciated. Even i tried other aac encoders like aac and libfaac, but getting the errors – akki_2891 Jul 16 '15 at 6:27
  • ffmpeg has to be compiled with fdk. Your build apparently isn't. Use the native encoder with a higher bitrate, so "-strict experimental -c:a aac -b:a 384k" in place of "-codec:a libvo_aacenc -b:a 128k" in your original command. – Gyan Jul 16 '15 at 6:59

You're using an ffmpeg with a 2-year-old version of libx264. It's been mostly feature-complete for a while now, but there are still small improvements and fixes happening.

As Mulvya says, get one built with libfdk_aac, since you should update your ffmpeg for libx264 anyway. Your current ffmpeg is trying to use the VisualOn aac encoder. That's a terrible choice.

Check the video encoding guide on ffmpeg's Trac wiki, too. You should probably use -preset slow at least, to get more quality per bitrate. -crf 23 is the default target-quality, which might be more or less than you want.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.