Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read preskip and gain from codec private
Looks like (unlike WebM) MP4 doesn't use `OpusHead` description from the encoder directly and has its own `dOps` format that differs in byte layout. So far preskip was hard-coded to 3840. If there's a significant difference in the value in the `OpusHead` private data from the encoder, can lead to more than necessary data being cut off from the beginning and possibly a slight desync with video. Effects of the shift can be observed in this example: https://codepen.io/brainshave/pen/QWXxKmW. It compares original source with `webm-muxer` (5.0.0) and `mp4-muxer` (5.0.4). WebM file is moslty in sync (but still not prefect but this could be either specific to decoder or encoder) while MP4 is shifted 2880 samples left. To fix this, add reading of the `OpusHead` format for creating the `dOps` box. Apart from preskip this also adds handling for gain field. Being conservative WRT other fields like number of channels and sample rate that are be provided from other sources. Also, keeping the original hard-coded values if the `description` field is missing to avoid regressions.
- Loading branch information