Skip to content

Commit

Permalink
Merge pull request #25 from raedle/pr25
Browse files Browse the repository at this point in the history
Change latencyMode to realtime to significantly reduce video file size on Safari
  • Loading branch information
vjeux authored Jun 6, 2024
2 parents fa090da + 82acc7b commit dfb2635
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,24 @@ progress.innerText =
Math.round(encodedFrameIndex / seconds) + " fps";
```
## Encoding Results
| Filename | Original Size | Chrome\* | Safari† | Firefox‡ |
| --------------------- | ------------: | -------: | ------: | -------: |
| mob_head_farm_5s.mp4 | 14.6 MB | 16.7 MB | 11.5 MB | 8.9 MB |
| mob_head_farm_10s.mp4 | 27.8 MB | 33.5 MB | 22.8 MB | 17.7 MB |
| mob_head_farm_20s.mp4 | 49.8 MB | 66.7 MB | 45.6 MB | 35.3 MB |
\* Chrome Version 125.0.6422.142 (Official Build) (arm64)
† Safari Version 17.5 (19618.2.12.11.6)
‡ Firefox Nightly 127.0a1 (2024-04-24) (64-bit)
## Open Issues
- [ ] Order `VideoFrame`s by timestamp. VideoDecoder callback `output` is not guaranteed to be called in presentation order. This can lead to seemingly _jerky_ outputs after encoding because frames are then encoded out of order. This is a prominent issue in Safari.
## Useful Tools
* This tool displays all the metadata from an mp4 and comes as part of mp4box.js. This has been my goto tool for all this project!
Expand Down
5 changes: 4 additions & 1 deletion mp4box.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@
width: track.track_width,
height: track.track_height,
hardwareAcceleration: 'prefer-hardware',
bitrate: 20_000_000,
bitrate: 14_000_000,
alpha: 'discard',
bitrateMode: 'variable',
latencyMode: 'realtime',
});

mp4boxInputFile.setExtractionOptions(track.id, null, {nbSamples: Infinity});
Expand Down
5 changes: 4 additions & 1 deletion mp4manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@
width: videoTrack.track_width,
height: videoTrack.track_height,
hardwareAcceleration: 'prefer-hardware',
bitrate: 20_000_000,
bitrate: 14_000_000,
alpha: 'discard',
bitrateMode: 'variable',
latencyMode: 'realtime',
});

mp4boxInputFile.setExtractionOptions(videoTrack.id, null, {nbSamples: Infinity});
Expand Down
5 changes: 4 additions & 1 deletion mp4wasm.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
format: 'annexb',
},
hardwareAcceleration: 'prefer-hardware',
bitrate: 20_000_000,
bitrate: 14_000_000,
alpha: 'discard',
bitrateMode: 'variable',
latencyMode: 'realtime',
});

mp4boxInputFile.setExtractionOptions(track.id, null, {nbSamples: Infinity});
Expand Down

0 comments on commit dfb2635

Please sign in to comment.