damontecres / StashAppAndroidTV

Android TV App for Stash
GNU Affero General Public License v3.0
84 stars 4 forks source link

Direct stream MPEG-TS? #302

Closed htpcforall closed 3 months ago

htpcforall commented 3 months ago

Question

It appears that Media3 Exoplayer can play MPEG-TS. I am playing m3u8 files that contain ts segments. The streams are being transcoded on my server instead of direct playback. Shouldn't these stream direct? Please advise. Thanks.

damontecres commented 3 months ago

I think https://github.com/damontecres/StashAppAndroidTV/pull/303 will fix this issue

htpcforall commented 3 months ago

Hello. Thanks for the quick response. After applying the update, mpegts is checked under Direct Play Formats, server is still transcoding streams. Any thoughts on this?

Update: Seems to be an Exoplayer issue. Exoplayer will play the original direct m3u8 link no problem, but it will not play the direct url provided by stash server. VLC, however, will play both without issue.

Update 2: This may be nothing, but there's a graphql FindScenes request made that returns several mime types. I noticed that mime_type video/MP2T (mpegts) was missing. Could this be the problem?

htpcforall commented 3 months ago

I think #303 will fix this issue

Streams are still being transcoded. Also, I noticed on the scene details page, it says Format: hls (unsupported) which doesn't make sense to me as exoplayer can play hls.

damontecres commented 3 months ago

Sorry I didn't realize you were trying to play an m3u8. I missed it in the original post.

I don't think this app can direct play an m3u8 playlist without server-side changes. The server provides scene.paths.stream which is basically a direct download of the scene's first video file. Additionally, the server has scene.sceneStreams which are the transcoded stream URLs.

So direct playing an m3u8 file just downloads a plaintext file that has a list of segment files. The player will then try to get the mpeg-ts segments from the server.

As far as I can tell, the server doesn't currently support serving up those segment files.

htpcforall commented 3 months ago

Sorry I didn't realize you were trying to play an m3u8. I missed it in the original post.

I don't think this app can direct play an m3u8 playlist without server-side changes. The server provides scene.paths.stream which is basically a direct download of the scene's first video file. Additionally, the server has scene.sceneStreams which are the transcoded stream URLs.

So direct playing an m3u8 file just downloads a plaintext file that has a list of segment files. The player will then try to get the mpeg-ts segments from the server.

As far as I can tell, the server doesn't currently support serving up those segment files.

Yeah. I figured that out when I setup a reverse proxy and rewrote the url to omit .m3u8. Nice try. Such an unnecessary waste of bandwidth. It seems like it should be easy for the player to read the playlist and play the segments. Any thoughts?

htpcforall commented 3 months ago

In Android, when opening the server chrome, selecting a scene, then selecting the play with external player button, the scene will play an m3u8 direct as expected ( I used VLC). Would it be possible to add that feature to this app?

damontecres commented 3 months ago

Sounds like your m3u8 playlist isn't referencing files on the server but maybe instead remote URLs? If can you send me a copy of the m3u8 file on Discord, I can investigate more.

Also, have you tried forcing direct play? It's an button at the bottom of the scene details page.

htpcforall commented 3 months ago

Yes, the playlist is referencing remote urls. Direct play says "Playback error, Source error". I'll send you an m3u8 on discord. Thanks.

htpcforall commented 3 months ago

I just noticed something odd. "Content-Type: audio/x-mpegurl" is being sent in the direct play response headers. Shouldn't that be something like "application/x-mpegurl"?