[FFmpeg-user] ffmpeg goes 100% cpu

Octavio Alvarez octalff at alvarezp.org
Sat Jun 23 03:19:10 EEST 2018


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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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:0    SKIP:0    size=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); 4 frames
decoded;
  Total: 4 packets (6294528 bytes) demuxed
Output file #0 (output.mkv):
  Output stream #0:0 (video): 120 frames encoded; 120 packets muxed
(12405656 bytes);
  Total: 120 packets (12405656 bytes) muxed
121 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x5604d38d7b40] Statistics: 14 seeks, 128 writeouts
[libx264 @ 0x5604d38d2a00] frame I:120   Avg QP:28.06  size:103376
[libx264 @ 0x5604d38d2a00] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x5604d38d2a00] coded y,uvDC,uvAC intra: 32.9% 17.3% 16.1%
[libx264 @ 0x5604d38d2a00] i16 v,h,dc,p: 71% 26%  2%  1%
[libx264 @ 0x5604d38d2a00] i8c dc,h,v,p: 78% 14%  7%  1%
[libx264 @ 0x5604d38d2a00] kb/s:19382.93
[AVIOContext @ 0x5604d38b2740] Statistics: 6306646 bytes read, 0 seeks

For -t 4.9:

[matroska @ 0x55af71159540] Writing block at offset 10, size 97984, pts
4520, dts 4520, duration 40, keyframe 1
[Parsed_setpts_0 @ 0x55af7136cac0] N:113 PTS:4843 T:4.843000 POS:6201895
INTERLACED:0 -> PTS:4840 T:4.840000
[libx264 @ 0x55af71155a00] frame= 106 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0    SKIP:0    size=102277 bytes
[matroska @ 0x55af71159540] Starting new cluster at offset 11279756
bytes, pts 4560dts 4560
[matroska @ 0x55af71159540] Writing block at offset 10, size 102277, pts
4560, dts 4560, duration 40, keyframe 1
[Parsed_setpts_0 @ 0x55af7136cac0] N:114 PTS:4883 T:4.883000 POS:6205211
INTERLACED:0 -> PTS:4880 T:4.880000
[libx264 @ 0x55af71155a00] frame= 107 QP=28.00 NAL=3 Slice:I Poc:0
I:4128 P:0    SKIP:0    size=102289 bytes
[matroska @ 0x55af71159540] Starting new cluster at offset 11382063
bytes, pts 4600dts 4600
[matroska @ 0x55af71159540] Writing block at offset 10, size 102289, pts
4600, dts 4600, duration 40, keyframe 1
[Parsed_setpts_0 @ 0x55af7136cac0] N:115 PTS:4923 T:4.923000 POS:6259321
INTERLACED:0 -> PTS:4920 T:4.920000
[out_0_0 @ 0x55af71512300] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
[Parsed_setpts_0 @ 0x55af7136cac0] N:116 PTS:4963 T:4.963000 POS:6303175
INTERLACED:0 -> PTS:4960 T:4.960000

What am I missing?

Thank you in advance,
Octavio.


More information about the ffmpeg-user mailing list