ffmpeg Too many bits per frame requested - ffmpeg

I am using ffmpeg to convert videos to mp4 format. Everything works fine except with MOV format.
The command I use for everything is:
ffmpeg -i input.mov -strict experimental -sameq -s vga -aspect 1.7777 -vcodec libx264 -preset fast -crf 22 -y output.mp4
but the output I keep getting is:
ffmpeg version 0.9, Copyright (c) 2000-2011 the FFmpeg developers
built on Mar 12 2012 11:01:05 with gcc 4.4.5
configuration: --enable-libx264 --enable-gpl --disable-yasm
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0x21767a0] Referenced QT chapter track not found
Seems stream 0 codec frame rate differs from container frame rate: 30.00 (30/1) -> 30.07 (2225/74)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
Metadata:
creation_time : 2009-04-04 07:12:29
comment : EASTMAN KODAK COMPANY KODAK Z1275 ZOOM DIGITAL CAMERA
comment-eng : EASTMAN KODAK COMPANY KODAK Z1275 ZOOM DIGITAL CAMERA
Duration: 00:00:17.76, start: 0.000000, bitrate: 8100 kb/s
Stream #0:0(eng): Video: mpeg4 (Advanced Simple Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 7968 kb/s, 30.07 fps, 30.07 tbr, 8544k tbn, 30 tbc
Metadata:
creation_time : 2009-04-04 07:12:29
handler_name :
Stream #0:1(eng): Audio: pcm_mulaw (ulaw / 0x77616C75), 16000 Hz, 1 channels, s16, 128 kb/s
Metadata:
creation_time : 2009-04-04 07:12:29
handler_name :
[buffer # 0x2187f00] w:1280 h:720 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[scale # 0x219c120] w:1280 h:720 fmt:yuv420p -> w:640 h:480 fmt:yuv420p flags:0x4
[libx264 # 0x2190d20] using SAR=4/3
[libx264 # 0x2190d20] using cpu capabilities: none!
[libx264 # 0x2190d20] profile High, level 3.0
[libx264 # 0x2190d20] 264 - core 120 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=12 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=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[aac # 0x21917e0] Too many bits per frame requested
Output #0, mp4, to 'output.mp4':
Metadata:
creation_time : 2009-04-04 07:12:29
comment : EASTMAN KODAK COMPANY KODAK Z1275 ZOOM DIGITAL CAMERA
comment-eng : EASTMAN KODAK COMPANY KODAK Z1275 ZOOM DIGITAL CAMERA
Stream #0:0(eng): Video: h264, yuv420p, 640x480 [SAR 4:3 DAR 16:9], q=-1--1, 90k tbn, 30.07 tbc
Metadata:
creation_time : 2009-04-04 07:12:29
handler_name :
Stream #0:1(eng): Audio: aac, 16000 Hz, 1 channels, s16, 128 kb/s
Metadata:
creation_time : 2009-04-04 07:12:29
handler_name :
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 -> libx264)
Stream #0:1 -> #0:1 (pcm_mulaw -> aac)
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
It seems the problem is with audio's bit per frame.
Which might be the right solution?

The "Too many bits per frame requested" error is coming from the native FFmpeg AAC encoder (-c:a aac). You can use one or more of the following solutions:
Update your ffmpeg
Development is very active and the native FFmpeg AAC encoder has seen many improvements; it will now automatically clamp to the max number of bits per frame instead of failing with this error. See the FFmpeg Download page for links to already compiled binaries which are the easiest method to get a recent ffmpeg.
If you're stuck with an old, outdated, ancient ffmpeg:
Increase the audio sampling rate such as by adding -ar 44100.
Decrease your bitrate. Default is probably -b:a 128k. Try lower values until it works.
Use -c:a copy to stream copy (re-mux) the audio, and, because MP4 doesn't support pcm_mulaw, use different output container format such as Matroska (.mkv).
Use a different AAC encoder such as libfdk_aac if your ffmpeg supports it.
You don't need to do any of these options if you upgrade ffmpeg.

I'd hope ffmpeg is more clever than this, but you might try specifying the video stream for your -s and -aspect options: -s:v and -aspect:v.
Alternately, since you're not doing anything special with the audio, you could copy it explicitly with -c:a copy.

Related

Synchronizing RTSP signals with FFMPEG

I have achieved to merge two RTSP signals in one with FFMPEG but in the resulting stream, the first input has a delay of between 2 and 5 seconds with respect to the second. And it is always the first input that is delayed compared to the second.
The two RTSP signals come from the same camera model, same configuration, same room ...
However, if I put the same RTSP signal (either of the two) as input 1 and input 2, the same thing happens. Despite being the same signal, the first input is delayed compared to the second one.
How could I get them synchronized?
This is the command that I execute:
ffmpeg -rtsp_transport tcp -thread_queue_size 512 -rtbufsize 50M -r 15
-i rtsp://XXXX -rtsp_transport tcp -thread_queue_size 512 -rtbufsize 50M -r 15
-c:a aac -i rtsp://YYYY -filter_complex "[0:v]pad=iw*2:ih,setpts=PTS-STARTPTS[bg];
[1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w[out]" -map "[out]" -f hls
-hls_time 2 -hls_list_size 5 -use_localtime 1 -use_localtime_mkdir 1
-hls_segment_filename 'LIVE/file-%s.ts' -map a -ar 16000 -ac 1 -ab 64000 -c:a aac
-y output.m3u8
Here you have the process informationn:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[rtsp # 0x7fe284000e00] Missing PPS in sprop-parameter-sets, ignoring
Input #0, rtsp, from 'rtsp://XXXX':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp
[rtsp # 0x7fe28484de00] Missing PPS in sprop-parameter-sets, ignoring
Input #1, rtsp, from 'rtsp://XXXX':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #1:0: Video: h264 (Main), yuv420p(progressive), 1280x720, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #1:1: Audio: aac (LC), 16000 Hz, mono, fltp
Stream mapping:
Stream #0:0 (h264) -> pad (graph 0)
Stream #1:0 (h264) -> setpts (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 # 0x7fe286802000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 # 0x7fe286802000] profile High, level 4.0
[libx264 # 0x7fe286802000] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=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=1 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls # 0x7fe286800000] Opening 'LIVE/file-1524728763.ts' for writing
Output #0, hls, to 'output.m3u8':
Metadata:
title : Media Presentation
encoder : Lavf57.83.100
Stream #0:0: Video: h264 (libx264), yuv420p, 2560x720, q=-1--1, 15 fps, 90k tbn, 15 tbc (default)
Metadata:
encoder : Lavc57.107.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC), 16000 Hz, mono, fltp, 64 kb/s
Metadata:
encoder : Lavc57.107.100 aac
[hls # 0x7fe286800000] Opening 'LIVE/file-1524728782.ts' for writinged=1.09x
[hls # 0x7fe286800000] Opening 'output.m3u8.tmp' for writing
[hls # 0x7fe286800000] Opening 'output.m3u8.tmp' for writing=N/A speed=1.07x
frame= 396 fps= 15 q=-1.0 Lsize=N/A time=00:00:27.00 bitrate=N/A speed=1.05x
video:2946kB audio:147kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
From the ffmpeg documentation
https://ffmpeg.org/ffmpeg-filters.html#Examples-139:
try setting video pts with
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)'
(some documentation says this is deprecated but I am using the November 27th build and it works.)
Sync the video streams to the first stream i.e
-map "[out]",0:v
and set pts on the audio
-af 'asetpts=N/SR/TB'
YMMV, but it works with my cheap Chinese IP cams

FFmpeg stuck on frame 0 during time-lapse conversion with `-ss` start time

I have a long video that I'd like to speed up into a time-lapse. Following the FFmpeg wiki, I came up with this incantation:
ffmpeg -i IMG_0238.MOV -r 60 -ss 00:04:41 -filter:v "setpts=PTS/60.0" -an output.mp4
It should clip off the first few minutes, then create a new 60fps video file at 60x the speed.
Although it spins all my CPU cores up to 100%, the status bar simply shows frame= 0 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x and never progresses.
The problem seems related to the -ss 00:04:41 flag, which specifies the start time; I want to drop the first 4 minutes 41 seconds of source video. When I omit this option, the video conversion succeeds.
Full log follows.
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.30)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb59b800000] stream 2, missing mandatory atoms, broken header
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fb59b800000] stream 3, missing mandatory atoms, broken header
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_0238.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2017-04-20T16:25:14.000000Z
com.apple.quicktime.location.ISO6709: +36.4610+025.3727+123.613/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 7
com.apple.quicktime.software: 10.3.1
com.apple.quicktime.creationdate: 2017-04-20T19:25:13+0300
Duration: 01:22:45.53, start: -0.000023, bitrate: 44171 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160, 44077 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 180
creation_time : 2017-04-20T16:25:14.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Side data:
displaymatrix: rotation of -180.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 84 kb/s (default)
Metadata:
creation_time : 2017-04-20T16:25:14.000000Z
handler_name : Core Media Data Handler
Stream #0:2(und): Data: none (mebx / 0x7862656D) (default)
Metadata:
creation_time : 2017-04-20T16:25:14.000000Z
handler_name : Core Media Data Handler
Stream #0:3(und): Data: none (mebx / 0x7862656D) (default)
Metadata:
creation_time : 2017-04-20T16:25:14.000000Z
handler_name : Core Media Data Handler
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 # 0x7fb59b82b800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 # 0x7fb59b82b800] profile High, level 5.2
[libx264 # 0x7fb59b82b800] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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=6 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=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
com.apple.quicktime.creationdate: 2017-04-20T19:25:13+0300
com.apple.quicktime.location.ISO6709: +36.4610+025.3727+123.613/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 7
com.apple.quicktime.software: 10.3.1
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 3840x2160, q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
Metadata:
encoder : Lavc57.107.100 libx264
creation_time : 2017-04-20T16:25:14.000000Z
handler_name : Core Media Data Handler
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
displaymatrix: rotation of -0.00 degrees
frame= 0 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
Specify the -ss parameter before the -i parameter:
ffmpeg -ss 00:04:41 -i IMG_0238.MOV -r 60 -filter:v "setpts=PTS/60.0" -an output.mp4
What -ss as an output option does, is discard output till frames with the specified inpoint are received. Since that can take some time, the progress counter will appear to be 'stuck' but processing is ongoing. In your case, what further compounds the issue is that since you're collapsing timestamps to 1/60th, ss of 04:41 represents 04:41 x 60 of input being discarded. Increases the progress delay a lot, but more importantly, your output doesn't start where you want it to.
By using -ss as input option, ffmpeg will discard 04:41 of the input and then process the rest. The progress counter will also be active immediately.

ffmpeg: Too many bits per frame requested [duplicate]

This question already has answers here:
ffmpeg Too many bits per frame requested
(2 answers)
Closed 6 years ago.
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
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.
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.

Set timeout on ffmpeg process

Sometims ffmpeg never completes, and thereby preventing conversions of other videos in the queue. Is it possible to set some sort of timeout in ffmpeg such that it terminates if it isnt finished within some given time, example 5 min
My command looks like this today:
ffmpeg -i /home/tomcat/bsafevideo/1efef9daa7f5000ed83d67f6fbd0e7d9/aad5adc307c4dd7e457509423a7f3734/69451c31cd592e86138423f6849d8141 -y -r 24 -ar 22050 -f mov -vf [in]transpose=1[rt0],[rt0]scale=iw*480/ih:480[sc0],[sc0]pad=640:480:140[pd0],movie=/srv/bsafe/tomcat7/webapps/ROOT/resources/images/logo_watermark.png [wm],[pd0][wm] overlay=W-w-140:0[out] /home/tomcat/bsafevideo/1efef9daa7f5000ed83d67f6fbd0e7d9/aad5adc307c4dd7e457509423a7f3734/69451c31cd592e86138423f6849d8141.mov -ar 22050 -b 1500k -vcodec libtheora -acodec libvorbis -f ogg -vf [in]transpose=1[rt0],[rt0]scale=iw*480/ih:480[sc0],[sc0]pad=640:480:140[pd0],movie=/srv/bsafe/tomcat7/webapps/ROOT/resources/images/logo_watermark.png [wm],[pd0][wm] overlay=W-w-140:0[out] /home/tomcat/bsafevideo/1efef9daa7f5000ed83d67f6fbd0e7d9/aad5adc307c4dd7e457509423a7f3734/69451c31cd592e86138423f6849d8141.ogg -ar 22050 -vcodec libx264 -profile baseline -vf [in]transpose=1[rt0],[rt0]scale=iw*480/ih:480[sc0],[sc0]pad=640:480:140[pd0],movie=/srv/bsafe/tomcat7/webapps/ROOT/resources/images/logo_watermark.png [wm],[pd0][wm] overlay=W-w-140:0[out] /home/tomcat/bsafevideo/1efef9daa7f5000ed83d67f6fbd0e7d9/aad5adc307c4dd7e457509423a7f3734/69451c31cd592e86138423f6849d8141_mp4.mp4
UPDATE. Thanks LordNeckBerd, you pointed me in right direction!
So I see now its kind of not ffmpeg really hanging, the issue is that my java code which reads the inputstream from the linux process will block since ffmpeg never returns a end of line, which I see now when Im running the command. This is the blocking line, it waits for more input from me.
Press [q] to stop, [?] for help
So its two issues here now. First is why this particular conversion is failing, and second, how to make sure ffmpeg is not making this (for my Java process) blocking command asking for more input.
C:\Program Files (x86)\Console2>ffmpeg -i C:/projectsGit/bsafe-server/classes/test/bs- base/video/ac7601e2bc3bc1545cd30ad3160f5232 -y -r 24 -ar 22050 -f mov C:/projectsGit/bsafe-server/classes/test/bs-base/video/ac7601e2bc3bc1545cd30ad3160f5232.mov -ar 22050 -b:v 1500k -vcodec libtheora -acodec libvorbis -f ogg C:/projectsGit/bsafe-server/classes/test/bs-base/video/ac7601e2bc3bc1545cd30ad3160f5232.ogg -ar 22050 -vcodec libx264 -profile:v baseline C:/projectsGit/bsafe-server/classes/test/bs-base/video/ac7601e2bc3bc1545cd30ad3160f5232_mp4.mp4
ffmpeg version N-54762-g38b701a Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 15 2013 18:47:20 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth -- enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable- libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable- libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable- libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable- libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame - -enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable- libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 39.100 / 52. 39.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.101 / 3. 81.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/projectsGit/bsafe-server/classes/test/bs- base/video/ac7601e2bc3bc1545cd30ad3160f5232':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
creation_time : 2013-01-15 05:46:02
Duration: 00:00:10.03, start: 0.000000, bitrate: 394 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 264 kb/s, SAR 65536:65536 DAR 4:3, 10.95 fps, 90k tbr, 90k tbn, 180k tbc
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 127 kb/s
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : SoundHandle
[ogg # 00000000027d7860] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[mp4 # 00000000027dacc0] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 # 0000000003e6b9c0] using SAR=1/1
[libx264 # 0000000003e6b9c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 0000000003e6b9c0] profile High, level 3.0
[libx264 # 0000000003e6b9c0] 264 - core 133 r2334 a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=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=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[libx264 # 00000000027db4a0] using SAR=1/1
[libx264 # 00000000027db4a0] MB rate (108000000) > level limit (2073600)
[libx264 # 00000000027db4a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 # 00000000027db4a0] profile Constrained Baseline, level 5.2
[libx264 # 00000000027db4a0] 264 - core 133 r2334 a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 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=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'C:/projectsGit/bsafe-server/classes/test/bs- base/video/ac7601e2bc3bc1545cd30ad3160f5232.mov':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf55.12.102
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 12288 tbn, 24 tbc
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (libvo_aacenc) (mp4a / 0x6134706D), 22050 Hz, mono, s16, 128 kb/s
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : SoundHandle
Output #1, ogg, to 'C:/projectsGit/bsafe-server/classes/test/bs-base/video/ac7601e2bc3bc1545cd30ad3160f5232.ogg':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf55.12.102
Stream #1:0(eng): Video: theora (libtheora), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 1500 kb/s, 90k tbn, 90k tbc
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : VideoHandle
Stream #1:1(eng): Audio: vorbis (libvorbis), 22050 Hz, mono, fltp
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : SoundHandle
Output #2, mp4, to 'C:/projectsGit/bsafe-server/classes/test/bs-base/video/ac7601e2bc3bc1545cd30ad3160f5232_mp4.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: isom3gp4
encoder : Lavf55.12.102
Stream #2:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 90k tbn, 90k tbc
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : VideoHandle
Stream #2:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 22050 Hz, mono, s16, 128 kb/s
Metadata:
creation_time : 2013-01-15 05:46:02
handler_name : SoundHandle
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Stream #0:0 -> #1:0 (h264 -> libtheora)
Stream #0:1 -> #1:1 (aac -> libvorbis)
Stream #0:0 -> #2:0 (h264 -> libx264)
Stream #0:1 -> #2:1 (aac -> libvo_aacenc)
Press [q] to stop, [?] for help

YUV to mp4 conversion

I am using the command:
ffmpeg -i MovieTest.yuv -vcodec libx264 -b 1200kb -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 128kb output.mp4
for yuv to mp4 conversion.
Here MovieTest.yuv is my input file and output.mp4 is my output file.
And I am using h.264 codec (libx264) for conversion.
It converts my most of the yuv files properly.
But sometimes, the conversion fails with the error on terminal:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '‪MovieTest.yuv‬':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Duration: 00:00:06.45, start: 0.000000, bitrate: 109786 kb/s
Stream #0.0(und): Video: rawvideo, uyvy422, 640x480, 109675 kb/s, 22.31 fps, 27.25 tbr, 30k tbn, 30k tbc
Stream #0.1(und): Audio: aac, stereo, s16, 106 kb/s
[libx264 # 0x12180da00]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 # 0x12180da00]profile High, level 3.0
[libx264 # 0x12180da00]264 - core 98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=6 deblock=1:0:0 analyse=0x3:0x133 me=umh 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=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=0 weightp=0 keyint=12 keyint_min=7 scenecut=40 intra_refresh=0 rc_lookahead=12 rc=abr mbtree=1 bitrate=120 ratetol=33.3 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
[libfaac # 0x12180e000]libfaac doesn't support this output format!
Output #0, mp4, to 'output.mp4':
Stream #0.0(und): Video: libx264, yuv420p, 640x480, q=10-51, 120 kb/s, 90k tbn, 27.25 tbc
Stream #0.1(und): Audio: libfaac, stereo, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
If anybody has any idea, that what is going wrong, plz help.
I think it's because your output bit rate (128kb) is higher than your input bit rate (106 kb).
I've just done a quick test and when I put my output higher than my input mine fails with the same errors as yours - it succeeds when I lower it again.
This may explain why it only fails for some inputs.
If you're scripting this in some way you'll have to use either 'ffmpeg -i' or something like MediaInfo to analyse your input source first and adjust accordingly.

Resources