encoder.h 696 Bytes
Newer Older
1
2
#pragma once

3
4
#include <libtorio/ffmpeg/ffmpeg.h>
#include <libtorio/ffmpeg/filter_graph.h>
5
6
#include <torch/types.h>

moto-meta's avatar
moto-meta committed
7
namespace torio::io {
8
9
10
11
12
13
14

// Encoder + Muxer
class Encoder {
  // Reference to the AVFormatContext (muxer)
  AVFormatContext* format_ctx;
  // Reference to codec context (encoder)
  AVCodecContext* codec_ctx;
15
  // Stream object as reference. Owned by AVFormatContext.
16
17
18
  AVStream* stream;
  // Temporary object used during the encoding
  // Encoder owns it.
19
  AVPacketPtr packet{alloc_avpacket()};
20
21

 public:
22
23
24
25
  Encoder(
      AVFormatContext* format_ctx,
      AVCodecContext* codec_ctx,
      AVStream* stream) noexcept;
26
27
28
29

  void encode(AVFrame* frame);
};

moto-meta's avatar
moto-meta committed
30
} // namespace torio::io