Skip to content

Commit

Permalink
Merge pull request #13 from slateteams/feat/add-color-attributes
Browse files Browse the repository at this point in the history
feat: add color properties to WebAVStream
  • Loading branch information
ForeverSc authored Oct 10, 2024
2 parents 1b45fc8 + a9d6727 commit 96f474a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ Get the media information of a file, the output is referenced from `ffprobe`
"codec_type_string": "video",
"codec_name": "h264",
"codec_string": "avc1.640032",
"color_primaries": "bt2020",
"color_range": "tv",
"color_space": "bt2020nc",
"color_transfer": "arib-std-b67",
"profile": "High",
"pix_fmt": "yuv420p",
"level": 50,
Expand Down
4 changes: 4 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ getMediaInfo(): Promise<WebMediaInfo> // 2.0新增
"codec_type_string": "video",
"codec_name": "h264",
"codec_string": "avc1.640032",
"color_primaries": "bt2020",
"color_range": "tv",
"color_space": "bt2020nc",
"color_transfer": "arib-std-b67",
"profile": "High",
"pix_fmt": "yuv420p",
"level": 50,
Expand Down
4 changes: 4 additions & 0 deletions lib/web-demuxer/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ function avStreamToObject(avStream) {
codec_type_string: avStream.codec_type_string,
codec_name: avStream.codec_name,
codec_string: avStream.codec_string,
color_primaries: avStream.color_primaries,
color_transfer: avStream.color_transfer,
color_space: avStream.color_space,
color_range: avStream.color_range,
profile: avStream.profile,
pix_fmt: avStream.pix_fmt,
level: avStream.level,
Expand Down
15 changes: 14 additions & 1 deletion lib/web-demuxer/web_demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ typedef struct WebAVStream
std::string codec_string;
std::string profile;
std::string pix_fmt;
std::string color_primaries;
std::string color_transfer;
std::string color_space;
std::string color_range;
int level;
int width;
int height;
Expand Down Expand Up @@ -153,6 +157,10 @@ void gen_web_stream(WebAVStream &web_stream, AVStream *stream, AVFormatContext *

if (par->codec_type == AVMEDIA_TYPE_VIDEO)
{
web_stream.color_primaries = av_color_primaries_name(par->color_primaries);
web_stream.color_transfer = av_color_transfer_name(par->color_trc);
web_stream.color_space = av_color_space_name(par->color_space);
web_stream.color_range = av_color_range_name(par->color_range);
set_video_codec_string(codec_string, sizeof(codec_string), par, &stream->avg_frame_rate);
}
else if (par->codec_type == AVMEDIA_TYPE_AUDIO)
Expand Down Expand Up @@ -633,7 +641,12 @@ EMSCRIPTEN_BINDINGS(web_demuxer)
.property("duration", &WebAVStream::duration)
.property("rotation", &WebAVStream::rotation)
.property("nb_frames", &WebAVStream::nb_frames)
.property("tags", &WebAVStream::tags);
.property("tags", &WebAVStream::tags)
.property("color_primaries", &WebAVStream::color_primaries)
.property("color_transfer", &WebAVStream::color_transfer)
.property("color_space", &WebAVStream::color_space)
.property("color_range", &WebAVStream::color_range);


value_object<WebAVStreamList>("WebAVStreamList")
.field("size", &WebAVStreamList::size)
Expand Down
4 changes: 4 additions & 0 deletions src/types/demuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export interface WebAVStream {
codec_type_string: string;
codec_name: string;
codec_string: string;
color_primaries: string;
color_range: string;
color_space: string;
color_transfer: string;
profile: string;
pix_fmt: string;
level: number;
Expand Down

0 comments on commit 96f474a

Please sign in to comment.