Debian Codegraph @

cvd/videowriter.h

raw symbols SCIP
1 #ifndef LIBCVD_VIDEOWRITER_H
2 #define LIBCVD_VIDEOWRITER_H
3
4 #include "image.h"
5 #include "rgba.h"
6 #include "videoffmpeg.h"
7
8 #include <libavutil/rational.h>
9
10 #include <cmath>
11 #include <cstdint>
12 #include <memory>
13 #include <string>
14 #include <utility>
15
16 namespace CVD
17 {
18 namespace internal
19 {
20 class Scaler;
21 }
22
23 // Simple video writer to write RGBA frames to a video file.
24 class VideoWriter
25 {
26 public:
27 VideoWriter(const std::string& filename,
28 const std::string& codec_name,
29 const std::string& pixel_format_name,
30 AVRational timebase,
31 AVRational frame_rate,
32 int rotation_degrees,
33 int threads,
34 int bitrate = -1,
35 std::int64_t duration = -1);
36 ~VideoWriter();
37
38 std::int64_t seconds_to_timebase(double seconds) const
39 {
40 return static_cast<std::int64_t>(std::round((seconds * m_timebase.den) / m_timebase.num));
41 }
42 void put_frame(const BasicImage<Rgba<std::uint8_t>>& image, std::int64_t pts);
43
44 private:
45 std::string m_filename;
46 AVRational m_timebase;
47 int m_threads;
48 const AVCodec* m_codec;
49 int m_bitrate;
50 std::unique_ptr<AVFormatContext, internal::AVFormatContextCloser> m_format_context;
51 std::unique_ptr<AVCodecContext, internal::AVCodecContextCloser> m_codec_context;
52 std::unique_ptr<internal::Scaler> m_scaler;
53 };
54
55 }
56
57 #endif