2025-04-22 07:52:40 +00:00
2025-04-22 07:49:23 +00:00
2025-04-22 07:52:40 +00:00
2025-04-22 07:52:05 +00:00

PURPOSE:
This Go script provides the foundation for a workaround for a bug involving N_m3u8DL-RE in which live recordings that are piped and muxed in real time have their video and audio out of sync.

USAGE:
1. download and install Go if you haven't already (https://go.dev/doc/install).
2. download/copy this script and place it in each of the two or three "track directories" created by N_m3u8DL-RE when recording a live stream (the root directory containing these directories will be named whatever you specified for the --save-name option in N_m3u8DL-RE).  There will be a video directory containing the video segments, an audio directory containing the audio segments, and (if available) a subtitle directory containing the subtitle segments.
3. in each of those two or three directories, open your terminal or change to the respective directory and type Go run Concat.go , then wait while the script concantenates all the segments into a single "out.mp4" output file.
4. using ffmpeg or mkvmerge, multiplex the "out.mp4" files together into one final .mp4 or .mkv output file.  The video, audio, and (if applicable) subtitle tracks should now all be in sync.

NOTES:
1. use Concat-Enc.go for CENC-protected streams.  Use Concat.go for unprotected/clear/plaintext streams.
2. Concat-Enc.go requires that an _init_dec.mp4 file be present within each track directory containing the segments of a protected track.
3. Concat.go likewise requires that an _init.mp4 file be present in each track directory.
4. ImAleeexx's streamlink-drm tool (available at https://github.com/ImAleeexx/streamlink-drm or via the mirror on this site) is a better workaround for most live MPDs.
Description
A Go script providing the foundation of a workaround for a synchronization issue arising during recording of live streams using N_m3u8DL-RE.
Readme 32 KiB
Languages
Go 100%