nilaoda / N_m3u8DL-RE

Cross-Platform, modern and powerful stream downloader for MPD/M3U8/ISM. English/简体中文/繁體中文.
MIT License
4.77k stars 499 forks source link

Sync Issues When Downloading and Merging Live Videos #405

Closed Anything1365 closed 3 months ago

Anything1365 commented 5 months ago

Hello,

When trying to download a live video via 'N_m3u8DL-RE "URL" --save-name "output" --no-log --live-real-time-merge --live-pipe-mux', it downloads the live video, but the audio and video are out of sync. Generally, when downloading normal videos with defined timestamps, everything is okay. However, this issue only occurs with live videos.

I want to add that when I download a live video without '--live-pipe-mux' and then stream the two files '.mp4' and '.m4a', everything works great. But when I try to merge the files (with ffmpeg or mkvmerge), the merged video lacks audio and video sync (even after the live broadcast).

Thank you.

Anything1365 commented 5 months ago

I've identified a solution to the issue. It appears that certain types of live videos experience problems, while others function correctly. For these problematic video types, I've discovered that using the following command resolves the issue:

ffmpeg -readrate 1 -i "INPUT_VIDEO_FILE_NAME.mp4" -ss 1.2 -i "INPUT_AUDIO_FILE_NAME.m4a" -c copy "OUTPUT_VIDEO_FILE_NAME.ts"

This command effectively adjusts synchronization and fixes the audio-video sync problem.

[By removing "--live-pipe-mux" from 'N_m3u8DL-RE "URL" --save-name "output" --no-log --live-real-time-merge --live-pipe-mux' (which runs in the background before executing the ffmpeg command)].