1

Sometimes there is an issue when i try to convert to mp4 using ffmpeg. I'm getting issue Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height.

This is the command:

 ffmpeg -y -i input.mp4 -i watermark.png -filter_complex 'scale=-2:360,overlay=(main_w-overlay_w)-20:(main_h-overlay_h)-20' -codec:v libx264 -profile:v main -preset slow -b:v 300k -maxrate 300k -bufsize 600k -threads 0 -codec:a aac -strict experimental -b:a 128k -crf 20 output.mp4 1> output.log 2>&1

Here the error log:

ffmpeg version 2.4.3 Copyright (c) 2000-2014 the FFmpeg developers
      built on Nov 16 2014 22:36:57 with gcc 4.8.2 (GCC)
      configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/man --docdir=/usr/doc/ffmpeg-2.4.3 --enable-gpl --enable-version3 --enable-avfilter --enable-avresample --enable-libass --enable-libdc1394 --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libv4l2 --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-postproc --enable-runtime-cpudetect --enable-vaapi --enable-vdpau --enable-memalign-hack --enable-pthreads --enable-x11grab --enable-bzlib --enable-zlib --enable-shared --enable-static --disable-debug --arch=x86_64 --enable-pic --extra-cflags='-I/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/include -DRUNTIME_CPUDETECT' --extra-ldflags='-L/tmp/build/tmp-ffmpeg/ffmpegdeps/usr/lib64 -ldl -lssl -lcrypto -lz -lusb' --pkg-config-flags=--static
      libavutil      54.  7.100 / 54.  7.100
      libavcodec     56.  1.100 / 56.  1.100
      libavformat    56.  4.101 / 56.  4.101
      libavdevice    56.  0.100 / 56.  0.100
      libavfilter     5.  1.100 /  5.  1.100
      libavresample   2.  1.  0 /  2.  1.  0
      libswscale      3.  0.100 /  3.  0.100
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  0.100 / 53.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.15.102
      Duration: 00:00:06.76, start: 0.000000, bitrate: 1856 kb/s
        Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x480, 1804 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 16000 Hz, mono, fltp, 54 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    Input #1, png_pipe, from 'watermark.png':
      Duration: N/A, bitrate: N/A
        Stream #1:0: Video: png, rgba, 120x35, 25 tbr, 25 tbn, 25 tbc
    [libx264 @ 0x2179d80] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 SlowShuffle
    [libx264 @ 0x2179d80] profile Main, level 3.0
    [libx264 @ 0x2179d80] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x1:0x111 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 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=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=300 vbv_bufsize=600 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    [aac @ 0x217ba40] Too many bits per frame requested
    Output #0, mp4, to 'output.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.15.102
        Stream #0:0: Video: h264 (libx264), yuv420p, 540x360, q=-1--1, 300 kb/s, 30 fps, 30 tbn, 30 tbc (default)
        Metadata:
          encoder         : Lavc56.1.100 libx264
        Stream #0:1(eng): Audio: aac, 0 channels, 128 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
          encoder         : Lavc56.1.100 aac
    Stream mapping:
      Stream #0:0 (h264) -> scale (graph 0)
      Stream #1:0 (png) -> overlay:overlay (graph 0)
      overlay (graph 0) -> Stream #0:0 (libx264)
      Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
llogan
  • 121,796
  • 28
  • 232
  • 243
nurmat
  • 361
  • 3
  • 11

2 Answers2

1

The relevant messages:

[aac @ 0x217ba40] Too many bits per frame requested
[…]
Error while opening encoder for output stream #0:1

This is from the native FFmpeg AAC encoder named "aac". Your options:

  • Stream copy the input AAC audio instead of re-encoding (-c:a copy).
  • Use a different AAC encoder. This would require re-compiling ffmpeg because your build appears to only support the native FFmpeg AAC encoder.
  • Use a lower audio bitrate (-b:a).
  • Use a higher audio rate (-ar).

Other notes

  • -b:v and -crf are mutually exclusive: you should choose only one. In you case -b:v was ignored.

  • -threads 0 is the default for this encoder, meaning that x264 will automatically select the appropriate number of threads, so you can remove this option.

  • The H.264 profile (-profile:v) only needs to be set if your target players or devices do not support whatever profile the encoder automatically selects.

  • FFmpeg 2.4.3 is considered old. General users are recommended to use ffmpeg from current git master if possible (meaning use a build from the most recent code). Downloading a static build is an easy way to do that.

  • Stack Overflow is for programming questions only. If you have additional ffmpeg cli usage questions they should be asked at Super User.

llogan
  • 121,796
  • 28
  • 232
  • 243
0

There seems to be a problem with your AAC audio stream #0:1. It shows 0 channels in the console output.

Try adding -analyzeduration and -probesize to your command to increase the analysis time and see if it detects them or drop the audio stream entirely / check the source file integrity.

probesize integer (input)

Set probing size in bytes, i.e. the size of the data to analyze to get stream information. A higher value will enable detecting more information in case it is dispersed into the stream, but will increase latency. Must be an integer not lesser than 32. It is 5000000 by default.

analyzeduration integer (input)

Specify how many microseconds are analyzed to probe the input. A higher value will enable detecting more accurate information, but will increase latency. It defaults to 5,000,000 microseconds = 5 seconds.

Community
  • 1
  • 1
aergistal
  • 29,947
  • 5
  • 70
  • 92
  • Is it can help to fix issue or just analyze video encoding procces? – nurmat May 04 '15 at 11:08
  • It will analyze the input file for longer before starting to encode in order to try and get the correct audio codec information. You need to put them before your input `ffmpeg -probesize ### -analyzeduration ### -i input.mp4 ...` – aergistal May 04 '15 at 11:12