I am trying to download a stream from this website : https://www.elahmad.com/tv/mobiletv/glarb.php?id=aflam_maroc, using ffmpeg but a weird bug sometimes appears where the recording will jump, repeat the sequence then audio will be high pitched and intermittent silence noise will mess up the recording, and this continues for the whole recording until I stop the command and run it again, then it gets fixed. I tried yt-dlp but it resulted in the same issue.
The link attached is an example of it happening, and it continuing through the whole recording to the end : https://youtu.be/-MWN5zo6hjw
Commands used : ffmpeg -i $(cat link.txt) -c copy "1.mkv" / .\yt-dlp.exe $(cat link.txt)
(link.txt contains the link generated by a script that pipes the m3u link)
Also as a side note I'm fairly sure the issue isn't from the website as I was watching it live and the sound was good but the recording was messed up nonetheless.
Other side note, as I tried to trim it to send to the forum, the editor I'm using (Shotcut) kept crashing where the bug starts, and using the built-in windows 10 editor produced a file where the audio was out of sync, so I finally resorted to simply screen record.
+ Reply to Thread
Results 1 to 27 of 27
-
-
(I'm not used to Stream-Recorder maybe it's better than N_m3u8DL-RE)
Try running :Code:N_m3u8DL-RE index.m3u8 --live-real-time-merge
-
-
streamlink "https://cdn8.elahmad.online/tv529_www.elahmad.com_aflam_maroc/index.m3u8?token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614" best -o video.ts
-
The first file outputted was fine, but the one after has delayed audio, however it does seem that the audio bug specified has yet to surface. I will now try the streamlink method and see if it gives better results
-
Update : the audio bug is not present but unfortunately like the previous method it started fine but eventually started generating files with delayed audio. I'm updating ffmpeg and seeing if that maybe is the cause of this.
Also this might be of help to explain the delayed audio but I keep getting this error :
C:\Users\hp\Desktop\mov\12.mkv
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[download] Written 211.50 KiB to C:\Users\hp\Desktop\mov\12.mkv (0s) [stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[download] Written 428.87 KiB to C:\Users\hp\Desktop\mov\12.mkv (10s @ 43.39 KiB/s) [stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[download] Written 846.00 KiB to C:\Users\hp\Desktop\mov\12.mkv (10s @ 81.26 KiB/s) [stream.hls][warning] Encountered a stream discontinuity. This is unsupported and will result in incoherent output data.
[download] Written 8.55 MiB to C:\Users\hp\Desktop\mov\12.mkv (1m04s @ 49.04 KiB/s) [stream.hls][warning] No new segments in playlist for more than 15.00s. Stopping...Last edited by wah; 17th May 2024 at 03:18. Reason: added error
-
Code:
token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614
-
-
When the token expires, I run a script to fetch a new one and pipe to the streamlink command
-
Okay so from the looks of it, the issue was related to the fact I was outputting the file to mkv not ts, I left it runnning around the day with the .ts extension and this time audio stayed synced up. However using video in .ts format whenever I jump to a segment of the video I need to wait a bit before the video loads up correctly, how can I fix that ?
Also I will now try this ffmpeg method you suggested. -
Last edited by white_snake; 17th May 2024 at 16:31.
-
Okay, I will look into it. I was also wondering if the solution proposed by LZAA requires that the tokens have the same expiration time because I don't know if they contain information that could help me find when they expire for each one, as judging from how the script behaves, all links don't seem to expire at the same rate, some going for around 3 hours and some only last a couple seconds.
-
No. I didn't express myself accurately.
It is necessary to determine the time interval during which one 'token' value is used in 'm3u8' requests. -
Last edited by wah; 18th May 2024 at 11:21.
-
In 'Developer Tools', use the 'm3u8' filter.
Use a 'screen capture' app. Turn on the capture.
Reload the page in your browser. Minimize the browser window. Window 'Developer Tools' should remain.
Keep an eye on the 'token' value occasionally. After it changes, stop capturing the screen.
In the saved video, determine the time of appearance of another 'token' value by the clock in the system tray. Calculate the usage time of the first 'token' value. -
Alright I will do that, but wouldn't just knowing how long one token lasts be not enough, since like I said earlier I noticed that the outputted recordings end up having different lengths like 3 hours for some and only a few minutes for others. Won't that be a problem to find a consistent metric to measure the expiry of the tokens ?
-
I'm not sure there is a strict sequence in changing token values. This can happen when advertising blocks are turned on or depend on the time of day. Watch this over time.
-
Update : The streamlink solution has been the best in terms of stability of the output, even after updating ffmpeg the issue remained. However recently had this bug happen while using streamlink : https://youtu.be/Qr6JOW2HBss?si=Ce_o-xDOuKmCDZ91 but luckily unlike ffmpeg it only affected this recording, the other ones were properly synced. Is there a parameter I could add to prevent this from happening ?
-
-
-
Alright I see, I think given everything I tried I will stick with using streamlink and ts as it is by far the most stable thing I tried, thank you guys again for your insight and time.
Similar Threads
-
Downloading an HLS stream: ONLY in sync when downloading with ffmpeg. Possi
By royjeon215 in forum Video Streaming DownloadingReplies: 6Last Post: 21st Jan 2024, 02:56 -
Downloading HLS stream
By Ukarer in forum Video Streaming DownloadingReplies: 2Last Post: 18th Jan 2022, 06:27 -
FFMPEG Save video from rtsp stream to hls stream
By Wisperrio in forum Video Streaming DownloadingReplies: 2Last Post: 26th Aug 2021, 22:38 -
Help downloading HLS protected stream
By AliasZA in forum Video Streaming DownloadingReplies: 2Last Post: 27th Apr 2021, 15:22 -
HLS Protected Stream Downloading Help
By Yamiraan in forum Video Streaming DownloadingReplies: 6Last Post: 30th Mar 2021, 15:57