Opened 5 years ago

Closed 6 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

Description

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 4 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 5 years ago by pulkomandy

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

comment:2 Changed 5 years ago by korli

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

comment:3 Changed 4 years ago by Barrett

Isn't system_info.info.cpu_count 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 Changed 4 years ago by pulkomandy

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 Changed 4 years ago by Barrett

Has a Patch: set

comment:6 Changed 4 years ago by Barrett

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 4 years ago by Barrett (previous) (diff)

comment:7 Changed 4 years ago by Barrett

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 Changed 4 years ago by pulkomandy

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 Changed 4 years ago by Barrett

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 Changed 2 years ago by axeld

Owner: changed from axeld to nobody
Status: newassigned

comment:11 Changed 19 months ago by pulkomandy

Patch migrated to Gerrit: https://review.haiku-os.org/58

comment:12 Changed 19 months ago by pulkomandy

Has a Patch: unset

comment:13 Changed 13 months ago by waddlesplash

Related: #11657.

comment:14 Changed 6 months ago by waddlesplash

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.