VideoHelp Forum




+ Reply to Thread
Results 1 to 27 of 27
  1. 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.
    Quote Quote  
  2. Member aqzs's Avatar
    Join Date
    Mar 2024
    Location
    Paris
    Search Comp PM
    Originally Posted by wah View Post
    I am trying to download a stream from this website : https://www.elahmad.com/tv/mobiletv/glarb.php?id=aflam_maroc
    (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
    It's working fine for me
    Quote Quote  
  3. Originally Posted by aqzs View Post
    Originally Posted by wah View Post
    I am trying to download a stream from this website : https://www.elahmad.com/tv/mobiletv/glarb.php?id=aflam_maroc
    (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
    It's working fine for me
    Alright, I am now trying it out, I'll update you if it fixed my issue.
    Quote Quote  
  4. streamlink "https://cdn8.elahmad.online/tv529_www.elahmad.com_aflam_maroc/index.m3u8?token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614" best -o video.ts
    Quote Quote  
  5. Originally Posted by aqzs View Post
    Originally Posted by wah View Post
    I am trying to download a stream from this website : https://www.elahmad.com/tv/mobiletv/glarb.php?id=aflam_maroc
    (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
    It's working fine for me
    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
    Quote Quote  
  6. Originally Posted by LZAA View Post
    streamlink "https://cdn8.elahmad.online/tv529_www.elahmad.com_aflam_maroc/index.m3u8?token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614" best -o video.ts
    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
    Quote Quote  
  7. Code:
    token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614
    'token' does not last forever. It needs to be changed after some time.
    Quote Quote  
  8. Originally Posted by LZAA View Post
    Code:
    token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614
    'token' does not last forever. It needs to be changed after some time.
    Yes I know I'm using a script to update it but is that what is causing this audio issue ?
    Quote Quote  
  9. I can't imagine how 'Streamlink' could change the URL 'on the fly'.
    Quote Quote  
  10. Originally Posted by LZAA View Post
    I can't imagine how 'Streamlink' could change the URL 'on the fly'.
    When the token expires, I run a script to fetch a new one and pipe to the streamlink command
    Quote Quote  
  11. The saved media file will be corrupted at the end. You can calculate how long a token lasts and use FFmpeg:

    ffmpeg -t xx:yy:zz -i URL -c copy video.ts
    Quote Quote  
  12. Originally Posted by LZAA View Post
    The saved media file will be corrupted at the end. You can calculate how long a token lasts and use FFmpeg:

    ffmpeg -t xx:yy:zz -i URL -c copy video.ts
    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.
    Quote Quote  
  13. Originally Posted by wah View Post
    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.
    That's just the nature of the TS container. It's more robust for recording/live streaming, but it's not optimal for local playback/seeking. FLV could be a good compromise in your case, so you might want to try that one.
    Last edited by white_snake; 17th May 2024 at 16:31.
    Quote Quote  
  14. Originally Posted by white_snake View Post
    Originally Posted by wah View Post
    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.
    That's just the nature of the TS container. It's more robust for recording/live streaming, but it's not optimal for local playback/seeking. FLV could be a good compromise in your case, so you might want to try that one.
    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.
    Quote Quote  
  15. Trace in 'Developer Tools' the time intervals between shifts 'm3u8'.
    Quote Quote  
  16. Originally Posted by LZAA View Post
    Trace in 'Developer Tools' the time intervals between shifts 'm3u8'.
    Okay so looking in developper tools, I noticed that each new request gets sent at about 10 seconds of interval, does this mean I should run ffmpeg -t 00:00:10 -i URL -c copy video.ts so that the command stops and fetches a new link every ten seconds ?
    Quote Quote  
  17. 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.
    Quote Quote  
  18. Originally Posted by LZAA View Post
    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.
    Alright, could you please guide me through the steps to accomplish this ?
    Last edited by wah; 18th May 2024 at 11:21.
    Quote Quote  
  19. 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.
    Quote Quote  
  20. Originally Posted by LZAA View Post
    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 ?
    Quote Quote  
  21. 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.
    Quote Quote  
  22. Originally Posted by LZAA View Post
    streamlink "https://cdn8.elahmad.online/tv529_www.elahmad.com_aflam_maroc/index.m3u8?token=ee9cc58f0f18af8fb58ce16e7d07a3306 57edeca-ecb2273c64f810683a19a88edab5bff5-1715862414-1715851614" best -o video.ts
    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 ?
    Quote Quote  
  23. Did you do what I recommended?
    Quote Quote  
  24. Originally Posted by LZAA View Post
    Did you do what I recommended?
    Yes, and confirmed what I said earlier in the thread, the links get changed at different intervals, some stay valid for multiple hours and others only few minutes, so I don't think I can give a specific time to ffmpeg
    Quote Quote  
  25. Originally Posted by white_snake View Post
    Originally Posted by wah View Post
    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.
    That's just the nature of the TS container. It's more robust for recording/live streaming, but it's not optimal for local playback/seeking. FLV could be a good compromise in your case, so you might want to try that one.
    I now tried the flv method and while the audio is fine, I did notice that playback behaves the same way as ts files do. Is that expected behaviour ?
    Quote Quote  
  26. Originally Posted by wah View Post
    I now tried the flv method and while the audio is fine, I did notice that playback behaves the same way as ts files do. Is that expected behaviour ?
    Yup, in my experience videos in FLV container are not supposed to have quick seeking. Even tools like OBS record in FLV by default for robustness and then let you remux everything in MP4 once the recording is over.
    Quote Quote  
  27. Originally Posted by white_snake View Post
    Originally Posted by wah View Post
    I now tried the flv method and while the audio is fine, I did notice that playback behaves the same way as ts files do. Is that expected behaviour ?
    Yup, in my experience videos in FLV container are not supposed to have quick seeking. Even tools like OBS record in FLV by default for robustness and then let you remux everything in MP4 once the recording is over.
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!