Changeset View
Changeset View
Standalone View
Standalone View
src/extractors/ffmpegextractor.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 70 | { | |||
---|---|---|---|---|---|
90 | 90 | | |||
91 | int totalSecs = fmt_ctx->duration / AV_TIME_BASE; | 91 | int totalSecs = fmt_ctx->duration / AV_TIME_BASE; | ||
92 | int bitrate = fmt_ctx->bit_rate; | 92 | int bitrate = fmt_ctx->bit_rate; | ||
93 | 93 | | |||
94 | result->add(Property::Duration, totalSecs); | 94 | result->add(Property::Duration, totalSecs); | ||
95 | result->add(Property::BitRate, bitrate); | 95 | result->add(Property::BitRate, bitrate); | ||
96 | 96 | | |||
97 | for (uint i = 0; i < fmt_ctx->nb_streams; i++) { | 97 | for (uint i = 0; i < fmt_ctx->nb_streams; i++) { | ||
98 | const AVStream* stream = fmt_ctx->streams[i]; | 98 | AVStream* stream = fmt_ctx->streams[i]; | ||
99 | #if defined HAVE_AVSTREAM_CODECPAR && HAVE_AVSTREAM_CODECPAR | 99 | #if defined HAVE_AVSTREAM_CODECPAR && HAVE_AVSTREAM_CODECPAR | ||
100 | const AVCodecParameters* codec = stream->codecpar; | 100 | const AVCodecParameters* codec = stream->codecpar; | ||
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 | int aspectRatio = codec->sample_aspect_ratio.num; | ||
110 | if (codec->sample_aspect_ratio.den) | 110 | if (codec->sample_aspect_ratio.den) | ||
111 | aspectRatio /= codec->sample_aspect_ratio.den; | 111 | aspectRatio /= codec->sample_aspect_ratio.den; | ||
112 | if (aspectRatio) | 112 | if (aspectRatio) | ||
113 | result->add(Property::AspectRatio, aspectRatio); | 113 | result->add(Property::AspectRatio, aspectRatio); | ||
114 | 114 | | |||
115 | int frameRate = stream->avg_frame_rate.num; | 115 | AVRational avFrameRate = av_guess_frame_rate(fmt_ctx, stream, NULL); | ||
116 | if (stream->avg_frame_rate.den) | 116 | double frameRate = avFrameRate.num; | ||
117 | frameRate /= stream->avg_frame_rate.den; | 117 | if (avFrameRate.den) | ||
118 | frameRate /= avFrameRate.den; | ||||
118 | if (frameRate) | 119 | if (frameRate) | ||
119 | result->add(Property::FrameRate, frameRate); | 120 | result->add(Property::FrameRate, frameRate); | ||
120 | } | 121 | } | ||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | AVDictionary* dict = fmt_ctx->metadata; | 124 | AVDictionary* dict = fmt_ctx->metadata; | ||
124 | AVDictionaryEntry* entry; | 125 | AVDictionaryEntry* entry; | ||
125 | 126 | | |||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |