-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp Device Profile Builder #519
Conversation
Removed device-specific identifier and replaced with built-in AVFoundation check to see if codec is playable. All devices that support iOS 15 (minimum required) support AC3/EAC3 so only check for FLAC (in native player) and HEVC (in both native and VLCKit).
Native player profile: - Remove h263 from native direct play profile because it is unsupported in mpegts and ffmpeg does not support muxing it into mp4. - Remove alac from native direct play profile because it is unsupported in mpegts, which is currently being used for HLS direct play streams. - Remove flac check and flac from native profile because it is unsupported in mpegts. VLCKit player profile: - Add h263 to direct play profile because it was removed from base. - Add in missing flv1 to direct play profile. - Add alac to direct play profile because it was removed from base. - Remove dca from direct play and transcoding profiles because I believe dts covers that codec. - Remove flac, vp8, theora, msmpeg4v2, msmpeg4v3, wmv1, wmv2, vorbis, wmav2, pcm_s24le from transcoding profile because they are unsupported in mpegts.
WAV is an audio container format and should not have been in the video profile
Thanks for the very comprehensive write up! I've CC'd the JF devs to potentially get some server insights to many of the questions regarding what the server expects, profiles, transcoding expectations and such. You know a lot more than I do for this, so I'm going to be playing a lot of catch up. I'll be able to give a more in depth comment later but regarding some of the development stuff:
Yes and thank you, this is how it should be.
It seems like FLAC was introduced in iOS 11? This discussion says that it supports it 🤷
VLCKit via the simulator is overall slow and only to prove that playback can happen. It's just laggy but should work just fine since you can build the application, meaning you have the correct libraries. Regarding the simulator in this and the previous point, I've also asked my local dev community to see if the simulator is an actual "simulator" of the device (and would returns their correct corresponding types from
We should be fine on the VLCKit front as we haven't received any issues regarding subtitle support yet. (this differs from the other subtitle issues we currently have)
We can just have this be a computed variable on |
Add FLAC DirectPlay support Fix string builders for codec strings
Native player only supports VTT external subs Get rid of duplicates in VLCKit player
Thanks for the offer - the issue with my testing initially was actually having a mac with a new-enough version of Xcode, but I've solved that! I have answered and completed some of the tasks here; I need to update the list. I'm running into a few issues that I think are server-side, and I'm eyeing some in-progress PRs that I hope will solve them. (I don't want to push a device profile that will cause less functionality because there is an active issue server-side.) |
Change maxAudioChannels from 6 to 8 in Transcoding Profiles
Change transcodingMaxAudioChannels to 8 from 6 in HLS builder
Okay I think this is ready for review/comments. (And could use some testing from someone else probably.) Changes from original idea:Whereas before I was going to query for HEVC and FLAC, I've decided against that. Querying can be messy and imprecise as I detailed in the OP. As far as I can tell, FLAC can be software or hardware decoded by all devices without issue and HEVC only affects three devices that support iOS/tvOS 15 but have an A8 chip (i.e. no HEVC hardware decoding): Apple TV HD, iPad Air 2, iPad Mini 4 - but it can software decode at least on Apple TV HD. I'm assuming it can either software decode on the others as well or those devices are old enough (7+/8+ years) that it won't be an issue. This means that device profiles are static! I've left some comments in the code, but I have made the DirectPlay profile for VLCKit so it only defines audio codecs; basically any container/video codec should pass through for DirectPlay. The way I see it, anything I know of that jellyfin can detect (and ffmpeg can transcode) is supported by VLCKit other than TrueHD/mlp. If someone finds another codec that can be decoded server-side but not in VLCKit, we can add it or change strategy there. Other changesI've gotten rid of fmp4 experimental option and just switching to mp4 for all HLS transcoding/remuxing; while ts supports more in terms of older formats, there are really only a few cases where transcoding will actually happen for VLCKit player - namely, 1) when TrueHD/mlp audio is selected and 2) when server forces a transcode for bitrate reasons. In case one, it is unlikely the video codec won't be able to pass through so we would get DirectStream. In case 2, video needs to be transcoded anyway, so we might as well transcode it to h264 or hevc and then mp4 container will fit well there. It shouldn’t happen with external subtitles on VLCKit because they can be passed externally as well. As the DirectPlay profile is defined right now, I don't think remuxing will ever happen for VLCKit. I've changed the maxAudioChannels to 8 from 6 because iOS/tvOS can handle 8 channels and tvOS can spit out 8 channel LPCM. This enables us to output DTS-HD MA up to 7.1 losslessly as well as TrueHD/mlp (transcoded server-side to FLAC) losslessly. It is waiting for my PR (jellyfin/jellyfin#9266) to hit serverside, though. Until then, channel limit is stuck at 6 server-side. I've changed it so the native player will actually DirectPlay vs. requesting an HLS stream for things it can actually DirectPlay. I believe this is important for content like MP4 with HEVC HDR and compatible audio (maybe AC3) because then this file can be played on SDR screens and native player will tonemap. However, more importantly perhaps, it maintains the meaning of DirectPlay and if user does not have permission to remux server-side, it will no longer do so. Why choose VLCKit or Native player?
What doesn't work yet?
Misc. NotesWould like at some point to figure out VP8/VP9 support for native player...very unclear what is actually supported. Please ask if there are questions. While the code changes are not that large themselves, there is so much at play here in terms of what is actually limited/defined server-side or by Apple or by ffmpeg or by HLS, etc. I'll say I found it extremely difficult to find documentation about these profiles. |
This looks great! I'm hoping this will be merged and released soon. |
Thank you for working on this! This will require testing and will be merged after #593. I don't think there will be many conflicts. |
I can confirm that this fixes #790, after toggling this patch on my local build, it seems to automatically "work" for my Apple TV HD. Additionally, I'm not too sure about the approach to not conditionally enable better codec options for future devices, as while the "lowest" profile for VLCkit seems to be alright, I'm not sure if that'll satisfy 4K HDR video and whatnot. But, for the reason to create a proper codec base for Apple devices, and continue from there, this will work. |
So with this, I've always wanted to learn more about how the server works and test on a variety of media configurations. I was sitting down to do this but I just don't have the time or expertise to focus on this system of the app/server. Due to that, assume my answer to all of these questions is 🤷. I know that it may be disappointing/upsetting that this PR has lived for so long and I can't provide any direction about whether this is correct or not, but I do like it a lot better than the manual specification that we did before. I am confident that this is a very large step in the right direction and we can, obviously, fix any issues that arise. I know that as we all learn more about the server we can answer some of these questions (ex: why remux if not necessary, how is HDR specified, codec ordering) and implement the work accordingly. I am comfortable with this implementation and luckily it's very localized so we can revert if necessary. If you are comfortable as well, this can be merged. |
@holow29 and @LePips I just created this repository https://github.com/AhsanFazal/avplayer-supported-media-types/. This repository contains the static files that class func isPlayableExtendedMIMEType(_ extendedMIMEType: String) -> Bool This function above calls a static function of With these files, we I think we now have all the information we need to determine the EXACT native playback capabilities of each device. @holow29 I would love to work together with you on finishing this PR. Let me know if you'd like that! :) |
@AhsanFazal Thanks for your work extracting those files. I was using isPlayableExtendedMIMEType originally, but it didn't prove to be extremely helpful. I left some notes in the OP explaining why (under the list of MIME types I put together and in the "To Note" section); the gist is that unless something has changed in iOS 16/17 there is no way to properly query for playability of a codec/MIME type in a container using isPlayableExtendedMIMEType AFAIK - and Apple is extremely picky about being able to play some codecs only in certain containers. If you've found otherwise, I would obviously be interested in that. Additionally, for practically all codecs apart from newer ones like AV1 or AC4, the limitation of iOS 15/tvOS 15 normalizes the codec limitations across almost all supported devices. The exception is HEVC support for ~2 iPad models, but it was similarly unclear if isPlayableExtendedMIMEType would be helpful in this instance because I believe software-decoding of HEVC was added even though it isn't performant; I don't recall what is returned on these. Regardless, the MediaValidator.plist file might still be helpful in determining some of the more specific limitations such as HEVC profiles, etc. |
I believe linting check is failing because of files without 2024 in the header. 15 Pro simulator (even though it should support AV1 hardware decode) is not reporting success using isPlayableExtendedMIMEType, so I left it out. Issues that might be solved by merging:
Refer to my above comment for more information about things that are not solved/potential issues that might become more apparent because of this PR. In addition to that, there might be more to investigate re: HDR and any signalling that must go on from OS(/TV) -> App -> Server. |
The build is failing on tvOS so we need to fix that, however the lint I can approve without it succeeding and we can get that later. I think I will quickly refactor this into I will consider this the work done for #296, so this will close that and ongoing work is always implied. Here is my stance on all of the playback issues: I have always wanted to close them. We don't control playback, we hand that off to VLCKit or AVPlayer and all we do is construct the URLs, so I never thought of them as actually a concern of ours. I actually will close them sometime but I have deferred that to when I get to implementing mpv and will update how we accept issues around anything playback related. While this does solve some issues, my policy would have always been: direct play or transcode your media to something more usable. I'm grateful for all the work that you've done here and the research done by @AhsanFazal to get this through! |
I am having difficulty seeing why it is failing on here; I expected to see a log but it just says the job failed. Build succeeds on my end, and tvOS has been my main testing ground. Please let me know if there is something I am missing!
I think that is sound. Best maybe to make sure that the URL is being constructed correctly and passed off to the players properly to ensure they support everything they should, which this works towards. I think the player issues are somewhat helpful in giving an idea of the player limitations, some of which are documented in this PR thread. Obviously they will change with MPV, though. |
Hm, the tvOS failed build seems to just have been a GH runner issue. I'll go ahead and merge this. |
@LePips Thanks for implementing this. How can I try it on my ATVHD 4? Seems like the latest version on the AppStore is one year old and cant seem to find a testflight version. Thanks! |
@pwntester there is no Testflight build and I think @LePips mentioned there won't be one for tvOS specifically until some more changes can be done. In the meantime you can build and sideload it yourself with Xcode. |
Thanks @ericswpark Is it possible to build swiftfin without an apple developer account? I seem to need a provisioning profile which I dont have |
@pwntester you should be able to build and sign Swiftfin with any Apple account. I'm hazy on the details, but I think you may have to sign up with the developer "program" and accept some ToSes, but you definitely don't have to pay to deploy Swiftfin. Do keep in mind that non-paid accounts can only sign builds that last 7 days, compared to paid developer accounts that can go up to 1 year. Once your developer profile is set up you should be able to select the development team in Xcode, by clicking on the "Swiftfin" project in the sidebar and selecting the profile. |
Draft related to #296.
Background
While theoretically it might make sense to query a given media item at playtime for support (I thought about investigating MediaInfo API maybe) and then send decision to server about play method, I don't believe that the API/server provides that capability. It seems architected in the opposite way using these device profiles.
Before, the device profile builder was relying on mapping the device to codec capabilities based on an external mapping of device model to CPU chip. This requires maintenance each time a new device is released, and it appears to be unnecessary given that we can query directly to see if a certain codec is supported, in many cases.
I encountered some difficulty with this because I wasn't sure where to draw the codec names for containers, audio codecs, video codecs, etc. I initially assumed ffmpeg would be good for this, but it appears it might be some combination of ffmpeg, file extensions, and maybe some hard-coded strings server-side. For example, ffmpeg does not use "mkv" but rather "matroska" or "matroska,webm." However, for the container, we use "mkv." To further complicate matters, using AVFoundation's AVURLAsset.isPlayableExtendedMIMEType() relies on the MIME type of the codec/container. Some of these are standardized with the IANA, some are from the MP4 registration authority, and others are from querying Apple's Universal Type Identifiers (UTI) using UniformTypeIdentifiers functions such as UTType.types() and preferredMIMEType. To make things easier, I have come up with the following list:
MIME Types by format/codec
When deciding if media can be played, we must keep in mind the following sources of limitations:
Therefore, querying for support alone is unfortunately insufficient.
Changes to Function
Codec querying
Profile separation
There is now a separate device profile for the native player and the VLCkit one. They share codec conditions and response profiles at the moment because I didn't see fit to separate those too, but containers, video codecs, audio codecs, and subtitle codecs theoretically differ. In the current implementation, VLCKit player only queries for HEVC support since it can software decode FLAC without issue; native player has had blocks on software decoding (which might happen on chips prior to A10). It can also decode HEVC but the experience will be poor unless the chip supports it (I think A9 chip+ required), so we check for it.
To Note
MIME querying
Container/HLS limitations
We have the following examples of limitations based on container (italics mean I am having trouble with ffmpeg muxing):
To Investigate
Needs testing
Meta question/question for devs
Bugs/Unexpected behavior
Codec support
Future Work
Subtitles
Audio transcoding to lossless
Meta optimization/decisions
Querying for support
Code sample
Resources
Possible codecs
Apple HLS
Apple codec support
MIME types
Potential VLCKit codecs
Supported formats in containers