TransparentComposition class
Transparent composition with silent audio.
Generating silent audio has proven to be a very difficult and buggy thing to do with FFMPEG. To do things in a way that seems to play nice with FFMPEG, this composition combines two different tools to generate silent audio.
First, one second of audio is taken from "invisible.mov", a transparent and silent video that plays for one second.
Second, an anullsrc
audio stream is tacked on after the real audio
sample to fill up any remaining time for this composition.
This approach came from an investigation into why noise was appearing
in videos after a silent portion, when that silent portion is the very
first thing to appear in a given FFMPEG stream. My theory is that FFMPEG
is choosing a very low bitrate, or a weird encoding, or a bad sample size
based on the fact that the first audio sample is anullsrc
, and then that
same decision is applied to the real video that follows, which degrades
the video's audio.
Therefore, by playing 1 second (or any length) of real, silent audio, and then
introducing anullsrc
after that, we convince FFMPEG to use audio settings
that are good enough for video. So that's the approach taken with this
composition when it comes to silent audio.
This is all a theory based on debugging. I'm not sure about the root cause,
but the silent audio + anullsrc
seems to solve the problem.
- Implemented types
Constructors
- TransparentComposition({bool hasVideo = true, bool hasAudio = true, required Duration duration})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
FfmpegBuilder builder, CompositionSettings settings) → Future< FfmpegStream> -
Adds this composition to the composition tree in the given
builder
.override -
computeIntrinsicDuration(
) → Future< Duration> -
Computes the natural, or intrinsic, duration of this composition.
override
-
computeIntrinsicSize(
) → Future< VideoSize> -
Computes the natural, or intrinsic, size of this composition.
override
-
createDiagnosticsNode(
) → DiagnosticsNode -
override
-
hasAudio(
) → Future< bool> -
Whether this composition includes any audio streams.
override
-
hasVideo(
) → Future< bool> -
Whether this composition includes any video frames.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited