Hand-apply 6a3cd511559433554ab40ed72ff94b7d8dc2c5bd from master;
[dcpomatic.git] / src / lib / ffmpeg_examiner.cc
index 48d85da6f11113cb6cabc83215505c8df766110a..1d01981f60c80dd55dc19f185bc8fda2b3e0dfe0 100644 (file)
@@ -156,7 +156,7 @@ FFmpegExaminer::frame_time (AVStream* s) const
        return t;
 }
 
-float
+optional<float>
 FFmpegExaminer::video_frame_rate () const
 {
        /* This use of r_frame_rate is debateable; there's a few different
@@ -180,6 +180,17 @@ FFmpegExaminer::video_length () const
        return ContentTime (max (ContentTime::Type (1), length.get ()));
 }
 
+optional<float>
+FFmpegExaminer::sample_aspect_ratio () const
+{
+       AVRational sar = av_guess_sample_aspect_ratio (_format_context, _format_context->streams[_video_stream], 0);
+       if (sar.num == 0) {
+               /* I assume this means that we don't know */
+               return optional<float> ();
+       }
+       return float (sar.num) / sar.den;
+}
+
 string
 FFmpegExaminer::audio_stream_name (AVStream* s) const
 {