Skip to content

Commit af51bd3

Browse files
committed
Add workaround for sort of corrupted MXV files
1 parent 32c9056 commit af51bd3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

mxv/reader.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ func (r *Reader) VideoFrameData(frame int) (io.Reader, error) {
167167
return nil, fmt.Errorf("failed to read chunk: %w", err)
168168
}
169169

170-
if chunk.Length() != int64(vfte.VideoFrameChunkSize) {
170+
// Check size, but only if the VideoFrameChunkSize field is != 0.
171+
// May be some sort of corruption that occurs in older MXV files.
172+
if vfte.VideoFrameChunkSize != 0 && chunk.Length() != int64(vfte.VideoFrameChunkSize) {
171173
return nil, fmt.Errorf("parsed chunk is of wrong size. Got %d bytes, want %d bytes", chunk.Length(), vfte.VideoFrameChunkSize)
172174
}
173175

@@ -240,7 +242,9 @@ func (r *Reader) AudioFrameData(frame int) (reader io.Reader, startSample uint64
240242
return nil, 0, 0, fmt.Errorf("failed to read chunk: %w", err)
241243
}
242244

243-
if chunk.Length() != int64(afte.AudioFrameChunkSize) {
245+
// Check size, but only if the AudioFrameChunkSize field is != 0.
246+
// May be some sort of corruption that occurs in older MXV files.
247+
if afte.AudioFrameChunkSize != 0 && chunk.Length() != int64(afte.AudioFrameChunkSize) {
244248
return nil, 0, 0, fmt.Errorf("parsed chunk is of wrong size. Got %d bytes, want %d bytes", chunk.Length(), afte.AudioFrameChunkSize)
245249
}
246250

0 commit comments

Comments
 (0)