Video decoding on webview (v79-0-3945). How to take advantage of my hardware acceleration ?

703 views
Skip to first unread message

Thomas LAVOCAT

unread,
Jan 13, 2021, 12:42:53 PM1/13/21
to Chromium-dev

Hello,

When I build the webview I have the option to compile it using the proprietary codec Which seems to be mandatory for any video to be decoded.
But what seems strange is that I don't achieve a good level of performances (even with full screen videos). And in the logs I don't see references to the hardware video decoder I'm used to when I use the native webview I had with AOSP 7 (version 52).

Did I do something wrong on the configuration of webview ?

Have a good day,
Thomas

Torne (Richard Coles)

unread,
Jan 13, 2021, 4:59:51 PM1/13/21
to Thomas LAVOCAT, Chromium-dev
What exact GN args did you use to build?

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/2325b09f-b543-4b0a-a0c2-346689b13690n%40chromium.org.

Thomas LAVOCAT

unread,
Jan 14, 2021, 11:10:43 AM1/14/21
to Torne (Richard Coles), Chromium-dev
Le mer. 13 janv. 2021 à 22:58, Torne (Richard Coles)
<to...@chromium.org> a écrit :
>
> What exact GN args did you use to build?
>

I should've embedded these directly in the first message, I'll think
about it next time. Here they are :

target_os = "android"
target_cpu = "arm"
chrome_public_manifest_package = "com.google.android.apps.chrome"
is_debug = false
is_official_build = true
fieldtrial_testing_like_official_build = true
is_component_build = false
is_chrome_branded = false
use_official_google_api_keys = false
#ffmpeg_branding = "Chrome"
#proprietary_codecs = true
exclude_unwind_tables = false

If I uncomment the proprietary codec part, I can decode the video. But
I feel like it is not a good approach because I already pay royalties
for my board's codecs and I don't think I have rights to distribute
chrome's proprietary codecs.

Again, thank you for helping me,

Torne (Richard Coles)

unread,
Jan 14, 2021, 12:02:42 PM1/14/21
to Thomas LAVOCAT, bo...@chromium.org, Chromium-dev
I'm not super familiar with how video decoding works here unfortunately; +bo...@chromium.org may be able to expand/correct me here, but if I'm remembering correctly we use Chromium's video pipeline in most cases rather than invoking the Android media playback system, and if you don't enable support in Chromium for the codecs in question the videos won't play at all even if they're supported on the device. This is independent of whether hardware or software decoding will be used.

So yes, I think that if you intend to be able to play videos encoded with proprietary codecs you will need to enable them in your build; unfortunately we can't give you legal advice on what obligations/royalties/etc this may incur.

If you're expecting hardware decoding but getting software decoding, that's a different problem and unfortunately I don't really know how HW decoding works in Chromium at all :(

Dale Curtis

unread,
Jan 14, 2021, 2:06:47 PM1/14/21
to to...@chromium.org, Thomas LAVOCAT, bo...@chromium.org, Chromium-dev
I think if you set proprietary_codecs=true but leave ffmpeg_branding=Chromium you'll get what you want. This will trigger a GN error that you'll need to disable, but might work for Android. 

- dale

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Thomas LAVOCAT

unread,
Jan 14, 2021, 3:58:26 PM1/14/21
to Chromium-dev, to...@chromium.org, Chromium-dev, Thomas LAVOCAT, Bo Liu
Hi again,

I've managed to find a configuration to use my own decoders.

In the logs I have :

I/MediaCodec: MediaCodec will operate in async mode
I/MediaCodec: [OMX.Freescale.std.video_decoder.avc.v3.hw-based] setting surface generation to 6471681
I/ACodec: Send reorder config(0) to VPU

Which is a good point :)

To do that I use

target_os = "android"                                                             
target_cpu = "arm"                                                             
system_webview_package_name = "com.google.android.apps.chrome"                 
is_debug = false                                                               
is_official_build = true                                                       
fieldtrial_testing_like_official_build = true                                  
is_component_build = false                                                     
is_chrome_branded = false                                                      
use_official_google_api_keys = false                                           
ffmpeg_branding = "Chrome"                                                     
proprietary_codecs = true                                                      
exclude_unwind_tables = false                                             
enable_ffmpeg_video_decoders = true                                      
integrated_mode = true   # I'm not sure if this is usefull or not.

I'm not super familiar with how video decoding works here unfortunately; +bo...@chromium.org may be able to expand/correct me here, but if I'm remembering correctly we use Chromium's video pipeline in most cases rather than invoking the Android media playback system, and if you don't enable support in Chromium for the codecs in question the videos won't play at all even if they're supported on the device. This is independent of whether hardware or software decoding will be used.

Indeed my goal is to make Chromium use the android media playback system. I've seen huge improvments in video playback when Chromium delegates the video player to a VideoView component when in full screen on the version 52 of chromium.
So far I've been unable to reproduce this behaviour with the version 79. So I'm wondering if things have change since 2016 (I bet they have), and if there is still a way to make the VideoView do the playback when in fullscreen.

So yes, I think that if you intend to be able to play videos encoded with proprietary codecs you will need to enable them in your build; unfortunately we can't give you legal advice on what obligations/royalties/etc this may incur.
 
I hope since now the browser is using the codecs I pay for, it is okay to assume that it's legally fine.
 
If you're expecting hardware decoding but getting software decoding, that's a different problem and unfortunately I don't really know how HW decoding works in Chromium at all :(
 I guess, I was already hardware decoding but using the GPU instead of the VPU on my board. But it's only a speculative assertion ^^

Thanks,
Thomas




Thomas LAVOCAT

unread,
Jan 19, 2021, 2:07:09 PM1/19/21
to Chromium-dev, Dale Curtis, Thomas LAVOCAT, Bo Liu, Chromium-dev, to...@chromium.org
Le jeudi 14 janvier 2021 à 20:06:47 UTC+1, Dale Curtis a écrit :
I think if you set proprietary_codecs=true but leave ffmpeg_branding=Chromium you'll get what you want. This will trigger a GN error that you'll need to disable, but might work for Android. 

- dale

I did this and it worked well.
Thanks for the advice,

Thomas
Reply all
Reply to author
Forward
0 new messages