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

Support HEVC/H.265 video with hev1 flavor (in addition to hvc1) #7569

Merged
merged 6 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5272,7 +5272,7 @@ dependencies = [
[[package]]
name = "re_mp4"
version = "0.1.0"
source = "git+https://github.com/rerun-io/re_mp4?rev=3236c76f9228cf6ab0b2bfb1b8f9ffcde975ea05#3236c76f9228cf6ab0b2bfb1b8f9ffcde975ea05"
source = "git+https://github.com/rerun-io/re_mp4?rev=4705e85f62ddb47c32d9c091d8f0662068211bc8#4705e85f62ddb47c32d9c091d8f0662068211bc8"
dependencies = [
"byteorder",
"bytes",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ missing_errors_doc = "allow"

# commit on `rerun-io/mp4` `master` branch: https://github.com/rerun-io/re_mp4/tree/master
# https://github.com/rerun-io/mp4/commit/3236c76f9228cf6ab0b2bfb1b8f9ffcde975ea05
re_mp4 = { git = "https://github.com/rerun-io/re_mp4", rev = "3236c76f9228cf6ab0b2bfb1b8f9ffcde975ea05" }
re_mp4 = { git = "https://github.com/rerun-io/re_mp4", rev = "4705e85f62ddb47c32d9c091d8f0662068211bc8" }

# commit on `rerun-io/re_arrow2` `main` branch
# https://github.com/rerun-io/re_arrow2/commit/e4717d6debc6d4474ec10db8f629f823f57bad07
Expand Down
7 changes: 5 additions & 2 deletions crates/store/re_video/src/mp4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use super::{Config, Sample, Segment, Time, Timescale, VideoData, VideoLoadError};

pub fn load_mp4(bytes: &[u8]) -> Result<VideoData, VideoLoadError> {
let mp4 = re_mp4::read(bytes)?;
let mp4 = re_mp4::Mp4::read_bytes(bytes)?;

let mp4_tracks = mp4.tracks().iter().map(|(k, t)| (*k, t.kind)).collect();

Expand Down Expand Up @@ -86,7 +86,10 @@ pub fn load_mp4(bytes: &[u8]) -> Result<VideoData, VideoLoadError> {

fn unknown_codec_fourcc(mp4: &re_mp4::Mp4, track: &re_mp4::Track) -> re_mp4::FourCC {
let stsd = &track.trak(mp4).mdia.minf.stbl.stsd;
stsd.unknown.first().copied().unwrap_or_default()
match &stsd.contents {
re_mp4::StsdBoxContent::Unknown(four_cc) => *four_cc,
_ => Default::default(),
}
}

/// Returns whether a buffer is MP4 video data.
Expand Down
18 changes: 12 additions & 6 deletions docs/content/reference/video.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ Video playback is done using the browser's own video decoder, so the supported c

Overall, we recommend using Chrome or another Chromium-based browser, as it seems to have the best video support as of writing.

When choosing a codec, we recommend [AV1](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs#av1), as that seems to have the best overall playback support. Since AV1 is patent-free, it is also likely the first codec we will support in the native viewer.
When choosing a codec, we recommend [AV1](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs#av1),
as it seems to have the best overall playback support while also having very high compression quality.
Since AV1 is patent-free, it is also likely the first codec we will support in the native viewer.

For decoding video in the Web Viewer, we use the [WebCodecs API](https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API).
This API enables us to take advantage of the browser's hardware accelerated video decoding capabilities.
It is implemented by all modern browsers, but with varying levels of support for different codecs, and varying levels of quality.

With that in mind, here are the browsers which we have tested and verified to work:
With that in mind, here are the browsers which we have tested and verified to generally work:

| | Linux | macOS | Windows |
| ---------- | ------ | ----- | ------- |
Expand All @@ -64,12 +66,16 @@ which codecs are supported by which browser, see [Video codecs on MDN](https://d

At the moment, we test the following codecs:

| | Linux | macOS | Windows |
| ----- | ----- | ------- | ------- |
| AV1 | ✅ | 🚧[^4] | ✅ |
| H.264 | ✅ | ✅ | ✅ |
| | Linux Firefox | Linux Chrome | macOS Firefox | macOS Chrome | macOS Safari | Windows Firefox | Windows Chrome |
| ---------- | ------------- | ------------ | ------------- | ------------ | ------------ | --------------- | -------------- |
| AV1 | ✅ | ✅ | ✅ | ✅ | 🚧[^4] | ✅ | ✅ |
| H.264/avc | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| H.265/hevc | ❌ | ❌ | ❌ | ✅ | 🚧[^6] | ❌ | 🚧[^7] |

[^4]: Safari/WebKit does not support AV1 decoding except on [Apple Silicon devices with hardware support](https://webkit.org/blog/14445/webkit-features-in-safari-17-0/).
[^5]: Firefox does not support H.265 decoding on any platform.
[^6]: Safari/WebKit has been observed suttering when playing `hvc1` but working fine with `hevc1`. Despite support being advertised Safari 16.5 has been observed not support H.265 decoding.
[^7]: Only supported if hardware encoding is available. Therefore always affected by Windows stuttering issues, see [^3].

## Links
* [Web video codec guide, by Mozilla](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs)
Loading