addAsset method
Adds an input asset at the given assetPath
.
If hasVideo
is true
, the asset is processed for video frames.
If hasAudio
is true
, the asset is processed for audio streams.
Implementation
FfmpegStream addAsset(
String assetPath, {
bool hasVideo = true,
bool hasAudio = true,
}) {
final input = FfmpegInput.asset(assetPath);
// Generate video and audio stream IDs using the format that
// FFMPEG expects.
final videoId = hasVideo
? hasVideo && hasAudio
? '[${_inputs.length}:v]'
: '[${_inputs.length}]'
: null;
final audioId = hasAudio
? hasVideo && hasAudio
? '[${_inputs.length}:a]'
: '[${_inputs.length}]'
: null;
_inputs.putIfAbsent(
input,
() => FfmpegStream(
videoId: videoId,
audioId: audioId,
));
return _inputs[input]!;
}