extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
+#include <libavutil/pixfmt.h>
+#include <libavutil/pixdesc.h>
}
#include "ffmpeg_examiner.h"
#include "ffmpeg_content.h"
if (_need_video_length) {
_video_length = frame_time (
_format_context->streams[_video_stream]
- ).get_value_or (ContentTime ()).frames (video_frame_rate().get ());
+ ).get_value_or (ContentTime ()).frames_round (video_frame_rate().get ());
}
}
}
return t;
}
-optional<float>
+optional<double>
FFmpegExaminer::video_frame_rate () const
{
/* This use of r_frame_rate is debateable; there's a few different
return max (Frame (1), _video_length);
}
-optional<float>
+optional<double>
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 optional<double> ();
}
- return float (sar.num) / sar.den;
+ return double (sar.num) / sar.den;
}
string
return n.str ();
}
+
+int
+FFmpegExaminer::bits_per_pixel () const
+{
+ return av_get_bits_per_pixel (av_pix_fmt_desc_get (video_codec_context()->pix_fmt));
+}