aconv: Copy metadata to output

This requires postponing FLAC header finalization, since FLAC cannot
write metadata after a finalized header.
This commit is contained in:
kleines Filmröllchen 2023-08-18 21:17:28 +02:00 committed by Andrew Kaster
parent 1e291753b0
commit 4c9c2104f3
Notes: sideshowbarker 2024-07-17 06:51:10 +09:00

View file

@ -134,15 +134,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
static_cast<int>(input_loader->sample_rate()),
input_loader->num_channels(),
Audio::pcm_bits_per_sample(parsed_output_sample_format)));
TRY(flac_writer->finalize_header_format());
writer.emplace(move(flac_writer));
} else {
warnln("Codec {} is not supported for encoding", output_format);
return 1;
}
if (writer.has_value())
if (writer.has_value()) {
(*writer)->sample_count_hint(input_loader->total_samples());
TRY((*writer)->set_metadata(input_loader->metadata()));
}
// FIXME: Maybe use a generalized interface for this as well if the need arises.
if (output_format == "flac"sv)
TRY(static_cast<Audio::FlacWriter*>(writer->ptr())->finalize_header_format());
if (output != "-"sv)
out("Writing: \033[s");