Appends codec name, pixel format, dimensions, frame rate, bit_rate, etc.
394{
396 return;
397
398 out.attributes[
"video_codec"] = std::string(avcodec_get_name(
codec_context->codec_id));
400 out.attributes[
"video_codec_long_name"] = std::string(
codec_context->codec->long_name);
401 out.attributes[
"video_width"] =
width;
402 out.attributes[
"video_height"] =
height;
403 out.attributes[
"video_frame_rate"] =
frame_rate;
406
407 const char* pix_fmt_name = av_get_pix_fmt_name(
codec_context->pix_fmt);
408 if (pix_fmt_name)
409 out.attributes["video_pixel_format"] = std::string(pix_fmt_name);
410
412 out.attributes[
"video_color_range"] =
static_cast<int>(
codec_context->color_range);
414 out.attributes[
"video_colorspace"] =
static_cast<int>(
codec_context->colorspace);
416 out.attributes[
"video_color_trc"] =
static_cast<int>(
codec_context->color_trc);
418 out.attributes[
"video_color_primaries"] =
static_cast<int>(
codec_context->color_primaries);
419
421 if (!stream)
422 return;
423
424 if (stream->sample_aspect_ratio.num > 0 && stream->sample_aspect_ratio.den > 0) {
425 out.attributes["video_sar_num"] = stream->sample_aspect_ratio.num;
426 out.attributes["video_sar_den"] = stream->sample_aspect_ratio.den;
427 }
428
429 AVDictionaryEntry* tag = nullptr;
430 while ((tag = av_dict_get(stream->metadata, "", tag, AV_DICT_IGNORE_SUFFIX)))
431 out.attributes[std::string("video_stream_") + tag->key] = std::string(tag->value);
432}
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.