Be able to recalculate the audio length field in headers #581

Open
opened 2025-08-22 13:43:22 +00:00 by martinwguy · 0 comments
martinwguy commented 2025-08-22 13:43:22 +00:00 (Migrated from codeberg.org)

Be able to recalculate the audio length field in headers

Description

Sone audio file types can have metadata in their headers
that give the length of the audio in sample frames or whatever.

It would be useful to be able to correct this if it is wrong,
such as if a file was written but could not be rewound to
rewrite its header, if a (e.g. MP3) file may need decoding fully
to determine its real length or if audio files are truncated.

Analysis

One way to implement this is to write an effect, say fixlength,
that modifies the audio stream's metadata as it passes through.
This would require temporary storage.

Another is a global option, say --fix-length, that means
"determine and rewrite the audio length in the header fields"
as it only affects the single output audio file.

It may be that SoX already does this if the output file is seekable
and e.g. lengths in ID3 or Xing tags are always recalculated.

# Be able to recalculate the audio length field in headers ## Description Sone audio file types can have metadata in their headers that give the length of the audio in sample frames or whatever. It would be useful to be able to correct this if it is wrong, such as if a file was written but could not be rewound to rewrite its header, if a (e.g. MP3) file may need decoding fully to determine its real length or if audio files are truncated. ## Analysis One way to implement this is to write an effect, say `fixlength`, that modifies the audio stream's metadata as it passes through. This would require temporary storage. Another is a global option, say `--fix-length`, that means "determine and rewrite the audio length in the header fields" as it only affects the single output audio file. It may be that SoX already does this if the output file is seekable and e.g. lengths in ID3 or Xing tags are always recalculated.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martinwguy/sox_ng#581
No description provided.