[FFmpeg-user] [anomaly] double CPU consumption when encoding from online source

Anton Litvinov jnashicq at googlemail.com
Wed Feb 1 11:53:11 CET 2012


Hi
Profiler report reveals that it takes _exactly_ twice as much (x2) cpu-time
to encode video from webcam compared to file (copy of original stream from
webcam).

When encoding from ip-camera:

perf record -o perf.data1 ffmpeg -t 60 -f mjpeg -r 25 -i '
http://192.168.1.32/cgi/mjpg/mjpg.cgi' -r 25 -b 500k -vcodec flv -f flv -y
output.flv

# Events: 23K cycles
#
# Overhead  Samples          Command          Shared Object
                     Symbol
# ........ ..........  .............  .....................
.........................................
#
    30.10%       7250         ffmpeg  libavcodec.so.53.6.0   [.] 0x416b43

    23.66%       5476         ffmpeg  libswscale.so.2.0.0    [.] 0x169e4

    10.86%       2512         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_decode_sos
     9.69%       2219         ffmpeg  libc-2.13.so           [.] 0x820e4

     4.41%       1014         ffmpeg  libavcodec.so.53.6.0   [.]
ff_estimate_p_frame_motion
     4.15%        951         ffmpeg  [kernel.kallsyms]      [k]
0xffffffff81031dba
     3.52%        428         ffmpeg  libavcodec.so.53.6.0   [.] 0x461685

     2.80%        635         ffmpeg  libavcodec.so.53.6.0   [.]
ff_fdct_sse2
     2.05%        464         ffmpeg  libavcodec.so.53.6.0   [.]
ff_epzs_motion_search
     1.63%        372         ffmpeg  libavcodec.so.53.6.0   [.]
h263_encode_mb
     1.13%        257         ffmpeg  libavcodec.so.53.6.0   [.]
MPV_decode_mb
     0.98%        227         ffmpeg  libavcodec.so.53.6.0   [.]
ff_simple_idct_put_mmx
     0.76%        175         ffmpeg  libavcodec.so.53.6.0   [.]
ff_put_pixels_clamped_mmx
     0.57%        135         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_find_marker
     0.42%        100         ffmpeg  libavcodec.so.53.6.0   [.] 0xc380b

     0.42%         85         ffmpeg  libavcodec.so.53.6.0   [.] 0x279c83

     0.27%         35         ffmpeg  libavcodec.so.53.6.0   [.] 0x305e94

     0.25%         55         ffmpeg  libavcodec.so.53.6.0   [.]
ff_h263_update_motion_val
     0.19%         43         ffmpeg  libavcodec.so.53.6.0   [.]
init_vlc_sparse
     0.18%         44         ffmpeg  libavcodec.so.53.6.0   [.]
ff_get_best_fcode
     0.12%         27         ffmpeg  libavcodec.so.53.6.0   [.]
ff_add_pixels_clamped_mmx
     0.12%         28         ffmpeg  libavformat.so.53.3.0  [.] 0xa4841

     0.10%         25         ffmpeg  libavcodec.so.53.6.0   [.]
MPV_encode_picture
     0.10%         21         ffmpeg  ffmpeg                 [.] 0x4ddc

     0.08%          5         ffmpeg  ld-2.13.so             [.] 0x5683

     0.07%         18         ffmpeg  libavcodec.so.53.6.0   [.]
ff_fix_long_mvs
     0.07%         13         ffmpeg  libavcodec.so.53.6.0   [.]
ff_h263_encode_motion
     0.06%         10         ffmpeg  libavcodec.so.53.6.0   [.] 0x2893f5

     0.06%         13         ffmpeg  libavcodec.so.53.6.0   [.]
ff_simple_idct_add_mmx
     0.05%         11         ffmpeg  libavutil.so.51.7.0    [.]
av_image_copy_plane
     0.05%         12         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_decode_dht
     0.05%         10         ffmpeg  libavfilter.so.2.4.0   [.]
avfilter_poll_frame



When encoding from file (dump of the same MJPEG stream from camera):
ffmpeg -t 60 -f mjpeg -i 'http://192.168.1.32/cgi/mjpg/mjpg.cgi' -vcodec
copy -y output.avi
perf record -o perf.data2 ffmpeg -vstats -i output.avi -rtbufsize 5000000
-r 25 -b 500k -vcodec flv -f flv -y  output2.flv

# Events: 14K cycles
#
# Overhead  Samples          Command          Shared Object
          Symbol
# ........ ..........  .............  .....................
..............................
#
    25.63%       3581         ffmpeg  libavcodec.so.53.6.0   [.] 0x45dc5c

    24.40%       1632         ffmpeg  libswscale.so.2.0.0    [.] 0x25519

    10.58%       1485         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_decode_sos
     9.91%       1400         ffmpeg  [kernel.kallsyms]      [k]
0xffffffff81031dba
     7.94%       1120         ffmpeg  libc-2.13.so           [.] 0x820e4

     5.20%        447         ffmpeg  libavcodec.so.53.6.0   [.] 0x3061f5

     4.04%        565         ffmpeg  libavcodec.so.53.6.0   [.]
ff_estimate_p_frame_motion
     2.57%        361         ffmpeg  libavcodec.so.53.6.0   [.]
ff_fdct_sse2
     1.79%        252         ffmpeg  libavcodec.so.53.6.0   [.]
ff_epzs_motion_search
     1.65%        232         ffmpeg  libavcodec.so.53.6.0   [.]
h263_encode_mb
     1.32%        184         ffmpeg  libavcodec.so.53.6.0   [.]
ff_simple_idct_put_mmx
     1.03%        145         ffmpeg  libavcodec.so.53.6.0   [.]
MPV_decode_mb
     0.76%        106         ffmpeg  libavcodec.so.53.6.0   [.]
ff_put_pixels_clamped_mmx
     0.57%         80         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_find_marker
     0.29%         41         ffmpeg  libavcodec.so.53.6.0   [.] 0x416af3

     0.21%         29         ffmpeg  libavcodec.so.53.6.0   [.]
init_vlc_sparse
     0.17%         24         ffmpeg  libavcodec.so.53.6.0   [.]
MPV_encode_picture
     0.17%         24         ffmpeg  libavcodec.so.53.6.0   [.]
ff_h263_update_motion_val
     0.16%         23         ffmpeg  libavcodec.so.53.6.0   [.]
ff_get_best_fcode
     0.11%         16         ffmpeg  ffmpeg                 [.] 0x4f01

     0.11%         15         ffmpeg  libavformat.so.53.3.0  [.] 0x3d298

     0.10%         14         ffmpeg  libavutil.so.51.7.0    [.]
av_image_copy_plane
     0.10%         14         ffmpeg  libavcodec.so.53.6.0   [.]
ff_add_pixels_clamped_mmx
     0.07%         10         ffmpeg  libavcodec.so.53.6.0   [.]
ff_fix_long_mvs
     0.06%          8         ffmpeg  libavcodec.so.53.6.0   [.]
h263_pred_motion
     0.05%          5         ffmpeg  ld-2.13.so             [.] 0x8e6f

     0.05%          7         ffmpeg  libc-2.13.so           [.] cfree
     0.04%          6         ffmpeg  libavcodec.so.53.6.0   [.]
ff_mjpeg_build_huffman_codes
     0.04%          6         ffmpeg  libavcodec.so.53.6.0   [.]
ff_init_block_index
     0.04%          5         ffmpeg  libm-2.13.so           [.] 0xe79e

     0.04%          5         ffmpeg  libavcodec.so.53.6.0   [.]
MPV_frame_end
     0.04%          5         ffmpeg  libavcodec.so.53.6.0   [.]
ff_rate_estimate_qscale

Pay attention to the column "samples".
Surprisingly, but win32 build has no this anomaly and consumes allmost x2
less cpu when encoding from webcam (taking into account, that tasmgr shows
cpu consumtion divided by number of cores).

The resulting file are the same.
I tried different versions, static linking, but it didn't help.

ffmpeg version 0.7.3-4:0.7.3-0ubuntu0.11.10.1
Linux 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20 17:23:00 UTC 2012 x86_64
x86_64 x86_64 GNU/Linux


More information about the ffmpeg-user mailing list