Changeset View
Changeset View
Standalone View
Standalone View
src/extractors/ffmpegextractor.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | |||||
103 | #else | 103 | #else | ||
104 | const AVCodecContext* codec = stream->codec; | 104 | const AVCodecContext* codec = stream->codec; | ||
105 | #endif | 105 | #endif | ||
106 | 106 | | |||
107 | if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { | 107 | if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { | ||
108 | result->add(Property::Width, codec->width); | 108 | result->add(Property::Width, codec->width); | ||
109 | result->add(Property::Height, codec->height); | 109 | result->add(Property::Height, codec->height); | ||
110 | 110 | | |||
111 | AVRational avSampleAspectRatio = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); | 111 | AVRational avSampleAspectRatio = av_guess_sample_aspect_ratio(fmt_ctx, stream, nullptr); | ||
112 | AVRational avDisplayAspectRatio; | 112 | AVRational avDisplayAspectRatio; | ||
113 | av_reduce(&avDisplayAspectRatio.num, &avDisplayAspectRatio.den, | 113 | av_reduce(&avDisplayAspectRatio.num, &avDisplayAspectRatio.den, | ||
114 | codec->width * avSampleAspectRatio.num, | 114 | codec->width * avSampleAspectRatio.num, | ||
115 | codec->height * avSampleAspectRatio.den, | 115 | codec->height * avSampleAspectRatio.den, | ||
116 | 1024*1024); | 116 | 1024*1024); | ||
117 | double displayAspectRatio = avDisplayAspectRatio.num; | 117 | double displayAspectRatio = avDisplayAspectRatio.num; | ||
118 | if (avDisplayAspectRatio.den) | 118 | if (avDisplayAspectRatio.den) | ||
119 | displayAspectRatio /= avDisplayAspectRatio.den; | 119 | displayAspectRatio /= avDisplayAspectRatio.den; | ||
120 | if (displayAspectRatio) | 120 | if (displayAspectRatio) | ||
121 | result->add(Property::AspectRatio, displayAspectRatio); | 121 | result->add(Property::AspectRatio, displayAspectRatio); | ||
122 | 122 | | |||
123 | AVRational avFrameRate = av_guess_frame_rate(fmt_ctx, stream, NULL); | 123 | AVRational avFrameRate = av_guess_frame_rate(fmt_ctx, stream, nullptr); | ||
124 | double frameRate = avFrameRate.num; | 124 | double frameRate = avFrameRate.num; | ||
125 | if (avFrameRate.den) | 125 | if (avFrameRate.den) | ||
126 | frameRate /= avFrameRate.den; | 126 | frameRate /= avFrameRate.den; | ||
127 | if (frameRate) | 127 | if (frameRate) | ||
128 | result->add(Property::FrameRate, frameRate); | 128 | result->add(Property::FrameRate, frameRate); | ||
129 | } | 129 | } | ||
130 | } | 130 | } | ||
131 | 131 | | |||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |