Skip to content

Commit

Permalink
Merge pull request #3 from amazon-contributing/ruwen/webvtt-with-av1
Browse files Browse the repository at this point in the history
Add av1 support
  • Loading branch information
palana authored Jan 22, 2025
2 parents 83322fc + c190fb0 commit 6dbc4c8
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 19 deletions.
9 changes: 8 additions & 1 deletion deps/c-webvtt-in-video-stream/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions deps/c-webvtt-in-video-stream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
};
use strum_macros::FromRepr;
use video_bytestream_tools::{
av1,
h264::{self, H264ByteStreamWrite, H264NalHeader},
h265::{self, H265ByteStreamWrite, H265NalHeader},
h26x::{NalUnitWrite, RbspWrite},
Expand Down Expand Up @@ -106,6 +107,7 @@ enum CodecFlavor {
H264Avcc4,
H264AnnexB,
H265AnnexB,
AV1OBUs,
}

impl CodecFlavor {
Expand All @@ -116,6 +118,7 @@ impl CodecFlavor {
CodecFlavor::H264Avcc4 => CodecFlavorInternal::H264(CodecFlavorH264::Avcc(4)),
CodecFlavor::H264AnnexB => CodecFlavorInternal::H264(CodecFlavorH264::AnnexB),
CodecFlavor::H265AnnexB => CodecFlavorInternal::H265(CodecFlavorH265::AnnexB),
CodecFlavor::AV1OBUs => CodecFlavorInternal::AV1,
}
}
}
Expand All @@ -132,6 +135,7 @@ enum CodecFlavorH265 {
enum CodecFlavorInternal {
H264(CodecFlavorH264),
H265(CodecFlavorH265),
AV1,
}

pub struct WebvttBuffer(Vec<u8>);
Expand Down Expand Up @@ -228,6 +232,16 @@ pub extern "C" fn webvtt_muxer_try_mux_into_bytestream(
},
)
.ok()?,

CodecFlavorInternal::AV1 => mux_into_bytestream(
muxer,
video_timestamp,
add_header,
&mut buffer,
|buffer| Ok(av1::OBUWriter::new(buffer)),
|_write| Ok(()),
)
.ok()?,
};
if !data_written {
return None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ name = "video-bytestream-tools"
version = "0.1.0"

[dependencies]
bitstream-io = "2.6.0"
byteorder = "1.5.0"
h264-reader = "0.7.0"
thiserror = "2.0.4"
Expand Down
Loading

0 comments on commit 6dbc4c8

Please sign in to comment.