diff --git a/README.md b/README.md index 09e9b71..fc97796 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/README_CN.md b/README_CN.md index fbba8c8..8568a32 100644 --- a/README_CN.md +++ b/README_CN.md @@ -188,6 +188,10 @@ getMediaInfo(): Promise // 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, diff --git a/lib/web-demuxer/post.js b/lib/web-demuxer/post.js index e1b5636..4ab86f0 100644 --- a/lib/web-demuxer/post.js +++ b/lib/web-demuxer/post.js @@ -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, diff --git a/lib/web-demuxer/web_demuxer.cpp b/lib/web-demuxer/web_demuxer.cpp index 788d55c..74bc727 100644 --- a/lib/web-demuxer/web_demuxer.cpp +++ b/lib/web-demuxer/web_demuxer.cpp @@ -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; @@ -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) @@ -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") .field("size", &WebAVStreamList::size) diff --git a/src/types/demuxer.ts b/src/types/demuxer.ts index 7da78be..8ceec93 100644 --- a/src/types/demuxer.ts +++ b/src/types/demuxer.ts @@ -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;