Jellyfin Forum
Issue streaming live tv from M3UTunerHost - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Development (https://forum.jellyfin.org/f-development)
+--- Forum: Server Development (https://forum.jellyfin.org/f-server-development)
+--- Thread: Issue streaming live tv from M3UTunerHost (/t-issue-streaming-live-tv-from-m3utunerhost)



Issue streaming live tv from M3UTunerHost - c172r_crusty#9441 - 2023-08-12

I am looking for help with getting M3U liveTV to work on my windows dev setup. I am able to view channels for my m3u iptv provider and have verified the streams being loaded by jellyfin are valid. I think when the live stream is being loaded / copied to the shared stream there an issue but am not sure based on exception thrown as pretty generic. 

I have a Visual Studio project runnon on a windows box using the .sln in the git repo. server version is 10.9.0. I was not able to build that project with jellyfin-web served from it so run jellyfin-web seperatly then connect to my local 8096 server from that web client on 8080. not sure I set that up correct for my dev environment but it works. I can use Jellyfin normal with my library files streaming correctly from the web client. I was not able to use the -InstallFFMEPG option on my server but manually downloaded (what I think is correct version) the jellyfin windows compiled FFMPEG and pointed to it from Jellyfin config. I also have number of tunors set to 10 to make sure the code to check that limit is not hit and streaming would occur.

I have traced as far as 
Code:
await StreamHelper.CopyToAsync(
    stream,
    fileStream,
    IODefaults.CopyToBufferSize,
    () => Resolve(openTaskCompletionSource),
    cancellationToken).ConfigureAwait(false);

in SharedHttpStream.cs and it seems to be where issue starts at - but am not sure. It looks like the code to copy over the stream from the iptv url is not working. I am wondering if there is maybe a 'RAW' mode or something for iptv streams I am not setting? or permissions in windows on target folder? 
Code:
[12:57:26] [INF] [69] Emby.Server.Implementations.LiveTv.TunerHosts.M3UTunerHost: Opening SharedHttpStream Live stream from https://lb.privatevps.org/play/<NOTREALURL>MAu_pFImttgCagZVRwrcqya-quaFne6
[12:57:28] [INF] [60] Emby.Server.Implementations.LiveTv.TunerHosts.M3UTunerHost: Beginning SharedHttpStream stream to C:\Users\windo\AppData\Local\jellyfin\cache\transcodes\0f2d014b559b4199965a41e0750585bb.ts
[12:57:29] [WRN] [69] Emby.Server.Implementations.LiveTv.TunerHosts.M3UTunerHost: Zero bytes copied from stream SharedHttpStream to C:\Users\windo\AppData\Local\jellyfin\cache\transcodes\0f2d014b559b4199965a41e0750585bb.ts but no exception raised
[12:57:29] [INF] [60] Emby.Server.Implementations.LiveTv.TunerHosts.M3UTunerHost: Deleting temp file C:\Users\windo\AppData\Local\jellyfin\cache\transcodes\0f2d014b559b4199965a41e0750585bb.ts
[12:57:30] [ERR] [69] Emby.Server.Implementations.LiveTv.TunerHosts.M3UTunerHost: Error opening tuner
System.IO.EndOfStreamException: Zero bytes copied from stream SharedHttpStream
  at Emby.Server.Implementations.LiveTv.TunerHosts.SharedHttpStream.Open(CancellationToken openCancellationToken)

any help would be appreciated.


RE: Issue streaming live tv from M3UTunerHost - c172r_crusty#9441 - 2023-08-12

This is what chatGPT says to check and I think it is onto something for item

"Examine Transcoding Settings: Sometimes the issue can be with the transcoding of the stream to a temporary file. Check the settings related to transcoding and make sure they are compatible with the IPTV stream you're trying to watch."

how do I check transcode settings for the IPTV stream?

------------------
from gpt
------------------

The error log you've shared provides good information about the issue, and the System.IO.EndOfStreamException is particularly informative. This error typically occurs when you're trying to read from a stream that has no data or has reached the end of the file before you expected it to. Here's a step-by-step approach you might take to diagnose and potentially resolve the problem:

Verify the URL: Ensure that the URL you're trying to stream from (https://lb.privatevps.org/play/<NOTREALURL>MAu_pFImttgCagZVRwrcqya-quaFne6) is valid and accessible. Try opening the URL directly in a browser or another player that can handle streaming to see if the content is there. If the URL is a placeholder, ensure that the actual URL is being correctly passed in your code.

Check Network Permissions: Sometimes, the application might not have the required permissions to access the network or the URL in question. Look into the network permissions and firewall settings to make sure they aren't blocking the stream.

Review the Code for Opening the Stream: In the class M3UTunerHost, closely look at how the stream is being opened. Ensure that the stream is being properly initialized and that there's no premature closing or reading beyond the end of the stream.

Examine Transcoding Settings: Sometimes the issue can be with the transcoding of the stream to a temporary file. Check the settings related to transcoding and make sure they are compatible with the IPTV stream you're trying to watch.

Debug in Real-time: If possible, run the application in debug mode and step through the code line by line in the M3UTunerHost class, particularly where the stream is being opened and copied. This can provide more context to the error and help pinpoint the exact cause.

Check Dependency Versions: Sometimes, these issues might be related to using an outdated or incompatible version of a library or dependency. Make sure you are using versions that are known to be compatible with each other.

Consider Community Support: If you continue to experience issues, consider reaching out to Jellyfin's community, such as forums or GitHub issues. The developers or other users who have faced similar issues might be able to provide specific guidance.

Remember to replace any sensitive information like URLs or access tokens before sharing your code or error logs with others.