FfmpegVideoSampler.h 695 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include "FfmpegSampler.h"

/**
 * Class transcode video frames from one format into another
 */

class FfmpegVideoSampler : public FfmpegSampler {
 public:
  explicit FfmpegVideoSampler(
      const VideoFormat& in,
      const VideoFormat& out,
      int swsFlags = SWS_AREA);
  ~FfmpegVideoSampler() override;

  int init() override;

  int32_t getImageBytes() const;
  // returns number of bytes of the sampled data
  std::unique_ptr<DecodedFrame> sample(const AVFrame* frame) override;

  const VideoFormat& getInFormat() const {
    return inFormat_;
  }

 private:
  VideoFormat inFormat_;
  VideoFormat outFormat_;
  int swsFlags_;
  SwsContext* scaleContext_{nullptr};
};