[FFmpeg-user] ffmpeg goes 100% cpu

2018-06-22 Thread Octavio Alvarez
Hi,

I created this 5-sec sample video:

ffmpeg -y -video_size 1366x768 -framerate 25 -f x11grab -i :0.0+0,0 -f
pulse -ac 2 -i default -c:v libx264 -qp 0 -preset ultrafast -pix_fmt
yuv420p -t 5 desk5.mkv

And I want to have it tailpadded with black if the video is too short
compared to the -t option. It works fine if I use -t 5.1 (or 6, or
whatever number larger than 5) like this:

ffmpeg -y -i desk5.mkv -f lavfi -i color=black:s=1366x768:r=25
-filter_complex
'[0:v]setpts=PTS-STARTPTS[timed];[timed][1:v]concat=n=2:v=1[vout]' -map
"[vout]" -t 5.1 -preset ultrafast -intra output.mkv

But if I use -t 4.9 (the result should just be the first 4.9 seconds of
the original video) ffmpeg hangs at the end using 100% of one cpu core:

ffmpeg -y -i desk5.mkv -f lavfi -i color=black:s=1366x768:r=25
-filter_complex
'[0:v]setpts=PTS-STARTPTS[timed];[timed][1:v]concat=n=2:v=1[vout]' -map
"[vout]" -t 4.9 -preset ultrafast -intra output.mkv

Here I add -loglevel trace for both and past the last output lines.
First for -t 5.1 (the one that works) and then for -t 4.9 (the one that
doesn't):

For -t 5.1:

[matroska @ 0x5604d38d6540] Writing block at offset 10, size 102160, pts
4720, dts 4720, duration 40, keyframe 1
[rawvideo @ 0x5604d38d6d00] PACKET SIZE: 1573632, STRIDE: 2049
[libx264 @ 0x5604d38d2a00] frame= 111 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=102160 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 11791814
bytes, pts 4760dts 4760
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 102160, pts
4760, dts 4760, duration 40, keyframe 1
[rawvideo @ 0x5604d38d6d00] PACKET SIZE: 1573632, STRIDE: 2049
[libx264 @ 0x5604d38d2a00] frame= 112 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=102160 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 11894004
bytes, pts 4800dts 4800
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 102160, pts
4800, dts 4800, duration 40, keyframe 1
[rawvideo @ 0x5604d38d6d00] PACKET SIZE: 1573632, STRIDE: 2049
[out_0_0 @ 0x5604d3911380] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
[Parsed_concat_1 @ 0x5604d38d4780] EOF on in1:v0, 0 streams left in segment.
[Parsed_concat_1 @ 0x5604d38d4780] Segment finished at pts=5162759
[libx264 @ 0x5604d38d2a00] frame= 113 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=102160 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 11996194
bytes, pts 4840dts 4840
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 102160, pts
4840, dts 4840, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 114 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=102551 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 12098384
bytes, pts 4880dts 4880
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 102551, pts
4880, dts 4880, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 115 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=99733 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 12200965
bytes, pts 4920dts 4920
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 99733, pts
4920, dts 4920, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 116 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=99732 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 12300728
bytes, pts 4960dts 4960
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 99732, pts
4960, dts 4960, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 117 QP=25.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=3131 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 12400490
bytes, pts 5000dts 5000
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 3131, pts
5000, dts 5000, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 118 QP=23.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=3130 bytes
[matroska @ 0x5604d38d6540] Writing block at offset 3148, size 3130, pts
5040, dts 5040, duration 40, keyframe 1
[libx264 @ 0x5604d38d2a00] frame= 119 QP=21.00 NAL=3 Slice:I Poc:0
I:4128 P:0SKIP:0size=3131 bytes
[matroska @ 0x5604d38d6540] Starting new cluster at offset 12406787
bytes, pts 5080dts 5080
[matroska @ 0x5604d38d6540] Writing block at offset 10, size 3131, pts
5080, dts 5080, duration 40, keyframe 1
[matroska @ 0x5604d38d6540] end duration = 5120
[matroska @ 0x5604d38d6540] stream 0 end duration = 5120
frame=  120 fps= 37 q=-1.0 Lsize=   12121kB time=00:00:05.08
bitrate=19543.0kbits/s speed=1.56x
video:12115kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.053097%
Input file #0 (desk5.mkv):
  Input stream #0:0 (video): 117 packets read (6242725 bytes); 117
frames decoded;
  Input stream #0:1 (audio): 52 packets read (7290 bytes);
  Total: 169 packets (6250015 bytes) demuxed
Input file #1 (color=black:s=1366x768:r=25):
  Input stream #1:0 (video): 4 packets read (6294528 bytes); 

[FFmpeg-user] "Buffer queue overflow, dropping" when using concat

2018-05-16 Thread Octavio Alvarez
Hi, everybody!

I am getting a huge amount of "Buffer queue overflow, dropping." when
using concat. This is my ffmpeg call:

ffmpeg -y  \
  -i camera.mts \
  \
  -f lavfi -i
'color=c=red:duration=675.8339800513014:s=1920x1080:r=3/1001' \
  \
  -filter_complex
'[0:a]adelay=675833.9800513014|675833.9800513014[audio_out]' -map
'[audio_out]' -ss 670 -t 10 track-camera-audio.flac \
  \
  -filter_complex '[1]null[p];[p][0:v]concat=n=2:v=1[video_out]' -map
'[video_out]' -ss 670 -t 10 track-camera-video.mkv


If I remove the line for the audio file (From -filter_complex to output
file) then video file gets created just fine. I get a lot of "Past
duration [N] too large" but the video track gets created correctly
without Buffer queue overflow messages.

Same if I remove the output line (the one for the video file, from the
-filter_complex to the output file). The audio file gets created just fine.


This is the full output. After a while I decide to Ctrl+C and the
track-camera-video.mkv file is less than 1 KB and the
track-camera-audio.flac is 8KB, so it looks like it did nothing.


[Wed May 16 21:28:11 -0500 -- alvarezp@laptop:~/handson/debug]
$ ffmpeg -y   -i camera.mts   -f lavfi -i
'color=c=red:duration=675.8339800513014:s=1920x1080:r=3/1001'
-filter_complex
'[0:a]adelay=675833.9800513014|675833.9800513014[audio_out]' -map
'[audio_out]' -ss 670 -t 15 track-camera-audio.flac   -filter_complex
'[1]null[p];[p][0:v]concat=n=2:v=1[video_out]' -map '[video_out]' -ss
670 -t 15 track-camera-video.mkv
ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7 (Debian 7.3.0-16)
  configuration: --disable-decoder=amrnb --disable-decoder=libopenjpeg
--disable-mips32r2 --disable-mips32r6 --disable-mips64r6
--disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-msa
--disable-libopencv --disable-podpages --disable-stripping
--enable-avfilter --enable-avresample --enable-gcrypt --enable-gnutls
--enable-gpl --enable-libass --enable-libbluray --enable-libbs2b
--enable-libcaca --enable-libcdio --enable-libfdk-aac
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libilbc --enable-libkvazaar
--enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg
--enable-libopenmpt --enable-libopus --enable-libpulse
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libtesseract
--enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libx265 --enable-libxvid
--enable-libzvbi --enable-nonfree --enable-opengl --enable-postproc
--enable-pthreads --enable-shared --enable-version3 --enable-libwebp
--incdir=/usr/include/x86_64-linux-gnu
--libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --toolchain=hardened
--enable-frei0r --enable-chromaprint --enable-libx264
--enable-libiec61883 --enable-libdc1394 --enable-vaapi --disable-opencl
--enable-libmfx --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
  libavutil  56. 14.100 / 56. 14.100
  libavcodec 58. 18.100 / 58. 18.100
  libavformat58. 12.100 / 58. 12.100
  libavdevice58.  3.100 / 58.  3.100
  libavfilter 7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale  5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc55.  1.100 / 55.  1.100
Input #0, mpegts, from 'camera.mts':
  Duration: 01:02:22.75, start: 1.433367, bitrate: 15646 kb/s
  Program 1
Metadata:
  service_name: Service01
  service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr,
90k tbn, 59.94 tbc
Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
stereo, fltp, 384 kb/s
Input #1, lavfi, from
'color=c=red:duration=675.8339800513014:s=1920x1080:r=3/1001':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #1:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 29.97 tbr, 29.97 tbn, 29.97 tbc
Stream mapping:
  Stream #0:0 (h264) -> concat:in1:v0 (graph 1)
  Stream #0:1 (ac3) -> adelay (graph 0)
  Stream #1:0 (rawvideo) -> null (graph 1)
  adelay (graph 0) -> Stream #0:0 (flac)
  concat (graph 1) -> Stream #1:0 (libx264)
Press [q] to stop, [?] for help
[flac @ 0x5620ad6cbcc0] encoding as 24 bits-per-sample
Output #0, flac, to 'track-camera-audio.flac':
  Metadata:
encoder : Lavf58.12.100
Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit), 128 kb/s
Metadata:
  encoder : Lavc58.18.100 flac
[libx264 @ 0x5620ad667980] using SAR=1/1
[libx264 @ 0x5620ad667980] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2
[libx264 @ 0x5620ad667980] profile High, level 4.0
[libx264 @ 0x5620ad667980] 264 - core 155 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2018 - http://www.videolan.org/x264.html - options:
cabac=1