|
arduino-audio-tools
|
Feeds a Muxer (MuxerAVI, MuxerMP4, ...) from a single copy() call. More...
#include <VideoMuxer.h>
Public Member Functions | |
| VideoMuxer ()=default | |
| VideoMuxer (Muxer &muxer) | |
| bool | begin () |
| size_t | copy () |
| void | end () |
| Closes the Muxer. | |
| void | setAudioEncoder (AudioEncoder &encoder) |
| void | setAudioInfo (AudioInfo info) |
| void | setAudioSource (AudioStream &out) |
| Defines the AudioSource that we can configure with setAudioInfo() | |
| void | setAudioSource (Stream &pcm) |
| void | setMuxer (Muxer &muxer) |
| Defines the Muxer copy() writes to - call before begin(). | |
| void | setVideoEncoder (VideoEncoder &encoder) |
| void | setVideoSource (VideoFrameSource &video) |
Protected Member Functions | |
| size_t | copyAudio () |
| bool | copyVideo () |
| bool | copyVideoPaced () |
Protected Attributes | |
| AudioInfo | audio_info |
| uint64_t | audio_samples_written = 0 |
| uint32_t | bytes_per_sample = 0 |
| bool | have_audio = false |
| bool | have_video = false |
| Stream * | p_audio = nullptr |
| AudioEncoder * | p_audio_encoder = nullptr |
| Muxer * | p_muxer = nullptr |
| AudioInfoSupport * | p_source_audio_info = nullptr |
| VideoFrameSource * | p_video = nullptr |
| VideoEncoder * | p_video_encoder = nullptr |
| uint32_t | sample_rate = 0 |
| float | video_fps = 0 |
| uint32_t | video_frame_count = 0 |
| uint32_t | video_interval_ms = 33 |
| MuxerVideoSink | video_sink |
Static Protected Attributes | |
| static constexpr size_t | kAudioReadChunkSize = 512 |
Feeds a Muxer (MuxerAVI, MuxerMP4, ...) from a single copy() call.
setAudioSource() is what drives time, so it's effectively required for the faster-than-real-time benefit; without one, there's no audio time to derive video timing from, so copy() instead paces itself against wall-clock time via VideoFrameSource::videoInfo().fps (like VideoMuxerWithTasks's own video task does), compensating for time spent encoding so the real capture cadence matches the fps written into the Muxer's video track. Configuration (setAudioEncoder()/setAudioInfo()/setVideoSource()/ setVideoEncoder()) and what begin() derives/configures automatically work exactly like VideoMuxerWithTasks's own - see that class's comment for the details not repeated here. end() closes the Muxer.
|
default |
|
inline |
|
inline |
Configures the Muxer's video/audio tracks from the source/encoder objects above and calls Muxer::begin() - see VideoMuxerWithTasks's own begin() comment for exactly what that derives; the only Muxer setup still needed from the caller is Muxer::setOutput().
|
inline |
With an audio source: reads and writes one PCM chunk, then mux/encodes however many video frames that much audio now covers (see class comment), returning the number of audio bytes processed - 0 once setAudioSource() has no more data, the signal to stop calling this. Without an audio source: pulls/writes exactly one video frame, paced against wall-clock time by VideoFrameSource::videoInfo().fps (see class comment), returning 1 (written) or 0 (setVideoSource() has none left/wasn't set).
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
No-audio fallback: paces copyVideo() against wall-clock time via video_interval_ms, sleeping only the remainder of the interval left after encoding - same compensation VideoMuxerWithTasks's video task applies, so a slow encoder doesn't slip the real capture cadence behind the fps written into the Muxer's video track.
|
inline |
Closes the Muxer.
|
inline |
Defines the (optional) encoder each PCM chunk is handed to - responsible for framing and writing the encoded result to the Muxer itself; its setOutput() is pointed at the Muxer by begin(). Leave unset to write setAudioSource()'s PCM straight through instead (see setAudioInfo()).
|
inline |
Defines the sample_rate/channels/bits_per_sample of setAudioSource()'s PCM data - only used (instead of AudioEncoder::audioInfo()) when no setAudioEncoder() was called. Call before begin().
|
inline |
Defines the AudioSource that we can configure with setAudioInfo()
|
inline |
Defines the raw PCM source copy() reads from - drives this class's timeline (see class comment). On its own (no setAudioEncoder()) each chunk is written to the Muxer as raw PCM - call setAudioInfo() too in that case.
|
inline |
Defines the (optional) encoder each raw picture from setVideoSource() is handed to - e.g. an H264Encoder (AudioTools/Video/CodecH264.h), configured as usual (setSize()/setVideoFormat()/...) before passing it here. Leave unset to write setVideoSource()'s bytes straight through as already-encoded frames instead.
|
inline |
Defines the video frame provider copy() pulls frames from - already-encoded unless setVideoEncoder() is also called. Leave unset to write audio only.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |