Skip to content

Commit

Permalink
MP4 video: Ignore sannies/mp4parser#427
Browse files Browse the repository at this point in the history
  • Loading branch information
don-vip committed Apr 19, 2024
1 parent 061e7e6 commit f2982ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.channels.Channels;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -156,6 +157,17 @@ private static ContentsAndMetadata<IsoFile> readVideo(Path path, long contentLen
throw new FileDecodingException("Failed to open MP4 video from " + path);
}
return new ContentsAndMetadata<>(mp4, contentLength, filename, extension, movieBox.getTrackCount());
} catch (RuntimeException e) {
if ("box size of zero means 'till end of file. That is not yet supported".equals(e.getMessage())) {
// Ignore https://github.com/sannies/mp4parser/issues/427
return new ContentsAndMetadata<>(
// Return sample data from
// https://github.com/mathiasbynens/small/blob/master/mp4-with-audio.mp4
new IsoFile(Channels.newChannel(MediaUtils.class.getResourceAsStream("/mp4-with-audio.mp4"))),
contentLength, filename, extension, 1);
} else {
throw e;
}
}
}

Expand Down
Binary file added src/main/resources/mp4-with-audio.mp4
Binary file not shown.

0 comments on commit f2982ba

Please sign in to comment.