MP4 on ARM not working with proprietary codecs enabled

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Sun Oct 27, 2019 12:22 am

Hello all

I've built CEF with proprietary codecs enabled (GN_DEFINES="use_sysroot=true is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome arm_float_abi=hard symbol_level=1" and even modified features.gni to have default for proprietary_codecs to be true instead of depending on chrome_branding). However when trying to play an mp4 video this does not work.

The build is a release build from the latest master.

The video is used like this:
Code: Select all
<video controls autoplay>
    <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
</video>


And the debug logs indicate:
Code: Select all
[1027/051736.551653:INFO:cpu_info.cc(53)] Available number of cores: 4
[1027/051736.552056:VERBOSE1:zygote_main_linux.cc(217)] ZygoteMain: initializing 0 fork delegates
[1027/051736.566342:VERBOSE1:pref_proxy_config_tracker_impl.cc(184)] 0xa9b44640: set chrome proxy config service to 0xa9b23f18
[1027/051736.583004:VERBOSE1:webrtc_internals.cc(119)] Could not get the download directory.
[1027/051736.606913:VERBOSE1:pref_proxy_config_tracker_impl.cc(184)] 0x9fc12f60: set chrome proxy config service to 0xa9b23600
[1027/051736.649929:VERBOSE1:sandbox_linux.cc(69)] Activated seccomp-bpf sandbox for process type: renderer.
[1027/051736.661021:VERBOSE1:sandbox_linux.cc(69)] Activated seccomp-bpf sandbox for process type: renderer.
[1027/051736.737166:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051737.759501:ERROR:sandbox_linux.cc(369)] InitializeSandbox() called with multiple threads in process gpu-process.
[1027/051737.901918:VERBOSE1:v8_context_snapshot.cc(153)] A context is created from snapshot for main world
[1027/051737.902583:VERBOSE1:script_context.cc(117)] Created context:
  extension id:           (none)
  frame:                  0x4e221a38
  URL:
  context_type:           WEB_PAGE
  effective extension id: (none)
  effective context type: WEB_PAGE
[1027/051737.904577:VERBOSE1:script_context.cc(117)] Created context:
  extension id:           (none)
  frame:                  (nil)
  URL:
  context_type:           UNSPECIFIED
  effective extension id: (none)
  effective context type: UNSPECIFIED
[1027/051737.905227:VERBOSE1:dispatcher.cc(353)] Num tracked contexts: 1
[1027/051737.912454:ERROR:command_buffer_proxy_impl.cc(124)] ContextResult::kTransientFailure: Failed to send GpuChannelMsg_CreateCommandBuffer.
[1027/051737.945817:VERBOSE1:gles2_cmd_decoder.cc(3788)] GL_EXT_packed_depth_stencil supported.
[1027/051737.967698:VERBOSE1:gles2_cmd_decoder.cc(3788)] GL_EXT_packed_depth_stencil supported.
[1027/051737.973991:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051737.974514:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051737.976013:VERBOSE1:simple_index_file.cc(599)] Simple Cache Index is being restored from disk.
[1027/051738.036300:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.037361:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038116:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038414:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038554:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038667:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038775:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038883:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.038988:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.039091:ERROR:paint_controller.cc(548)] PaintController::FinishCycle() completed
[1027/051738.047683:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051738.048138:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051738.058012:ERROR:batching_media_log.cc(26)] MediaEvent: MEDIA_ERROR_LOG_ENTRY {"error":"FFmpegDemuxer: no supported streams"}
[1027/051738.058484:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051738.058941:VERBOSE1:network_delegate.cc(32)] NetworkDelegate::NotifyBeforeURLRequest: http://techslides.com/demos/sample-videos/small.mp4
[1027/051738.088441:ERROR:batching_media_log.cc(26)] MediaEvent: PIPELINE_ERROR DEMUXER_ERROR_NO_SUPPORTED_STREAMS


Except the DEMUXER_ERROR_NO_SUPPORTED_STREAMS there also seem to be some GPU errors, but I am not sure if that is related.

BR
Yanick
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Sun Oct 27, 2019 12:07 pm

I have made some progress by making sure I am linking against the right version of libcef.so (I had multiple builds linked like libcef.so.1, libcef.so.2, etc) and at some time had the wrong version. In addition I have edited the ffmpeg build python script and added more stuff to the --enable-decoder --enable-parser etc flags. Now playing mp4 from a web-url works (i.E the link above). However when using a locally registered scheme this does not work. I get the following error:

Code: Select all
[1027/163800.571602:ERROR:batching_media_log.cc(26)] MediaEvent: MEDIA_ERROR_LOG_ENTRY {"error":"FFmpegDemuxer: open context failed"}
[1027/163800.572314:ERROR:batching_media_log.cc(26)] MediaEvent: PIPELINE_ERROR DEMUXER_ERROR_COULD_NOT_OPEN


It has nothing to do with my local resource loader, since everything else works (the .html itself, images like gifs, png, etc).

Is there a flag that I need to set to enable video playback from custom schemes? I have registered it like this:

Code: Select all
// also in sub process
registrar->AddCustomScheme("carpi", CEF_SCHEME_OPTION_STANDARD | CEF_SCHEME_OPTION_SECURE);

CefRegisterSchemeHandlerFactory("carpi", "", CefRefPtr<CefSchemeHandlerFactory>{new io::LocalSchemeHandler::Factory{}});
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Fri Nov 01, 2019 10:57 am

There seems to be a bug somewhere in the resource handling. Debuggin I could figure out that this is the root cause:
https://github.com/chromium/chromium/bl ... col.cc#L58

For some reason data_source_->GetSize(&file_size) yields 0 for my CefResourceHandler. Seeing as my CefResourceHandlers Read method gets called twice (so it obviously assumes my data source is not empty) and response_length in GetResponseHeaders is properly filled (verified) it seems that there is bug somewhere internally. Could this be related to the deprecation of CefResourceHandler::ProcessRequest and CefResourceHandler::ReadResponse that only shows for FFmpeg?
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby magreenblatt » Fri Nov 01, 2019 11:04 am

Does it work if you use the deprecated CefResourceHandler methods? Are you handling the Range header in your implementation?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Fri Nov 01, 2019 11:21 am

No, which kinda makes my last sentence pointless. I have added them like this (based on the method docs):
Code: Select all
    bool LocalSchemeHandler::ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback) {
        auto handle_request = false;
        return Open(request, handle_request, callback);
    }

    bool LocalSchemeHandler::ReadResponse(void *data_out, int bytes_to_read, int &bytes_read, CefRefPtr<CefCallback> callback) {
        return CefResourceHandler::ReadResponse(data_out, bytes_to_read, bytes_read, callback);
    }


To verify I have also created an embedded HTTP server that ignores all headers and just serves the same file in the exact same way and it only fills the Content-Length response header (not even Content-Type) and modified my html to use localhost:8081/camera.mp4 instead of camera.mp4. In this case the video properly displays. I have also dumped the headers in LocalSchemeHandler::Open and this is the range header: 'Range: bytes=0-' which is the same the localhost approach receives. Since the localhost version also doesn't respond with a Content-Range header this is probably not the reason, however just to be sure I have extended my GetResponseHeaders function to return such a header:
Code: Select all
headers.emplace("Content-Range", fmt::format("bytes 0-{}/{}", _file_size, _file_size));


FWIW the request sometimes shows up in the network panel of devtools, and sometimes it does not show up. You can observe this here: https://i.imgur.com/mPlXcbz.png The first request to test.html did not show up loading a 'camera.mp4' while after a location.reload() it did show up. Maybe the same way I did you might find the 'Content-Length: 0' suspicious, since this is consistent with the AVERROR_EOF case this can hardly come from my code because it is 0 even if I do this:
Code: Select all
headers.emplace("Content-Length", fmt::format("{}", _file_size));


And as you can see the Content-Range header is filled properly, so my _file_size variable is obviously not 0. Also other requests over the same protocol have a proper content length: https://i.imgur.com/eY804Ko.png
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Fri Nov 01, 2019 11:24 am

I only noticed after posting, I didn't actually implment the ReadResponse method, so I did this:
Code: Select all
    bool LocalSchemeHandler::ReadResponse(void *data_out, int bytes_to_read, int &bytes_read, CefRefPtr<CefCallback> callback) {
        return Read(data_out, bytes_to_read, bytes_read, nullptr);
    }


This didn't change anything (it does not get called).
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby magreenblatt » Fri Nov 01, 2019 11:50 am

I would suggest starting with an existing example of CefResourceHandler usage, and verifying that it works with simple content like HTML pages.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Fri Nov 01, 2019 12:07 pm

The same implementation that provides the video is also providing the html page loading the video (second screenshot). I have also verified that it is not something size related by providing a gif image that is larger than the video, it also properly loads. Everything is loaded over the same CefResourceHandler implementation, everything works except the video.

For the sake of completeness I have also completed removed my resource handling and used the built in stream handlers:
Code: Select all
        const auto extension = file_path.extension().string();

        const auto path = canonical(absolute(target_path)).string();

        auto stream_handler = CefStreamReader::CreateForFile(path);
        const auto mime_type = CefGetMimeType(!extension.empty() ? extension.substr(1) : extension);
        return new CefStreamResourceHandler(mime_type.empty() ? "text/plain" : mime_type, stream_handler);


Same result. It is also not limited to mp4. Tried an .ogg video and same result. As soon as FFmpeg is involved it no longer works.
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby ebahar » Fri Nov 08, 2019 1:59 am

Hi,
i'm having the same issue
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17200

worked fine before network-service introduced.

@yanicks90,

have you found a solution for this?

thanks,
ebahar
Techie
 
Posts: 46
Joined: Tue Nov 22, 2016 3:52 am

Re: MP4 on ARM not working with proprietary codecs enabled

Postby yanicks90 » Sat Nov 09, 2019 2:15 pm

Seeing as the out of the box solution of CEF (CefStreamReader) didn't fix the problem and the absence of support I decided to switch to converting stuff via libyuv myself and streaming it via shared memory to the render process and then rendering it with WebGL myself. No idea why I have to to jump through such hoops but I guess thats the chromium experience... ¯\_(ツ)_/¯
yanicks90
Techie
 
Posts: 19
Joined: Sat Oct 26, 2019 11:03 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 73 guests