Populate stream-specific fields into an existing FileMetadata.
Appends codec name, pixel format, dimensions, frame rate, bit_rate, etc.
- Parameters
-
| demux | The demux context that owns the format_context. |
| out | Metadata struct to append into. |
Definition at line 397 of file VideoStreamContext.cpp.
399{
401 return;
402
403 out.attributes[
"video_codec"] = std::string(avcodec_get_name(
codec_context->codec_id));
405 out.attributes[
"video_codec_long_name"] = std::string(
codec_context->codec->long_name);
406 out.attributes[
"video_width"] =
width;
407 out.attributes[
"video_height"] =
height;
408 out.attributes[
"video_frame_rate"] =
frame_rate;
411
412 const char* pix_fmt_name = av_get_pix_fmt_name(
codec_context->pix_fmt);
413 if (pix_fmt_name)
414 out.attributes["video_pixel_format"] = std::string(pix_fmt_name);
415
417 out.attributes[
"video_color_range"] =
static_cast<int>(
codec_context->color_range);
419 out.attributes[
"video_colorspace"] =
static_cast<int>(
codec_context->colorspace);
421 out.attributes[
"video_color_trc"] =
static_cast<int>(
codec_context->color_trc);
423 out.attributes[
"video_color_primaries"] =
static_cast<int>(
codec_context->color_primaries);
424
427 return;
428
429 if (
stream->sample_aspect_ratio.num > 0 &&
stream->sample_aspect_ratio.den > 0) {
430 out.attributes[
"video_sar_num"] =
stream->sample_aspect_ratio.num;
431 out.attributes[
"video_sar_den"] =
stream->sample_aspect_ratio.den;
432 }
433
434 AVDictionaryEntry* tag = nullptr;
435 while ((tag = av_dict_get(
stream->metadata,
"", tag, AV_DICT_IGNORE_SUFFIX)))
436 out.attributes[std::string("video_stream_") + tag->key] = std::string(tag->value);
437}
Core::GlobalStreamInfo stream
double frame_rate
Average frame rate (fps).
uint32_t height
Source height in pixels.
uint32_t width
Source width in pixels.
AVCodecContext * codec_context
Owned; freed in destructor.
References MayaFlux::IO::FileMetadata::attributes, codec_context, frame_rate, MayaFlux::IO::FFmpegDemuxContext::get_stream(), height, stream, stream_index, total_frames, and width.