Skip to content

Commit

Permalink
Fix video duration parsing in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds-signal committed Jan 18, 2023
1 parent 0f8009f commit c1b8fe8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ts/util/isVideoGoodForStories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export async function isVideoGoodForStories(
const mp4 = MP4Box.createFile();
await new Promise<void>((resolve, reject) => {
mp4.onReady = info => {
if (info.duration > MAX_VIDEO_DURATION) {
// mp4box returns a `duration` in `timescale` units
const seconds = info.duration / info.timescale;
const milliseconds = seconds * 1000;

if (milliseconds > MAX_VIDEO_DURATION) {
reject(ReasonVideoNotGood.TooLong);
return;
}
Expand Down

0 comments on commit c1b8fe8

Please sign in to comment.