jellyfin / jellyfin-plugin-intros

Intros Plugin for Jellyfin
GNU General Public License v3.0
48 stars 10 forks source link

Preroll videos always transcoded #11

Closed Lodeli closed 1 year ago

Lodeli commented 1 year ago

Hi all, my JF server is in a Docker container on a RPI 4. I've downloaded all the prerolls videos from the archive on Discord and I've also converted all of them to H264 AAC. I can DirectPlay all of the videos when added the folder as a new library.

Anyway, I can't directly reproduce any of these videos as preroll on Fire TV and Android app: they only work on Web browser.

When playing from Fire TV or Android app, it seems that the DirectPlay encounters an error. This is what I find in my logs:

[2023-05-04 20:45:35.792 +02:00] [INF] [11] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="Anonymous Profile", Path="/media/prerolls/Paint Splash Jellyfin Pre-roll.m4v", AudioStreamIndex=1, SubtitleStreamIndex=null ) => ( PlayMethod=Transcode, TranscodeReason=DirectPlayError ) "media:/videos/4175b670-8da9-4665-8857-8c75968e6f44/stream?MediaSourceId=4175b6708da9466588578c75968e6f44&AudioStreamIndex=1&api_key=<token>&RequireAvc=false&Tag=d7f8f0a1422251cfab54e091688543d1&TranscodeReasons=DirectPlayError"
[2023-05-04 20:45:35.893 +02:00] [INF] [82] Jellyfin.Api.Helpers.TranscodingJobHelper: "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -fflags +genpts -f mov,mp4,m4a,3gp,3g2,mj2  -i file:\"/media/prerolls/Paint Splash Jellyfin Pre-roll.m4v\" -map 0:0 -map 0:1 -map -0:s -codec:v:0 copy -map_metadata -1 -map_chapters -1 -threads 0 -codec:a:0 copy -y \"/config/data/transcodes/ba8150950d36d3ba0fc4ffb84686a1ad.mov\""
[2023-05-04 20:45:36.162 +02:00] [INF] [28] Jellyfin.Api.Helpers.TranscodingJobHelper: FFmpeg exited with code 0
[2023-05-04 20:45:37.147 +02:00] [WRN] [82] Jellyfin.Server.Middleware.ResponseTimeMiddleware: Slow HTTP Response from "https://xxx.xxx.xxx.xxx/videos/4175b670-8da9-4665-8857-8c75968e6f44/stream?DeviceId=edc7cc1a87d48f8d6d07030dda994c72b9568a03059f37b3&MediaSourceId=4175b6708da9466588578c75968e6f44&AudioStreamIndex=1&PlaySessionId=ef9428e88596495b94e69d06bee15016&api_key=1c76fefb59c54f4fab2148619cffe28f&RequireAvc=false&Tag=d7f8f0a1422251cfab54e091688543d1&TranscodeReasons=DirectPlayError&allowVideoStreamCopy=false" to "10.0.0.x" in 0:00:01.299281 with Status Code 200
[2023-05-04 20:45:38.311 +02:00] [INF] [10] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "FireTV". EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: False EnableAudioPlaybackTranscoding: True
[2023-05-04 20:45:38.312 +02:00] [INF] [10] Jellyfin.Api.Helpers.MediaInfoHelper: StreamBuilder.BuildVideoItem( Profile="Anonymous Profile", Path="/media/prerolls/Paint Splash Jellyfin Pre-roll.m4v", AudioStreamIndex=1, SubtitleStreamIndex=null ) => ( PlayMethod=Transcode, TranscodeReason=DirectPlayError ) "media:/videos/4175b670-8da9-4665-8857-8c75968e6f44/stream?MediaSourceId=4175b6708da9466588578c75968e6f44&AudioStreamIndex=1&api_key=<token>&RequireAvc=false&Tag=d7f8f0a1422251cfab54e091688543d1&TranscodeReasons=DirectPlayError"
[2023-05-04 20:45:38.376 +02:00] [INF] [10] Jellyfin.Api.Helpers.TranscodingJobHelper: Deleting partial stream file(s) "/config/data/transcodes/ba8150950d36d3ba0fc4ffb84686a1ad.mov"
[2023-05-04 20:45:38.459 +02:00] [INF] [10] Jellyfin.Api.Helpers.TranscodingJobHelper: "/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -fflags +genpts -f mov,mp4,m4a,3gp,3g2,mj2  -i file:\"/media/prerolls/Paint Splash Jellyfin Pre-roll.m4v\" -map 0:0 -map 0:1 -map -0:s -codec:v:0 copy -map_metadata -1 -map_chapters -1 -threads 0 -codec:a:0 copy -y \"/config/data/transcodes/5acb96d15c283de214b50fb409bc8639.mov\""
BrianCArnold commented 1 year ago

The plugin provides the intro library item to the Jellyfin intro system, which is supposed to process the series of items as a playlist.

I've noticed an issue with playing them on Android as well, but I think this is an issue with Jellyfin itself. I'll have to crawl into the code and figure out what's going on in the Jellyfin server itself, and if it's the server, the client, or something else.

In order to verify this, it may be useful if anyone can test any other plugin that adds prerolls, like the original plugin.

A way around this is to turn off "Cinema Mode" in clients that are having issues. It won't show the prerolls, but it will skip trying to play them.

Lodeli commented 1 year ago

Thank you for the quick response. I've never seen the Jellyfin code but I've tried to check it too and indeed it seems to me that the IIntroProvider interface just returns an enumerable of IntroInfo items that, inside the Jellyfin system, the ResolveIntro() method transform into Video object.

At some point anyway something breaks and it has to be caused by the item being an intro and not a normal playlist item.

In fact, If I add the prerolls folder as a normal library, I can play the items with no issues on FireTV and Android mobile app.

Anyway, even if I'm a C# dev, I know nothing about JF code. I will try to help with my limited free time as far as I'm able to, though.

Lodeli commented 1 year ago

Checking the differences in server behaviors between intros and main file didn't lead me to anything. In both I found _dtoService.GetBaseItemDto(item, dtoOptions, user); and the objects involved seem the same.

But I've found a difference from the dkanada plugin. When it adds a new video (local or downloaded) to its cache, it calls its private method UpdateLibrary() in which there's this line: Plugin.LibraryManager.CreateItem(video, null);

Maybe this is something of any importance? I'd really like to be of any help but I have no clue of what I'm seeing here.

BrianCArnold commented 1 year ago

iirc, his plugin re-added the same video to the library multiple times every time, my plugin makes sure that it doesn't clog up the library with multiple references to the same file. That line shouldn't be related to the determination of whether to transcode.

I can try later on to run jellyfin on a raspberry pi to see if it does the same thing, but if it does, it would still be a bug in the central application, not the plugin.