Opened 9 years ago

Closed 9 years ago

#4690 closed defect (fixed)

Windows - Streaming using matroska muxer: CPU usage increases over time

Reported by: MariusSchipper Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mkv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When transcoding from raw video to mjpeg encapsulated in matroska on Windows 7 64bit OS, then CPU usage increases over time. After 12 hours, approx. 2-4 times more CPU time is necessary to get the same amount of work done.

How to reproduce:

ffmpeg -f lavfi -i testsrc=size=720x576:rate=50 -pix_fmt yuv420p -vcodec mjpeg -s 360x288 -qscale:v 5 -f matroska - | ffplay -i -

ffmpeg version: Static from 30-06-2015 via Zeranoe.com

Attachments (1)

patchmkvseekable.diff (2.4 KB ) - added by Carl Eugen Hoyos 9 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Carl Eugen Hoyos, 9 years ago

Is this only reproducible with matroska output or also with -f mjpeg?
I would assume that the matroska muxer needs resources to store the index and similar at the end of transcoding.

comment:2 by MariusSchipper, 9 years ago

I will test this overnight and then post the result.

comment:3 by MariusSchipper, 9 years ago

I ran four tests in total over 12h:

  • mjpeg video coder + matroska muxer: CPU usage increases
  • mjpeg video coder + mjpeg muxer: CPU usage does NOT increase
  • mjpeg video coder + avi muxer: CPU usage does NOT increase
  • mpeg1 video coder + mpeg1 muxer: CPU usage does NOT increase

=> Problem is related to matroska usage:

  • Isn't the matroska format suitable for streaming?
  • What exactly causes the additional work to do?
  • Is this a bug or a property of the matroska muxer?

comment:4 by MariusSchipper, 9 years ago

Keywords: mjpeg removed
Summary: Windows - Transcoding raw video to mjpeg+matroska: CPU usage increases over timeWindows - Streaming using matroska muxer: CPU usage increases over time

comment:5 by Carl Eugen Hoyos, 9 years ago

Keywords: mkv added; matroska CPU removed
Version: unspecifiedgit-master

Please test if attached patch improves the issue.

by Carl Eugen Hoyos, 9 years ago

Attachment: patchmkvseekable.diff added

comment:6 by MariusSchipper, 9 years ago

Thanks for the quick patch, cehoyos!

Unfortunately I do not have the toolchain installed to apply & compile the patch to a windows binary.

Could you carry out the testing instead?

in reply to:  6 comment:7 by Carl Eugen Hoyos, 9 years ago

Replying to MariusSchipper:

Thanks for the quick patch, cehoyos!

Unfortunately I do not have the toolchain installed to apply & compile the patch to a windows binary.

Could you carry out the testing instead?

No (I cannot even reproduce your original issue).
I suggest you install current MSYS and try a default compilation.

comment:8 by Hendrik, 9 years ago

Checks around mkv_add_seekhead_entry are not required, it does not actually write anything itself, similarly mkv_add_cuepoint does not write anything to the file, and the actual writing is protected by a seekable check.

For the OP, try adding a "-live 1" option to the ffmpeg command, and see if it changes anything.

in reply to:  8 comment:9 by Carl Eugen Hoyos, 9 years ago

Replying to heleppkes:

Checks around mkv_add_seekhead_entry are not required,

it does not actually write anything itself, similarly mkv_add_cuepoint does not write anything to the file

Of course not.

But it does allocate memory, or do I misunderstand the code?

comment:10 by Josef Meier, 9 years ago

This command line:

ffmpeg -f lavfi -i testsrc=size=720x576:rate=25 -pix_fmt yuv420p -vcodec mjpeg -s 360x288 -qscale:v 5 -f matroska -live 1 - | ffplay -i - -window_title M-JPEG_Live

(with the option '-live 1') didn't resolve the issue.

The CPU load increased from 1% to 13% over 24 hours. It really seems as if there's a problem with the matroska container.

-f mpeg1video

and

-f mjpeg

work like a charm. The problem with reproducing this effect is in my opinion, that it occurs only after a few hours and it seems as if cpu load increases not linear but exponential after some point in time.

Last edited 9 years ago by Josef Meier (previous) (diff)

comment:11 by MariusSchipper, 9 years ago

cehoyos, I finally tested your suggested patch: It works! CPU load does NOT increase anymore!

When will it be applied to the official version?

comment:12 by Carl Eugen Hoyos, 9 years ago

Component: undeterminedavformat
Status: newopen

comment:13 by Carl Eugen Hoyos, 9 years ago

Resolution: fixed
Status: openclosed

A simplified version of the patch was applied as da46370e94aa9a9225532ac63c5fc7c1259ca837
Thank you for the report and the testing!

Note: See TracTickets for help on using tickets.