candlewick 0.7.0-59-g23c6
A tiny cross-platform renderer based on SDL3
Loading...
Searching...
No Matches
VideoRecorder.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef CANDLEWICK_WITH_FFMPEG_SUPPORT
4#error "Including this file requires candlewick to be built with FFmpeg support"
5#endif
6#include "../core/Core.h"
7#include "../core/Tags.h"
8
9#include <SDL3/SDL_gpu.h>
10#include <SDL3/SDL_stdinc.h>
11#include <memory>
12
13namespace candlewick {
14namespace media {
15
16 struct VideoRecorderImpl;
17
19
21 std::unique_ptr<VideoRecorderImpl> m_impl;
22 Uint32 m_width;
23 Uint32 m_height;
24
25 public:
26 struct Settings {
27 int fps = 30;
28 // default: 2.5 Mb/s
29 int bitRate = 2'500'000u;
30 int outputWidth = 0;
31 int outputHeight = 0;
32 };
33
37 VideoRecorder &operator=(VideoRecorder &&) noexcept;
38
44 void open(Uint32 width, Uint32 height, std::string_view filename,
45 Settings settings);
46
48 bool isRecording() const { return m_impl != nullptr; }
49
60 VideoRecorder(Uint32 width, Uint32 height, std::string_view filename,
61 Settings settings);
62
63 VideoRecorder(Uint32 width, Uint32 height, std::string_view filename);
64
66 Uint32 frameCounter() const;
67
69 void close() noexcept;
70
72
74 const Device &device,
76 SDL_GPUTexture *texture,
77 SDL_GPUTextureFormat format);
78 };
79
80} // namespace media
81} // namespace candlewick
Definition CommandBuffer.h:17
Transfer buffer for the texture downloader.
Definition WriteTextureToImage.h:19
VideoRecorder(NoInitT)
Constructor which will not open the file or stream.
bool isRecording() const
Returns whether the recording stream is open.
Definition VideoRecorder.h:48
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename)
void open(Uint32 width, Uint32 height, std::string_view filename, Settings settings)
Open the recording stream.
void close() noexcept
Close the recording stream.
Uint32 frameCounter() const
Current number of recorded frames.
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename, Settings settings)
Constructor for the video recorder.
VideoRecorder(VideoRecorder &&) noexcept
void writeTextureToVideoFrame(CommandBuffer &command_buffer, const Device &device, TransferBufferPool &pool, SDL_GPUTexture *texture, SDL_GPUTextureFormat format)
Definition VideoRecorder.h:14
Definition Camera.h:8
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6
Definition VideoRecorder.h:26
int fps
Definition VideoRecorder.h:27
int outputHeight
Definition VideoRecorder.h:31
int outputWidth
Definition VideoRecorder.h:30
int bitRate
Definition VideoRecorder.h:29