-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video without autoplay doesn't show up #31666
Comments
So basically you want the reason why is this happening right? No code is required right? |
This issue can only be closed when videos that do not have the autoplay attribute are rendered correctly. That will require code changes. |
I just spent some time looking into this, for anyone else interested in this issue, here's some things that I thought might be of note to someone working on this issue (not exhaustive but maybe it is helpful to someone):
https://html.spec.whatwg.org/multipage/media.html#the-video-element:the-video-element-9
<video poster="https://placehold.co/500x500.jpg">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
<p>Video not supported</p>
</video> Note that even then, before the video is loaded, it is not displayed.
<video>
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4">
<p>Video not supported</p>
</video>
<script>
setTimeout(() => {
document.querySelector('video').play();
}, 1000);
</script>
|
@RustAndMetal thank you so much for the insight! I did some testing and it seems that #31746 addresses some of the issues. However, it still doesn't show the first frame of the video as the placeholder. Here's a comparison: Current behaviour: With #31746: Testing with: <!DOCTYPE html>
<body>
<video style="border: 1px solid red">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4"/>
<p>Video not supported</p>
</video>
<video autoplay style="border: 1px solid blue">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4"/>
<p>Video not supported</p>
</video>
<video poster="https://placehold.co/500x500.jpg" style="border: 1px solid yellow">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4"/>
<p>Video not supported</p>
</video>
<video width="400" style="border: 1px solid green">
<source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" type="video/mp4"/>
<p>Video not supported</p>
</video>
</body> The videos are definitely loading and the size is set correctly (the red rectangle is the same as the blue one, the other two are different because either the poster sets the size or the default width was modified). I'll take a look at the code tomorrow to see if I can get the first frame to render by default. |
Update: I have been looking into this and going into servo-media and gstreamer code. One way this could be solved is by adding a function to servo-media's Inside this function we could call fn request_frame(&self) -> Result<(), PlayerError> {
let inner = self.inner.borrow();
let mut inner = inner.as_ref().unwrap().lock().unwrap();
let Some(sample) = inner.player.video_snapshot(...) else {
return Err(...);
};
let Ok(frame) = self.render.lock().unwrap().get_frame_from_sample(sample) else {
return Err(...);
};
if let Some(video_renderer) = &self.video_renderer {
video_renderer.lock().unwrap().render(frame);
}
Ok(())
} The new function could be called somewhere around here, when
when calling g_object_get (self->playbin, "n-video", &video_tracks, NULL); // This crashes
if (video_tracks == 0) {
GST_DEBUG_OBJECT (self, "total video track num is 0");
return NULL;
} I'll try to diagnose the 'n-video' error and get this working, but if anyone that is familiar with gstreamer has any pointers they are greatly appreciated! |
I can't provide any gstreamer assistance, but that all sounds pretty reasonable to me! |
I have a working proof of concept for this! The critical error was coming directly from a GStreamer regression on the latest version, I opened a pr there (https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6516). I also had to find another place from where to call The implementation still needs a bit of cleanup, as well as handling some details like asking The change will require two prs, one in servo/media that adds the |
Hi @eerii Thanks for your hard work. Your proposal of a video snapshot is interesting and it looks to solve the issue. But I wonder how required is too add new code for that. As you already found out, in a GStreamer pipeline, before passing to PLAYING state, it has to change first to PAUSED state, and in to reach PAUSED state, all sinks have to receive a buffer, this operation is known as preroll. So, as far as I remember, when the GStreamer's pipeline pass to PAUSED, the All I'm saying that perhaps it's a bug to fix rather than a workaround to add. Not sure, though. |
Thank you so much for all the information, the page on preroll was very useful.
This makes a lot of sense, I observed that Returns (GstSample *) – a GstSample of the current video frame converted to caps. The caps on the sample will describe the final layout of the buffer data. NULL is returned when no current buffer can be retrieved or when the conversion failed. Additionally, if no
I'll look closely into the code to see if it's supposed to be rendered somewhere already. As far as I could tell before, the buffer was loaded but no calls to render were made, but I'll review the comments and todos just in case. There needs to be a place where we render this initial frame, maybe it can be done directly on servo/media when the video first enters the PAUSED state, I'll look into it. Thank you a lot! |
You were right! In |
I created a new pr in servo/media which renders the first frame on the preroll callback. There are two issues but they need to be resolved in this repo:
|
The following example:
Shows Video not supported.
However simply adding
autoplay
makes the video to show and play properly:Maybe this is a known/duplicated issue, sorry if that's the case.
The text was updated successfully, but these errors were encountered: