[FFmpeg-user] Zeranoe Windows builds spiking CPU to 100% randomly

Andy Sheen sheen.andy at googlemail.com
Tue Jul 10 19:42:50 CEST 2012


Roger Pack wrote on Tue 10 Jul at 17:11 UK time
>> There is a problem with this approach. You will have to compile FFmpeg
>> yourself to know if the spikes still occur. I had also seen those spikes
>> https://sessiondatabase.net/jwplayer/double5.gif but could not reproduce
>> them with my own build of the same core sources (+x264 +libmp3lame
>> +libfaac). The only real way to do a bisect is to make an exact copy of
>> Zeranoe's build environment. I do not know if he is cross compiling on
>> *nix or using MingW onder Windows. But he is using GCC 4.7.1 right now,
>> which is not available as Windows binary yet as far as I know.
> At least he makes a script available to setup his compiler, so you can
> use that.  Or whatever script he used at the time, but yes, you'd
> first want to compile it yourself and see if you can reproduce the
> spikes.
> -r
>

Built (and thank goodness for that script!). I can reproduce the spikes.
When the spikes are there, the system is spemding 60+% of it's time in
the kernel.

git bisect seems to suggest this is the problem:

xbmc at pain:~/source/ffmpeg/ffmpeg$ git bisect bad
e4e30256f87f177decf59b59e923d05ef64147df is the first bad commit
commit e4e30256f87f177decf59b59e923d05ef64147df
Author: Janne Grunau <janne-libav at jannau.net>
Date: Sun Dec 25 11:45:05 2011 +0100

threads: default to automatic thread count detection

:100644 100644
0cbc20af9e1da01f3deb42bf16748ba49d613d55c305406493c8bc86f47819e1c33127dd2778cb22
M Changelog
:040000 040000
1095f382f3c1ac7e6bbb19e2a046897a8e18a0ace65f7ef0c2c7fe7d0cfc5c78779e9b34edb3275f
M libavcodec
:040000 040000
be4b4aa8fcb913c1b8730e92cd38d3c31b4897d8d332497fd1a32d0f4bc530bf884983d7a5fc9afd
M libavformat

HOWEVER, code from around that time was compiling two binaries: avconv
and ffmpeg. Both get built and running these command lines (they have
slightly different command line syntax):

ffmpeg -y -loglevel info -i 7416_20120706232700.mpg -r 25 -ss 0:0:0 -t
0:10:00 -map 0:0 -pass 1 -vcodec libx264 -b 1200k -threads 8 -f mp4 -an nul

and

avconv -y -loglevel info -i 7416_20120706232700.mpg -r 25 -ss 0:0:0 -t
0:10:00 -map 0:0 -pass 1 -c:v libx264 -b:v 1200k -threads 8 -f mp4 -an nul

Produce *different* results: the avconv file locks, the ffmpeg one
doesn't. They are both the same build (see logs below).

If I'm reading the compare correctly:
https://github.com/FFmpeg/FFmpeg/compare/f514695...e4e30256 the checkin
before e4e3025 is c11b92b. Building avconv and ffmpeg from c11b92b and
they both work perfectly with no locks. Using avconv from e4e3025, the
locks are back.

Have I debugged it far enough so someone more familiar with the code can
debug it or are we now at a "patches are welcome" point?

For completeness, here's the two command lines for completeness:

ffmpeg version e4e3025, Copyright (c) 2000-2011 the Libav developers
built on Jul 10 2012 17:23:12 with gcc 4.7.1
This program is not developed anymore and is only provided for
compatibility. Use avconv instead (see Changelog for the list of
incompatible changes).
[mpegts @ 000000000455EAE0] Continuity check failed for pid 0 expected 4
got 6
[mpegts @ 000000000455EAE0] max_analyze_duration reached
[NULL @ 00000000045EC6B0] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045EE660] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045F0610] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045CF5E0] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045F5BA0] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045F7AD0] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045F9A00] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045FB9E0] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045FD990] start time is not set in estimate_timings_from_pts
[NULL @ 00000000045FF940] start time is not set in estimate_timings_from_pts
[NULL @ 0000000004601900] start time is not set in estimate_timings_from_pts
[NULL @ 00000000046038C0] start time is not set in estimate_timings_from_pts
[NULL @ 0000000004629E30] start time is not set in estimate_timings_from_pts
[mpegts @ 000000000455EAE0] PES packet size mismatch
Last message repeated 1 times
Input #0, mpegts, from '7416_20120706232700.mpg':
Duration: 00:47:58.80, start: 92347.294089, bitrate: 8027 kb/s
Program 1
Stream #0.0[0x15e0]: Video: mpeg2video (Main), yuv420p, 720x576 [PAR
64:45 DAR 16:9], 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x15e1](eng): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.2[0x15e2](NAR): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
Stream #0.3[0x15e3](eng): Subtitle: [6][0][0][0] / 0x0006
Stream #0.4[0xf05]: Data: [11][0][0][0] / 0x000B
Stream #0.5[0xf07]: Data: [11][0][0][0] / 0x000B
Stream #0.6[0xf08]: Data: [11][0][0][0] / 0x000B
Stream #0.7[0xf09]: Data: [11][0][0][0] / 0x000B
Stream #0.8[0x15e4](eng): Subtitle: dvbsub
Stream #0.9[0xf00]: Data: [5][0][0][0] / 0x0005
Stream #0.10[0xf01]: Data: [5][0][0][0] / 0x0005
Stream #0.11[0xf02]: Data: [5][0][0][0] / 0x0005
Stream #0.12[0xf03]: Data: [5][0][0][0] / 0x0005
Stream #0.13[0xf04]: Data: [5][0][0][0] / 0x0005
Stream #0.14[0x910]: Data: [5][0][0][0] / 0x0005
Stream #0.15[0x911]: Data: [5][0][0][0] / 0x0005
Stream #0.16[0x914]: Data: [5][0][0][0] / 0x0005
Stream #0.17[0x336]: Data: [5][0][0][0] / 0x0005
[buffer @ 0000000004601F50] w:720 h:576 pixfmt:yuv420p
[libx264 @ 000000000462A300] using SAR=64/45
[libx264 @ 000000000462A300] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX
[libx264 @ 000000000462A300] profile Main, level 3.0
[libx264 @ 000000000462A300] 264 - core 125 r2200 999b753 - H.264/MPEG-4
AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html -
options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1
psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=8
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1
b_bias=0 direct=1 weightb=0 open_gop=1 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr
mbtree=1 bitrate=1200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
ip_ratio=1.25 aq=1:1.00
Output #0, mp4, to 'nul':
Metadata:
encoder : Lavf53.19.0
Stream #0.0: Video: libx264, yuv420p, 720x576 [PAR 64:45 DAR 16:9],
q=-1--1, pass 1, 1200 kb/s, 25 tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
[mpegts @ 000000000455EAE0] Continuity check failed for pid 0 expected 4
got 6
frame=14997 fps=379 q=30.0 Lsize= 0kB time=599.84 bitrate= 0.0kbits/s
dup=11 drop=0
video:87671kB audio:0kB global headers:0kB muxing overhead -100.000000%
frame I:105 Avg QP:23.91 size: 22171
[libx264 @ 000000000462A300] frame P:7647 Avg QP:26.89 size: 8856
[libx264 @ 000000000462A300] frame B:7245 Avg QP:28.41 size: 2722
[libx264 @ 000000000462A300] consecutive B-frames: 13.3% 63.3% 10.8% 12.6%
[libx264 @ 000000000462A300] mb I I16..4: 60.6% 0.0% 39.4%
[libx264 @ 000000000462A300] mb P I16..4: 14.9% 0.0% 0.0% P16..4: 39.1%
0.0% 0.0% 0.0% 0.0% skip:46.0%
[libx264 @ 000000000462A300] mb B I16..4: 1.6% 0.0% 0.0% B16..8: 16.4%
0.0% 0.0% direct: 8.6% skip:73.4% L0:29.0% L1:44.5% BI:26.4%
[libx264 @ 000000000462A300] final ratefactor: 24.57
[libx264 @ 000000000462A300] coded y,uvDC,uvAC intra: 31.8% 38.8% 10.1%
inter: 13.9% 10.6% 0.5%
[libx264 @ 000000000462A300] i16 v,h,dc,p: 54% 21% 17% 8%
[libx264 @ 000000000462A300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 23% 15%
6% 5% 6% 5% 7% 5%
[libx264 @ 000000000462A300] i8c dc,h,v,p: 65% 11% 21% 3%
[libx264 @ 000000000462A300] Weighted P-Frames: Y:13.0% UV:2.2%
[libx264 @ 000000000462A300] kb/s:1197.23

This does lock up:

$ avconv -y -loglevel info -i 7416_20120706232700.mpg -r 25 -ss 0:0:0 -t
0:10:00 -map 0:0 -pass 1 -c:v libx264 -b:v 1200k -threads 8 -f mp4 -an nul
avconv version e4e3025, Copyright (c) 2000-2011 the Libav developers
  built on Jul 10 2012 17:23:12 with gcc 4.7.1
[mpegts @ 00000000046BEAE0] Continuity check failed for pid 0 expected 4
got 6
[mpegts @ 00000000046BEAE0] max_analyze_duration reached
[NULL @ 000000000034C6B0] start time is not set in estimate_timings_from_pts
[NULL @ 000000000034E620] start time is not set in estimate_timings_from_pts
[NULL @ 00000000003505D0] start time is not set in estimate_timings_from_pts
[NULL @ 000000000032F5B0] start time is not set in estimate_timings_from_pts
[NULL @ 0000000000355B60] start time is not set in estimate_timings_from_pts
[NULL @ 0000000000357A90] start time is not set in estimate_timings_from_pts
[NULL @ 00000000003599C0] start time is not set in estimate_timings_from_pts
[NULL @ 000000000035B930] start time is not set in estimate_timings_from_pts
[NULL @ 000000000035D8A0] start time is not set in estimate_timings_from_pts
[NULL @ 000000000035F810] start time is not set in estimate_timings_from_pts
[NULL @ 0000000000361780] start time is not set in estimate_timings_from_pts
[NULL @ 0000000000363780] start time is not set in estimate_timings_from_pts
[NULL @ 0000000000389CF0] start time is not set in estimate_timings_from_pts
[mpegts @ 00000000046BEAE0] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from '7416_20120706232700.mpg':
  Duration: 00:47:58.80, start: 92347.294089, bitrate: 8027 kb/s
  Program 1
    Stream #0.0[0x15e0]: Video: mpeg2video (Main), yuv420p, 720x576 [PAR
64:45 DAR 16:9], 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x15e1](eng): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
    Stream #0.2[0x15e2](NAR): Audio: mp2, 48000 Hz, stereo, s16, 256 kb/s
    Stream #0.3[0x15e3](eng): Subtitle: [6][0][0][0] / 0x0006
    Stream #0.4[0xf05]: Data: [11][0][0][0] / 0x000B
    Stream #0.5[0xf07]: Data: [11][0][0][0] / 0x000B
    Stream #0.6[0xf08]: Data: [11][0][0][0] / 0x000B
    Stream #0.7[0xf09]: Data: [11][0][0][0] / 0x000B
    Stream #0.8[0x15e4](eng): Subtitle: dvbsub
    Stream #0.9[0xf00]: Data: [5][0][0][0] / 0x0005
    Stream #0.10[0xf01]: Data: [5][0][0][0] / 0x0005
    Stream #0.11[0xf02]: Data: [5][0][0][0] / 0x0005
    Stream #0.12[0xf03]: Data: [5][0][0][0] / 0x0005
    Stream #0.13[0xf04]: Data: [5][0][0][0] / 0x0005
    Stream #0.14[0x910]: Data: [5][0][0][0] / 0x0005
    Stream #0.15[0x911]: Data: [5][0][0][0] / 0x0005
    Stream #0.16[0x914]: Data: [5][0][0][0] / 0x0005
    Stream #0.17[0x336]: Data: [5][0][0][0] / 0x0005
[buffer @ 0000000006B9FF10] w:720 h:576 pixfmt:yuv420p
[libx264 @ 000000000038A1C0] using SAR=64/45
[libx264 @ 000000000038A1C0] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2 AVX
[libx264 @ 000000000038A1C0] profile Main, level 3.0
[libx264 @ 000000000038A1C0] 264 - core 125 r2200 999b753 - H.264/MPEG-4
AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html -
options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0 me=dia subme=2 psy=1
psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=8
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=1
b_bias=0 direct=1 weightb=0 open_gop=1 weightp=2 keyint=250
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr
mbtree=1 bitrate=1200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
ip_ratio=1.25 aq=1:1.00
Output #0, mp4, to 'nul':
  Metadata:
    encoder         : Lavf53.19.0
    Stream #0.0: Video: libx264, yuv420p, 720x576 [PAR 64:45 DAR 16:9],
q=-1--1, pass 1, 1200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> libx264)
Press ctrl-c to stop encoding
[mpegts @ 00000000046BEAE0] Continuity check failed for pid 0 expected 4
got 6
frame=14999 fps=186 q=30.0 Lsize=       0kB time=599.92 bitrate=  
0.0kbits/s dup=11 drop=0
video:87687kB audio:0kB global headers:0kB muxing overhead -100.000000%
[libx264 @ 000000000038A1C0] frame I:105   Avg QP:23.91  size: 22171
[libx264 @ 000000000038A1C0] frame P:7648  Avg QP:26.89  size:  8857
[libx264 @ 000000000038A1C0] frame B:7246  Avg QP:28.41  size:  2722
[libx264 @ 000000000038A1C0] consecutive B-frames: 13.3% 63.3% 10.8% 12.6%
[libx264 @ 000000000038A1C0] mb I  I16..4: 60.6%  0.0% 39.4%
[libx264 @ 000000000038A1C0] mb P  I16..4: 14.9%  0.0%  0.0%  P16..4:
39.1%  0.0%  0.0%  0.0%  0.0%    skip:46.0%
[libx264 @ 000000000038A1C0] mb B  I16..4:  1.6%  0.0%  0.0%  B16..8:
16.4%  0.0%  0.0%  direct: 8.6%  skip:73.4%  L0:29.0% L1:44.5% BI:26.4%
[libx264 @ 000000000038A1C0] final ratefactor: 24.57
[libx264 @ 000000000038A1C0] coded y,uvDC,uvAC intra: 31.8% 38.8% 10.1%
inter: 13.9% 10.6% 0.5%
[libx264 @ 000000000038A1C0] i16 v,h,dc,p: 54% 21% 17%  8%
[libx264 @ 000000000038A1C0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 23% 15% 
6%  5%  6%  5%  7%  5%
[libx264 @ 000000000038A1C0] i8c dc,h,v,p: 65% 11% 21%  3%
[libx264 @ 000000000038A1C0] Weighted P-Frames: Y:13.0% UV:2.2%
[libx264 @ 000000000038A1C0] kb/s:1197.28




More information about the ffmpeg-user mailing list