Add isValid field to Conversion if output track counts haven't been reached, improve error messages to be more clear (closes #148)

This commit is contained in:
Vanilagy
2025-09-26 13:11:35 +02:00
parent 1b8e4f9f4b
commit be151d3494
4 changed files with 133 additions and 15 deletions
+12 -1
View File
@@ -13,6 +13,7 @@ It has the following features:
- Video rotation
- Video cropping
- Video frame rate adjustment
- Video transparency removal/preservation
- Audio resampling
- Audio up/downmixing
@@ -41,6 +42,14 @@ const output = new Output({
});
const conversion = await Conversion.init({ input, output });
if (!conversion.isValid) {
// Conversion is invalid and cannot be executed without error.
// This field gives reasons for why tracks were discarded:
conversion.discardedTracks; // => DiscardedTrack[]
return;
}
await conversion.execute();
// output.target.buffer contains the final file
@@ -57,7 +66,7 @@ Unconfigured, the conversion process handles all the details automatically, such
- Copying media data whenever possible, otherwise transcoding it
- Dropping tracks that aren't supported in the output format
You should consider inspecting the [discarded tracks](#discarded-tracks) before executing a `Conversion`.
You should consider inspecting `isValid` and the [discarded tracks](#discarded-tracks) before executing a `Conversion`.
### Monitoring progress
@@ -353,6 +362,8 @@ type DiscardedTrack = {
Since you can inspect this list before executing a `Conversion`, this gives you the option to decide if you still want to move forward with the conversion process.
If `isValid` is `false`, then the discarded tracks caused the `Conversion` to become invalid. For example, this can happen when a format requires a specific codec but that codec cannot be encoded.
---
The following reasons exist: