Repository navigation
Description
Upstream OBS bug, reported by angeloruggieridj in obsproject/obs-studio#13249 (macOS 15, OBS 32.0.4). After remuxing an MKV recording to MP4 with OBS, the audio crackles or pops in Final Cut Pro. The MKV plays cleanly, and so does an MP4 made from the same MKV with FFmpeg. benank and lucgrefte report the same; lucgrefte notes that recording straight to MP4 is fine and that muxing the MKV with ffmpeg is "flawless". The older obsproject/obs-studio#4740 (2021, still open) is the same problem in QuickTime Player and Final Cut Pro; PatTheMav reproduced it there, ruled out the FFmpeg version and concluded it was in how OBS uses FFmpeg for MKV input. The code has not changed in this fork.
Location
libobs/media-io/media-remux.cprocess_packet()(lines 167-175): every packet's pts, dts and duration are rescaled on their own from the input time base to the output time base withav_rescale_q_rnd().- Matroska stores timestamps in milliseconds. AAC frames of 1024 samples at 48 kHz (21.333 ms) are stored as 0, 21, 43, 64, ... ms. The MP4/MOV muxer uses the sample rate as the audio time base and stores each frame's length as the gap to the next timestamp, so the remuxed frames are 1008 or 1056 samples long instead of 1024 (1014, 1015 or 1058 at 44.1 kHz), and the last frame loses 16 samples.
ffmpeg -c copydoes not have this problem because it rescales audio timestamps of a stream copy withav_rescale_delta(), which keeps frames back to back as long as that fits the input's rounding.
Class
Wrong output: the remuxed MP4/MOV has irregular audio frame lengths (16 to 32 samples off at every frame). Players and editors that honour those lengths (Final Cut Pro, QuickTime) stretch or overlap the audio at every frame boundary, which is heard as crackling. Players that ignore them (VLC) sound fine, which is why the issue looks player-specific.
How it is reached
- File > Remux Recordings, or automatic remux after recording, from MKV to MP4 or MOV with AAC audio. Every MKV recording is affected, not just some: OBS writes MKV with a 1 ms time base.
- Audio whose frames are a whole number of milliseconds (Opus at 48 kHz, 20 ms) is not affected, nor is input with a finer time base (MPEG-TS, MOV).
Reproduced headlessly against libobs on master: an MKV encoded with FFmpeg's AAC encoder, remuxed with media_remux_job_create()/media_remux_job_process(), has 200 of 200 audio frame starts off the 1024-sample grid. An MKV with H.264 and AAC remuxed by ffmpeg -c copy has 140 of 141 frames at 1024 (one 1016 where the encoder delay settles).
Upstream work
None found: no upstream PR references obsproject/obs-studio#13249 or obsproject/obs-studio#4740 or changes media-remux.c timestamps. obsproject/obs-studio#12224 (remuxed MP4 stutters in Premiere at 2x/4x, ffmpeg -c copy behaves better) may be related but is about video and is not covered here.
Proposed fix and failing test
Fix: in process_packet(), rescale the timestamps of audio packets with av_rescale_delta(), as ffmpeg -c copy does, with the frame length from av_get_audio_frame_duration2() or the stream's frame size. Real gaps in the recording are kept, and a trimmed last frame keeps its shorter length. Video and other streams are unchanged.
RED test (cmocka, test_remux_audio_timestamps). It encodes a tone with FFmpeg's AAC encoder into an MKV, remuxes it through libobs and reads the result back. It needs no display. Four cases:
- 48 kHz MKV to MP4: every frame starts 1024 samples after the previous one, and the last frame is 1024 samples long;
- 44.1 kHz MKV to MP4 with a shorter last frame: the same, and the last frame keeps its length;
- 48 kHz MKV to MOV;
- 48 kHz MKV with 10 frames left out: the gap survives the remux.
All four fail today.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 12, 2026
Claiming: this issue.
test_remux_audio_timestamps(4 of 4 failing, no display needed): AAC in MKV at 48 and 44.1 kHz remuxed to MP4/MOV through libobs' remux; every audio frame must start on the sample grid and keep its length, and a real gap must survive.ffmpeg -c copy.PR today.
test/cmocka: Add failing test for remuxed MKV audio timestamps
libobs: Keep audio frames sample accurate when remuxing
libobs: Keep audio frames sample accurate when remuxing
libobs: Keep audio frames sample accurate when remuxing (#360)
rdoupe commentedon Oct 12, 2026
@angeloruggieridj you reported this in obsproject/obs-studio#13249, so a heads-up: it's fixed here in obs-rust by #360, merged today with a regression test.
Cause: MKV stores timestamps in milliseconds, so AAC frames of 1024 samples at 48 kHz sit at 0, 21, 43, 64 ... ms. OBS's remux rescaled each of those on its own into MP4/MOV, where the sample rate is the audio time base and each frame's length is taken from the gap to the next timestamp, so frames came out 1008 or 1056 samples long instead of 1024. QuickTime and Final Cut Pro honour those lengths and glitch at every frame boundary; VLC ignores them, and
ffmpeg -c copyhandles audio timestamps differently, which is why remuxing with the ffmpeg command line sounded clean. The same thing was reported in obsproject/obs-studio#4740 by PoC22, dtest, bodote, Piipperi and DaiAoMori, and benank and lucgrefte confirmed it on yours. Now the remux places audio frames the same wayffmpeg -c copydoes: every frame starts on the sample grid, real gaps in the recording are kept, and video is untouched. The test remuxes generated AAC-in-MKV files at 48 and 44.1 kHz to MP4 and MOV: before, every frame boundary was off by 16-34 samples; now none is.Not covered: tested by reading the remuxed files' timestamps, not by listening in QuickTime or Final Cut Pro (no macOS here).
Workaround on stock OBS: remux with
ffmpeg -i in.mkv -c copy out.mp4, or record straight to MP4/MOV (or Hybrid MP4).obs-rust is an AI-assisted fork of OBS; on Arch it's
obs-studio-rust-gitin the AUR.If you try it, a short reply here on whether the remuxed files play cleanly in Final Cut Pro would really help.