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