crates/veilvoice-video/src/export.rs
veilvoice-video · 942 lines · read the source here · or on GitHub
What an export asks, and the ffmpeg command each answer turns into.
Roadmap item 175. The Browser's export used to offer three things: a page, a video with a black picture, or both. A recording tool asks more than that, and this module is the questions it asks, in the order it asks them:
- What to write: the sound on its own, the picture on its own, or the two together (
Content). - A container and a codec (
Container,VideoCodec). - A quality, from a lossless master down to something small enough to send in a message (
Quality).
The fourth question, how the picture looks, is crate::motion.
The audio is lossless whatever the video is
There is no lossy audio codec anywhere in this module, and that is the rule rather than a default. The recording is the point of the file and the picture is a carrier for it: somebody who picks the smallest video there is has chosen a smaller picture, not a worse voice. So the sound goes in as FLAC, ALAC or plain PCM, whichever the container can carry, and a veiled recording that leaves VeilVoice is bit for bit the one that was stored.
That rule is also why WebM is not offered. WebM carries Vorbis and Opus and nothing lossless, and ffmpeg refuses to put FLAC in it. Offering it would mean either breaking the rule for one container or offering a choice that always fails, and neither is honest.
A choice that cannot work is refused before anything runs
Not every codec goes in every container, and not every quality means anything for every codec. Export::checked refuses the combinations that would make ffmpeg stop after the frames were drawn, and every refusal names something that would have worked, because "that does not go in a MOV" is only half an answer.
And VeilVoice still does not run it for you
Exactly as crate::ffmpeg says: this builds the argument list. Running it is the caller's, and a front end names the program it found rather than fetching one.
In plain words
These are the questions the export asks: sound, picture or both; which kind of file; how good. Whatever you pick for the picture, the sound is saved without losing anything, because the voice is what the file is for.
WHAT THIS FILE CONTAINS
942 lines defining 23 functions (21 public), 7 types and 3 constants. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
enum Contentline 58 · What an export writes.enum Containerline 95 · The file a video goes into.enum VideoCodecline 163 · How the picture is compressed.enum AudioCodecline 221 · The lossless audio an export carries.enum Qualityline 259 · How good the picture is, and so how large the file is.enum AudioFileline 326 · The lossless audio-only file.struct Exportline 354 · Every answer an export needs.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
Content::labelline 74 · What this is called where it is chosen.Content::wants_pictureline 83 · Whether the picture is drawn at all.Content::wants_soundline 88 · Whether the sound goes in.Container::labelline 110 · What this is called where it is chosen.Container::extensionline 119 · The file extension, without its dot.Container::video_codecsline 128 · The video codecs this container carries, in the order they are offered.Container::audio_codecline 153 · The lossless audio this container carries.VideoCodec::labelline 181 · What this is called where it is chosen.VideoCodec::encoderline 199 · The ffmpeg encoder that writes it.VideoCodec::always_losslessline 214 · Whether every quality is the same quality for this codec.AudioCodec::encoderline 232 · The ffmpeg encoder that writes it.AudioCodec::labelline 243 · What this is called where it is shown.Quality::labelline 281 · What this is called where it is chosen.Quality::factorline 295 · The constant rate factor this quality means for codec, if it uses one.Quality::prores_profileline 314 · The ProRes profile this quality means: 3 is HQ, 2 standard, 0 proxy.AudioFile::labelline 336 · What this is called where it is chosen.AudioFile::extensionline 344 · The file extension, without its dot.Export::extensionline 441 · The extension of the file this writes.Export::describeline 455 · What will be written, in one line a person reads before pressing the button.Export::commandline 490 · The command that writes the export.
reacheschecked,video_settings
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one. 22 of 15 functions are drawn; the diagram is bounded at 22 so it stays readable.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_label(["Content::label<br/>line 74"])
n_wants_picture(["Content::wants_picture<br/>line 83"])
n_wants_sound(["Content::wants_sound<br/>line 88"])
n_label(["Container::label<br/>line 110"])
n_extension(["Container::extension<br/>line 119"])
n_video_codecs(["Container::video_codecs<br/>line 128"])
n_audio_codec(["Container::audio_codec<br/>line 153"])
n_label(["VideoCodec::label<br/>line 181"])
n_encoder(["VideoCodec::encoder<br/>line 199"])
n_always_lossless(["VideoCodec::always_lossless<br/>line 214"])
n_encoder(["AudioCodec::encoder<br/>line 232"])
n_label(["AudioCodec::label<br/>line 243"])
n_label(["Quality::label<br/>line 281"])
n_factor(["Quality::factor<br/>line 295"])
n_prores_profile(["Quality::prores_profile<br/>line 314"])
n_label(["AudioFile::label<br/>line 336"])
n_extension(["AudioFile::extension<br/>line 344"])
n_checked["Export::checked<br/>line 396"]
n_extension(["Export::extension<br/>line 441"])
n_describe(["Export::describe<br/>line 455"])
n_command(["Export::command<br/>line 490"])
n_video_settings["Export::video_settings<br/>line 591"]
n_command --> n_checked
n_command --> n_video_settings
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L74" "open the source"
click n_wants_picture href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L83" "open the source"
click n_wants_sound href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L88" "open the source"
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L110" "open the source"
click n_extension href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L119" "open the source"
click n_video_codecs href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L128" "open the source"
click n_audio_codec href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L153" "open the source"
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L181" "open the source"
click n_encoder href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L199" "open the source"
click n_always_lossless href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L214" "open the source"
click n_encoder href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L232" "open the source"
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L243" "open the source"
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L281" "open the source"
click n_factor href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L295" "open the source"
click n_prores_profile href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L314" "open the source"
click n_label href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L336" "open the source"
click n_extension href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L344" "open the source"
click n_checked href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L396" "open the source"
click n_extension href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L441" "open the source"
click n_describe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L455" "open the source"
click n_command href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L490" "open the source"
click n_video_settings href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-video/src/export.rs#L591" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_label,n_wants_picture,n_wants_sound,n_label,n_extension,n_video_codecs,n_audio_codec,n_label,n_encoder,n_always_lossless,n_encoder,n_label,n_label,n_factor,n_prores_profile,n_label,n_extension,n_extension,n_describe,n_command entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_checked api
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_video_settings helper
subgraph chart_key ["Key"]
direction LR
key_entry["entry: a way in: public, and nothing in this file calls it"]
key_api["api: public, and also used inside this file"]
key_helper["helper: private to this file"]
end
class key_entry entry
class key_api api
class key_helper helper
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
Content pub enum | 58 | What an export writes. |
Content::ALL pub const | 71 | Every choice, in the order they are offered. |
Content::label pub fn | 74 | What this is called where it is chosen. |
Content::wants_picture pub fn | 83 | Whether the picture is drawn at all. |
Content::wants_sound pub fn | 88 | Whether the sound goes in. |
Container pub enum | 95 | The file a video goes into. |
Container::ALL pub const | 107 | Every container, in the order they are offered. |
Container::label pub fn | 110 | What this is called where it is chosen. |
Container::extension pub fn | 119 | The file extension, without its dot. |
Container::video_codecs pub fn | 128 | The video codecs this container carries, in the order they are offered. |
Container::audio_codec pub fn | 153 | The lossless audio this container carries. |
VideoCodec pub enum | 163 | How the picture is compressed. |
VideoCodec::label pub fn | 181 | What this is called where it is chosen. |
VideoCodec::encoder pub fn | 199 | The ffmpeg encoder that writes it. |
VideoCodec::always_lossless pub fn | 214 | Whether every quality is the same quality for this codec. |
AudioCodec pub enum | 221 | The lossless audio an export carries. |
AudioCodec::encoder pub fn | 232 | The ffmpeg encoder that writes it. |
AudioCodec::label pub fn | 243 | What this is called where it is shown. |
Quality pub enum | 259 | How good the picture is, and so how large the file is. |
Quality::ALL pub const | 273 | Every quality, best first. |
Quality::label pub fn | 281 | What this is called where it is chosen. |
Quality::factor pub fn | 295 | The constant rate factor this quality means for codec, if it uses one. |
Quality::prores_profile pub fn | 314 | The ProRes profile this quality means: 3 is HQ, 2 standard, 0 proxy. |
AudioFile pub enum | 326 | The lossless audio-only file. |
AudioFile::label pub fn | 336 | What this is called where it is chosen. |
AudioFile::extension pub fn | 344 | The file extension, without its dot. |
Export pub struct | 354 | Every answer an export needs. |
Export::default fn | 377 | High quality H.264 in an MP4 with FLAC in it, at 1080p and sixty frames a second. |
Export::checked pub fn | 396 | Refuse a combination ffmpeg would refuse, and say what would work. |
Export::extension pub fn | 441 | The extension of the file this writes. |
Export::describe pub fn | 455 | What will be written, in one line a person reads before pressing the button. |
Export::command pub fn | 490 | The command that writes the export. |
Export::video_settings fn | 591 | The encoder settings for the chosen codec and quality. |