Skip to content
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

Small video-related cleanups #8118

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/store/re_types/src/archetypes/asset_video_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl AssetVideo {
/// Returned timestamps are in nanoseconds since start and are guaranteed to be monotonically increasing.
#[cfg(feature = "video")]
pub fn read_frame_timestamps_ns(&self) -> Result<Vec<i64>, re_video::VideoLoadError> {
re_tracing::profile_function!();

let Some(media_type) = self
.media_type
.clone()
Expand Down
5 changes: 3 additions & 2 deletions crates/store/re_video/src/decode/ffmpeg_h264/ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ fn write_ffmpeg_input(
.concat();
write_bytes(ffmpeg_stdin, &end_nals).ok();

// NOTE(emilk): I've also tried writing `NalUnitType::AccessUnitDelimiter` here, but to no avail.

ffmpeg_stdin.flush().ok();

break;
Expand Down Expand Up @@ -1011,8 +1013,7 @@ fn should_ignore_log_msg(msg: &str) -> bool {
// Size etc. *is* specified in SPS & PPS, unclear why it's missing that.
// Observed on Windows FFmpeg 7.1, but not with the same version on Mac with the same video.
"Could not find codec parameters for stream 0 (Video: h264, none): unspecified size",
// We sometimes get a `[NULL @ 0x14f107150]`, which is not very actionable
"[NULL @ ",
// NOTE: We sometimes get a `[NULL @ 0x14f107150]`, which is not very actionable, but may be useful for debugging.
];

// Why would we get an empty message? Observed on Windows FFmpeg 7.1.
Expand Down
2 changes: 2 additions & 0 deletions crates/store/re_video/src/decode/ffmpeg_h264/sps.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! TODO(emilk): replace this whole file with <https://docs.rs/h264-reader/latest/h264_reader/nal/sps/struct.SeqParameterSet.html>

use crate::decode::YuvPixelLayout;

use super::nalu::{NalHeader, NalUnitType};
Expand Down
14 changes: 11 additions & 3 deletions crates/viewer/re_renderer/src/video/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ impl VideoPlayer {
let presentation_timestamp = presentation_timestamp.min(self.data.duration); // Don't seek past the end of the video.

let error_on_last_frame_at = self.last_error.is_some();
self.frame_at_internal(render_ctx, presentation_timestamp, video_data)?;
self.unqueue_samples(presentation_timestamp, video_data)?;
self.update_video_texture(render_ctx, presentation_timestamp)?;

let frame_info = self.video_texture.frame_info.clone();

Expand Down Expand Up @@ -181,9 +182,8 @@ impl VideoPlayer {
}
}

fn frame_at_internal(
fn unqueue_samples(
emilk marked this conversation as resolved.
Show resolved Hide resolved
&mut self,
render_ctx: &RenderContext,
presentation_timestamp: Time,
video_data: &[u8],
) -> Result<(), VideoPlayerError> {
Expand Down Expand Up @@ -279,6 +279,14 @@ impl VideoPlayer {
self.current_gop_idx = requested_gop_idx;
self.current_sample_idx = requested_sample_idx;

Ok(())
}

fn update_video_texture(
&mut self,
render_ctx: &RenderContext,
presentation_timestamp: Time,
) -> Result<(), VideoPlayerError> {
let result = self.chunk_decoder.update_video_texture(
render_ctx,
&mut self.video_texture,
Expand Down
Loading