Opened 5 years ago

Closed 11 months ago

#11212 closed enhancement (no change required)

Video encoding is single-threaded

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: Kits/Media Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All


Converting a video with MediaConverter results in a single thread being consumed. As FFMPEG supports multiple threads for encoding, this should be investigated. (or an option added to MediaConverter to specify threads)

Attachments (1)

0001-Set-thread_count-configuration-variable-to-actual-nu.patch (979 bytes ) - added by Barrett 5 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 by pulkomandy, 5 years ago

Does the ancinet version of ffmpeg we use support multiple threads, or is that a more recent addition to ffmpeg?

comment:2 by korli, 5 years ago

For decoding it's done here. Now it's up to the encoder/decoder to actually use this setting.

comment:3 by Barrett, 5 years ago

Isn't set to the number of cpu cores? If i'm right, it's actually the expected way to work, and there's not any advantage on raw calculus to increase or decrease the number of threads behind.

comment:4 by pulkomandy, 5 years ago

That code is only for decoding, we need to do the same for encoding (in AVCodecEncoder). As mentionned this also assumes ffmpeg will actually use the setting (it may not do so with some video formats).

comment:5 by Barrett, 5 years ago

Has a Patch: set

comment:6 by Barrett, 5 years ago

I was referring mostly to add it as a configurable option in MediaConverter. In the patch attached i've add the setting in the fContext of AVCodecEncoder and it adds two threads with my dual core cpu compared to the same rev built without it. The cores are more balanced, it can be seen in ProcessController where without the patch there's just one core in high load.

Last edited 5 years ago by Barrett (previous) (diff)

comment:7 by Barrett, 5 years ago

There's anyway an accuracy drop when the patch is applied, it may be related to the comments contained in AVFormatReader.cpp. Our version of ffmpeg is also compiled without the --enable-pthread flag which may be cause of problems.

comment:8 by pulkomandy, 4 years ago

What do you mean by "accuracy drop"? Is the encoding less good?

Another option could be to process several files at a time at MediaConverter side. This would be more generic and work also with other encoders, but help with MediaConverter only, and not with other apps.

comment:9 by Barrett, 4 years ago

The resulting files played correctly in MediaPlayer but the image was visibly distorted with things like frames dropped. I think the result was different depending on the format, but it has passed a few time since i've tested it.

comment:10 by axeld, 3 years ago

Owner: changed from axeld to nobody
Status: newassigned

comment:11 by pulkomandy, 2 years ago

Patch migrated to Gerrit:

comment:12 by pulkomandy, 2 years ago

Has a Patch: unset

comment:13 by waddlesplash, 18 months ago

Related: #11657.

comment:14 by waddlesplash, 11 months ago

Resolution: no change required
Status: assignedclosed

Patch was abandoned as it is not needed, FFmpeg does this already.

Note: See TracTickets for help on using tickets.