Facade that maps tracks and runs one reader-to-writer job. More...
#include <StormByte/multimedia/pipeline/transcoder.hxx>
Classes | |
| class | Track |
| Fluent handle for one origin stream in this job. More... | |
Public Member Functions | |
| const StormByte::Safe::Shared< StormByte::Logger::Log > & | Logger () const noexcept |
| Logger used by this job after InstallLog. | |
| const StormByte::Safe::Shared< class Plan > & | Plan () const noexcept |
| Intention built for this job, if any. | |
Lifecycle | |
| Transcoder (const StormByte::Safe::String &source, const StormByte::Safe::String &destination, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Builds reader and writer from paths. | |
| Transcoder (const StormByte::Safe::String &source, StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > writer, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
Builds a local reader and takes writer. | |
| Transcoder (StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > reader, const StormByte::Safe::String &destination, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
Takes reader and builds a local writer. | |
| Transcoder (StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > reader, StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > writer, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Takes both location owners without slicing. | |
| Transcoder (const StormByte::Safe::String &source, const StormByte::Safe::String &destination, const class Container &container, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Builds local locations with an authoritative borrowed container. | |
| Transcoder (const StormByte::Safe::String &source, StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > writer, const class Container &container, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Builds a local reader and takes the writer with an explicit container. | |
| Transcoder (StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > reader, const StormByte::Safe::String &destination, const class Container &container, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Takes the reader and builds a writer with an explicit container. | |
| Transcoder (StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > reader, StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > writer, const class Container &container, StormByte::Safe::Shared< StormByte::Logger::Log > logger, StormByte::Safe::Optional< std::int64_t > duration={}) | |
| Takes both locations with an authoritative borrowed container. | |
| Transcoder (const Transcoder &other)=delete | |
| Copy constructor. | |
| Transcoder (Transcoder &&other)=delete | |
| Move constructor. | |
| virtual | ~Transcoder () noexcept |
| Destructor. | |
| Transcoder & | operator= (const Transcoder &other)=delete |
| Copy assignment. | |
| Transcoder & | operator= (Transcoder &&other) noexcept=delete |
| Move assignment. | |
Map | |
| Track | Video (int in) noexcept |
| Maps a video origin stream. | |
| Track | Audio (int in) noexcept |
| Maps an audio origin stream. | |
| Track | Subtitle (int in) noexcept |
| Maps a subtitle origin stream. | |
| Transcoder & | Attachments () noexcept |
| Keeps every source attachment. | |
| Transcoder & | Attachments (std::string_view pattern) noexcept |
Keeps source attachments whose MIME matches pattern. | |
| Transcoder & | Tag (StormByte::Multimedia::Metadata::FileTag tag, StormByte::Safe::String value) noexcept |
| Replaces a file-level tag in the output. | |
| Transcoder & | RemoveTag (StormByte::Multimedia::Metadata::FileTag tag) noexcept |
Writes the output without file tag tag. | |
| ResourceUsage | Resources () const noexcept |
| Resource policy selected for this job. | |
| void | Resources (ResourceUsage usage) noexcept |
| Selects a resource policy before Run. | |
| BufferingPolicy | Buffering () const noexcept |
| Queue capacity overrides used by the Plan built on Run. | |
| void | Buffering (const BufferingPolicy &policy) noexcept |
| Configure queue element caps before Run. | |
| Transcoder & | Ignore (int in) noexcept |
| Drops an origin stream (omit from the Plan). | |
| template<typename FilterType, typename... Args> | |
| Transcoder & | Filter (Args &&... args) |
| Appends a global analytics filter. | |
Run | |
| void | Run () noexcept |
| Builds the Plan, starts the coordinator and returns. | |
| void | Cancel () noexcept |
| Requests abort. | |
| void | Pause () noexcept |
| Pauses the job. | |
| void | Resume () noexcept |
| Resumes after Pause. | |
| enum Status | Status () const noexcept |
| Current lifecycle value. | |
| bool | Failed () const noexcept |
| Whether the job failed. | |
| StormByte::Safe::Optional< StormByte::Safe::String > | Error () const |
| Failure text. | |
| StormByte::Safe::Shared< StormByte::Buffer::ReadTelemetry > | InputTelemetry () const noexcept |
| Shared telemetry for the original input reader. | |
| StormByte::Safe::Shared< StormByte::Buffer::WriteTelemetry > | OutputTelemetry () const noexcept |
| Shared telemetry for the destination writer. | |
| StormByte::Safe::Shared< const class Progress > | Progress () const noexcept |
| Shared tube clock. | |
| StormByte::Safe::Vector< StormByte::Safe::Pair< StormByte::Safe::String, Filter::Report > > | Reports () const |
| Analytics snapshots after the job is Idle. | |
| StormByte::Safe::Shared< const JobTelemetry > | Telemetry () const noexcept |
| Shared job and stage telemetry, available before Run. | |
| operator bool () const noexcept | |
| true if not failed. | |
Protected Member Functions | |
| virtual void | InstallLog () |
| Scopes this job's own logger. | |
| const StormByte::Safe::Shared< StormByte::Logger::Log > & | ApplicationLog () const noexcept |
| Application logger passed to the constructor. | |
| virtual StormByte::Safe::Shared< class Plan > | EmptyPlan (StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > reader, StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > writer, StormByte::Safe::Optional< std::int64_t > duration={}, const class Container *container=nullptr) const |
| Allocates the Plan type for this job. | |
| StormByte::Safe::Function< void(double)> | DurationProgress () const |
| Observer for duration resolution in custom EmptyPlan implementations. | |
| virtual StormByte::Safe::Unique< TrackSettled > | EmptySettled () const |
| Allocates the settled-row type. | |
| virtual void | OnConfigure () noexcept |
| Last chance to raise ceilings before the job starts. | |
| virtual enum Status | OnStart () noexcept |
| Gate after the Plan is filled. | |
| virtual void | OnPlan (const class Plan &plan) noexcept |
| Intention, just before plan >> demuxer. | |
| virtual void | OnSettled (const TrackSettled &track) noexcept |
| One encode lane finished Encoder open. | |
| virtual void | OnMeasureDone () noexcept |
| Measure pass closed. | |
| virtual void | OnAnalyticsDone () noexcept |
| Analytics taps idle. | |
| virtual void | OnProgress () noexcept |
| Progress tick. | |
| virtual void | OnDone () noexcept |
| Successful flush. | |
| virtual void | OnError (const StormByte::Safe::String &message) noexcept |
| Hard error. | |
| virtual void | OnAborted () noexcept |
| Cancel completed. | |
Friends | |
| class | Backend::Pipeline::Transcoder |
| Backend coordinator that runs this job's pipeline. | |
| class | Track |
| Fluent handle that configures this job's mapped tracks. | |
Facade that maps tracks and runs one reader-to-writer job.
File-to-file job facade.
Connects operator>> and Filters for you. The stock class is a complete job: own reader/writer locations, choose origin streams, remux or encode each one, write through the Plan writer. You do not have to derive anything to transcode.
Four input/output combinations are accepted: path/path, path/writer, reader/path, and reader/writer. Path arguments create local file locations; supplied location owners preserve their dynamic type. The job takes ownership of the reader and writer. Source analysis supplies stream information, attachments and metadata for the Plan.
It is also the extension point. Mix what you need:
EmptyPlan / EmptySettled only pick the dynamic type. This class still fills tracks from the fluent map and settled fields from the opened Encoder. One instance is one Run. Another job is another instance.
Assembly uses the same connections as a manual pipeline. Filters close before the shared Plan is sent to Demuxer, then the Plan enters Running. Finished is published only after every stage and analytics complete. Failures and cancellation publish Failed.
Mux order is the order of Video / Audio / Subtitle / Attachments calls. There is no output-index argument and no Destination setter: the container is the writer extension.
Analytics attach with Filter. After the job reaches Status::Done, Reports returns the same snapshots a hand tube reads with Filter::Analytics::Report on the leaf pointer.
Progress provides shared job progress. The handle remains usable after the job has been destroyed.
Each constructor calls InstallLog after the most-derived constructor body of this class. A derived constructor that constructs a subclass must call InstallLog itself after that constructor.
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | const StormByte::Safe::String & | source, |
| const StormByte::Safe::String & | destination, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Builds reader and writer from paths.
| source | Input path. |
| destination | Output path. |
| logger | Shared log for the job and the tube. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
Stores logger as-is. InstallLog runs at the end of this constructor.
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | const StormByte::Safe::String & | source, |
| StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > | writer, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Builds a local reader and takes writer.
| source | Input path. |
| writer | Owned output location (moved). |
| logger | Shared log for the job and the tube. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > | reader, |
| const StormByte::Safe::String & | destination, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Takes reader and builds a local writer.
| reader | Owned input location (moved). |
| destination | Output path. |
| logger | Shared log for the job and the tube. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > | reader, |
| StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > | writer, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Takes both location owners without slicing.
| reader | Owned input location (moved). |
| writer | Owned output location (moved). |
| logger | Shared log for the job and the tube. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | const StormByte::Safe::String & | source, |
| const StormByte::Safe::String & | destination, | ||
| const class Container & | container, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Builds local locations with an authoritative borrowed container.
| source | Input path. |
| destination | Output path; its suffix does not select the muxer. |
| container | Registered identity, borrowed through job and Plan destruction. |
| logger | Shared application log. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | const StormByte::Safe::String & | source, |
| StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > | writer, | ||
| const class Container & | container, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Builds a local reader and takes the writer with an explicit container.
| source | Input path. |
| writer | Owned output location. |
| container | Registered identity, borrowed through job and Plan destruction. |
| logger | Shared application log. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > | reader, |
| const StormByte::Safe::String & | destination, | ||
| const class Container & | container, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Takes the reader and builds a writer with an explicit container.
| reader | Owned input location. |
| destination | Output path; its suffix does not select the muxer. |
| container | Registered identity, borrowed through job and Plan destruction. |
| logger | Shared application log. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| StormByte::Multimedia::Pipeline::Transcoder::Transcoder | ( | StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationReader > | reader, |
| StormByte::Safe::Unique< StormByte::Buffer::IO::BufferedLocationWriter > | writer, | ||
| const class Container & | container, | ||
| StormByte::Safe::Shared< StormByte::Logger::Log > | logger, | ||
| StormByte::Safe::Optional< std::int64_t > | duration = {} ) |
Takes both locations with an authoritative borrowed container.
| reader | Owned input location. |
| writer | Owned output location. |
| container | Registered identity; its registry must outlive the job and Plan. |
| logger | Shared application log. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
|
delete |
Copy constructor.
| other | Source job. |
|
delete |
Move constructor.
| other | Job to take. |
|
virtualnoexcept |
Destructor.
Stops the coordinator and joins.
|
inlineprotectednoexcept |
Application logger passed to the constructor.
Hand this to a Step or filter. Those apply the Multimedia stage path themselves.
|
noexcept |
Keeps every source attachment.
Alias of Attachments with the star-star MIME pattern. Default is drop (do not call this).
|
noexcept |
Keeps source attachments whose MIME matches pattern.
| pattern | Exact type/subtype, type-star category, or star-star (all). Same matcher as Plan::Check. |
|
noexcept |
Maps an audio origin stream.
Mux order is Add order.
| in | Origin stream index. |
|
noexcept |
Queue capacity overrides used by the Plan built on Run.
|
noexcept |
Configure queue element caps before Run.
| policy | Automatic, bounded, or unlimited caps. |
Invalid minima fail the Transcoder. This policy does not alter CPU threading selected by Resources.
|
noexcept |
Requests abort.
Coordinator ends in Status::Aborted unless a genuine failure occurs.
|
protected |
Observer for duration resolution in custom EmptyPlan implementations.
|
protectedvirtual |
Allocates the Plan type for this job.
| reader | Owned origin location, transferred from this Transcoder. |
| writer | Owned destination location, transferred from this Transcoder. |
| duration | Authoritative nanoseconds; otherwise use the container estimate, scanning only if unavailable. |
| container | Borrowed authoritative registry identity; null guesses from the writer path. |
Override to return a type derived from Plan. Tracks are filled from the fluent map after this returns. After the call this Transcoder no longer owns the leaves. Allocation failures propagate to the coordinator, which fails the job. Construct Shared<Plan>::MakePointer<Derived> in the provider module so the exact payload is released there. Keep a local DurationProgress() observer and pass its address to the observing Plan constructor.
|
protectedvirtual |
Allocates the settled-row type.
Override to return a type derived from TrackSettled. MarkSettled fills it and calls OnSettled. Construct Unique<TrackSettled>::MakePointer<Derived> in the provider module.
| StormByte::Safe::Optional< StormByte::Safe::String > StormByte::Multimedia::Pipeline::Transcoder::Error | ( | ) | const |
Failure text.
|
noexcept |
Whether the job failed.
|
inline |
Appends a global analytics filter.
One node, every matching stretch.
| FilterType | Child of Filter::Analytics. |
| Args | Filter constructor argument types. |
| args | Constructor arguments, forwarded. |
Track-scoped analytics attach on Track::Filter. Both are allowed; there is no dedup.
|
noexcept |
|
noexcept |
Shared telemetry for the original input reader.
|
protectedvirtual |
Scopes this job's own logger.
Stock path is StormByte/Multimedia/Transcoder with the Multimedia format and throttle. Override to use another path and other rules. Tube stages still use the StormByte/Multimedia/ prefix followed by the stage name. Do not call from a constructor. Each stock constructor calls this after the most-derived constructor of this class.
|
noexcept |
Logger used by this job after InstallLog.
Stock path is StormByte/Multimedia/Transcoder. Do not pass this pointer to a Step or filter; those use the application logger and the Multimedia stage path.
|
protectedvirtualnoexcept |
Cancel completed.
|
protectedvirtualnoexcept |
Analytics taps idle.
Not called if this tube did not mount analytics.
|
protectedvirtualnoexcept |
Last chance to raise ceilings before the job starts.
|
protectedvirtualnoexcept |
Successful flush.
|
protectedvirtualnoexcept |
Hard error.
| message | Error text, possibly empty when allocation failed. |
|
protectedvirtualnoexcept |
Measure pass closed.
Not called if this tube did not mount a measure pass.
|
protectedvirtualnoexcept |
Intention, just before plan >> demuxer.
| plan | Filled Plan (still owned by this job). |
|
protectedvirtualnoexcept |
|
protectedvirtualnoexcept |
One encode lane finished Encoder open.
| track | Settled row from EmptySettled. |
|
protectedvirtualnoexcept |
|
explicitnoexcept |
true if not failed.
|
delete |
Copy assignment.
| other | Source job. |
|
deletenoexcept |
Move assignment.
| other | Job to take. |
|
noexcept |
Shared telemetry for the destination writer.
|
noexcept |
Pauses the job.
Every stage (demux, decode, filters, encode, mux) blocks before its next work unit, so CPU use stops once in-flight units finish. Cancel still works while paused. Duration scans also wait at their next progress checkpoint.
|
inlinenoexcept |
Intention built for this job, if any.
|
noexcept |
Shared tube clock.
Forwards Demuxer::Progress().
Empty before Run wires the Demuxer. The user may keep the pointer after the job dies. No public setters.
|
noexcept |
| StormByte::Safe::Vector< StormByte::Safe::Pair< StormByte::Safe::String, Filter::Report > > StormByte::Multimedia::Pipeline::Transcoder::Reports | ( | ) | const |
Analytics snapshots after the job is Idle.
Track-scoped leaves use the origin index. Global Add uses general. Same contract as Filters::Reports. Snapshots only; the leaves stay owned by the job. Meaningful after Status::Done. A low score is still Ok. Notice lines from a leaf are log, not this API.
|
noexcept |
Resource policy selected for this job.
|
noexcept |
Selects a resource policy before Run.
| usage | Full, approximately half of available process CPUs, or at most two CPUs, with smaller frame queues for reduced modes. |
Full keeps native codec threading defaults and all requested VMAF workers (all process-available CPUs by default). Its raw-video queues retain their 27-frame capacity and analytics input is capped at 32 looks, without shrinking either by available RAM. Medium and Low distribute a best-effort thread budget across decode/encode lanes and reduce queued frames and packets, including filter and analytics input. VMAF also reduces its memory-intensive extractor pool (a half-CPU target shared across video contexts in Medium and one worker in Low, even with an explicit worker count). Encoder options are applied only when supported. In reduced modes, raw-video queues share a RAM-aware reservation with conservative frame sizing and a two-frame floor, and VMAF workers are additionally bounded by resolution and available RAM. Explicit FineTune values that control threading conflict with Medium or Low and fail the job rather than bypassing the selected policy. This is not a hard CPU or RSS limit; codec libraries, filters and drivers may use additional resources.
|
noexcept |
Resumes after Pause.
|
noexcept |
Builds the Plan, starts the coordinator and returns.
A second Run fails. Calls OnConfigure, EmptyPlan (moves the BufferedFile leaves), fills tracks from the fluent map, OnPlan, OnStart, then plan >> demuxer >> muxer. Does not block until Done.
|
noexcept |
Current lifecycle value.
|
noexcept |
Maps a subtitle origin stream.
Mux order is Add order.
| in | Origin stream index. |
|
noexcept |
Replaces a file-level tag in the output.
Tags without an edit are copied from the source. Track and Disc are written verbatim, so "3" and "3/12" both work. Formats that cannot store tag ignore it; see Container::Stores.
| tag | File tag. |
| value | New value. Empty drops the edit and keeps the source value. |
|
noexcept |
Shared job and stage telemetry, available before Run.
Retain the handle to inspect final counters after the worker and its pipeline stages have been destroyed. Resident memory values are sampled process RSS and are not per-stage allocations.
|
noexcept |
Maps a video origin stream.
Mux order is Add order.
| in | Origin stream index. |
|
friend |
Backend coordinator that runs this job's pipeline.
|
friend |
Fluent handle that configures this job's mapped tracks.