Jump to content

Framerate check causes playback failure or unwanted transcoding


OddbOd

Recommended Posts

Issue description:

Video 1 has a constant frame rate of 60 fps as reported by the server and fails to play when transcoding is disabled, local playback works fine, disabling the framerate check in GuiPlayer_Transcoding.js allows the video to DirectPlay without issue.

Video 2 has a variable framerate averaging 23.97616 fps as reported by the server but is detected by the client as 59.94006 fps, fails to play when transcoding is disabled, local playback works fine, disabling the framerate check in GuiPlayer_Transcoding.js allows the video to DirectPlay without issue.

 

Steps to reproduce:

"Enable Transcoding on D series" is set to False

 

My TV/HTS/BD Player model number:

UA46D7000

 

My firmware version:

1015.0

 

Other TVs etc. the issue has been reproduced on:

BD-H8500A has the essentially the same issue but videos play via transcoding, as with my D series, disabling the framerate check in GuiPlayer_Transcoding.js allows both videos to DirectPlay without issue.

 

My Emby server version:

3.0.5870

 

My current Emby Samsung client version:

D7000 TV: 1.0.7 (git)

D7000 TV: 2.1.0g (git)

BD-H8500A: 2.1.0 (release)

 

Other Emby Samsung versions the issue can be reproduced in:

1.0.2

1.0.3

1.0.4

1.0.5

1.0.6

2.0.3a

2.0.4a

2.0.5b

2.1.0c

2.1.0f

 

Supporting information to include logs and pictures where applicable:

MB3_Log.txt

Emby Application Started
Screensaver enabled.
Key handlers initialised.
Plugins initialised.
Product type is 0
Check physical connection returned 1
Check HTTP returned 1
Check gateway returned 1
Model Year is D
MAC address is 8cc8cd0b0365
Emby server found.
Ready to start. Removing the splash screen.
User <removed> authenticated. 
Video : Loading Farbrausch - The Popular Demo
Video : Find Media Streams
Video : Audio Play Default Track Setting: true
Video : Audio Language Preference Setting: eng
Video : Subtitle Preference: Default
Video : Subtitle Language: eng
Video : First Audio Index : 1
Video : Default Video Index Found : 0
Video : Default Audio Track Found : 1
Video : Audio language und
Video : Media Stream Added : 2D 0,0,1,true,-1
Video : Determine Playback of Media Streams
Video : Video File Analysis Results
Video : Codec Compatibility: true : h264
Video : Container Compatibility: true : mp4
Video : Resolution Compatibility: true : 1280x638
Video : BitRate Compatibility: true : 7054299 : 7054299
Video : FrameRate Compatibility: false : 60
Video : Level Compatibility: true : 31
Video : Profile Compatibility: true : Main
Video : Audio File Analysis Results
Video : Codec Compatibility: true : aac
Video : Container Compatibility: true : mp4
Video : Channel Compatibility: true : 2
Video : Transcode Status : Transcoding Audio & Video
Video : URL : http://192.168.0.200:8096/emby/Videos/16ad5c226d4530660ebfbd10ec9103ea/master.m3u8?VideoStreamIndex=0&AudioStreamIndex=1&VideoCodec=h264&Profile=high&Level=41&MaxVideoBitDepth=8&MaxWidth=1280&VideoBitrate=7054299&AudioCodec=aac&AudioBitrate=360000&MaxAudioChannels=6&MediaSourceId=16ad5c226d4530660ebfbd10ec9103ea&api_key=<removed>&DeviceId=EXCN4UQJHNPSM
Video : Playback NOT Added - Requires Transcode and user setting is off
Video : No Playback Options
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2567ms
Loading : GuiDisplay_Series : User Control : Time 3078ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2626ms
Loading : GuiDisplay_Series : User Control : Time 2936ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2111ms
Loading : GuiDisplay_Series : User Control : Time 2357ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 1877ms
Loading : GuiDisplay_Series : User Control : Time 2414ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2175ms
Loading : GuiDisplay_Series : User Control : Time 2422ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 1873ms
Loading : GuiDisplay_Series : User Control : Time 2115ms
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2085ms
Loading : GuiDisplay_Series : User Control : Time 2380ms
Video : Loading Danger: Diabolik
Video : Find Media Streams
Video : Audio Play Default Track Setting: true
Video : Audio Language Preference Setting: eng
Video : Subtitle Preference: Default
Video : Subtitle Language: eng
Video : First Audio Index : 1
Video : Default Video Index Found : 0
Video : Default Audio Track Found : 1
Video : Audio language eng
Video : Media Stream Added : 2D 0,0,1,true,-1
Video : Determine Playback of Media Streams
Video : Video File Analysis Results
Video : Codec Compatibility: true : h264
Video : Container Compatibility: true : mp4
Video : Resolution Compatibility: true : 718x480
Video : BitRate Compatibility: true : 1252531 : 1252531
Video : FrameRate Compatibility: false : 59.94006
Video : Level Compatibility: true : 31
Video : Profile Compatibility: true : High
Video : Audio File Analysis Results
Video : Codec Compatibility: true : aac
Video : Container Compatibility: true : mp4
Video : Channel Compatibility: true : 2
Video : Transcode Status : Transcoding Audio & Video
Video : URL : http://192.168.0.200:8096/emby/Videos/7c8d26d47ffcf53166d035d42c680081/master.m3u8?VideoStreamIndex=0&AudioStreamIndex=1&VideoCodec=h264&Profile=high&Level=41&MaxVideoBitDepth=8&MaxWidth=1280&VideoBitrate=1252531&AudioCodec=aac&AudioBitrate=360000&MaxAudioChannels=6&MediaSourceId=7c8d26d47ffcf53166d035d42c680081&api_key=<removed>&DeviceId=EXCN4UQJHNPSM
Video : Playback NOT Added - Requires Transcode and user setting is off
Video : No Playback Options
Video : Loading Danger: Diabolik
Video : Find Media Streams
Video : Audio Play Default Track Setting: true
Video : Audio Language Preference Setting: eng
Video : Subtitle Preference: Default
Video : Subtitle Language: eng
Video : First Audio Index : 1
Video : Default Video Index Found : 0
Video : Default Audio Track Found : 1
Video : Audio language eng
Video : Media Stream Added : 2D 0,0,1,true,-1
Video : Determine Playback of Media Streams
Video : Video File Analysis Results
Video : Codec Compatibility: true : h264
Video : Container Compatibility: true : mp4
Video : Resolution Compatibility: true : 718x480
Video : BitRate Compatibility: true : 1252531 : 1252531
Video : FrameRate Compatibility: false : 59.94006
Video : Level Compatibility: true : 31
Video : Profile Compatibility: true : High
Video : Audio File Analysis Results
Video : Codec Compatibility: true : aac
Video : Container Compatibility: true : mp4
Video : Channel Compatibility: true : 2
Video : Transcode Status : Transcoding Audio & Video
Video : URL : http://192.168.0.200:8096/emby/Videos/7c8d26d47ffcf53166d035d42c680081/master.m3u8?VideoStreamIndex=0&AudioStreamIndex=1&VideoCodec=h264&Profile=high&Level=41&MaxVideoBitDepth=8&MaxWidth=1280&VideoBitrate=1252531&AudioCodec=aac&AudioBitrate=360000&MaxAudioChannels=6&MediaSourceId=7c8d26d47ffcf53166d035d42c680081&api_key=<removed>&DeviceId=EXCN4UQJHNPSM
Video : Playback NOT Added - Requires Transcode and user setting is off
Video : No Playback Options
Loading : GuiDisplay_Series : Retrieved Data From Server : Time 2098ms
Loading : GuiDisplay_Series : User Control : Time 2348ms

Video 1

Media Info
Video
CodecH264
Codec tagavc1
ProfileMain
Level31
Resolution1280x638
Aspect ratio640:319
AnamorphicNo
InterlacedNo
Framerate60
Bitrate6888 kbps
Bit depth8 bit
Pixel formatyuv420p
Ref frames5
Audio
Languageund
CodecAAC
Codec tagmp4a
ProfileLC
Layoutstereo
Channels2 ch
Bitrate125 kbps
Sample rate48000 khz
DefaultYes
Containermp4
Path\\192.168.0.200\Multimedia\video\Demos\Farbrausch - The Popular Demo.mp4

 

Video 2

Media Info
Video
CodecH264
ProfileHigh
Level31
Resolution718x480
Aspect ratio16:9
AnamorphicNo
InterlacedNo
Framerate23.97616
Bitrate1223 kbps
Bit depth8 bit
Pixel formatyuv420p
Ref frames4
Audio
Languageeng
CodecAAC
ProfileLC
Layoutstereo
Channels2 ch
Bitrate156 kbps
Sample rate48000 khz
DefaultYes
Audio
Languageeng
CodecAC3
Layoutstereo
Channels2 ch
Bitrate187 kbps
Sample rate48000 khz
DefaultNo
Containermp4
Path\\192.168.0.200\Multimedia\video\Movies\Danger Diabolik\Danger_Diabolik.1968.DVD.mp4

 

I honestly can't see what purpose the framerate check serves as the results are clearly taken from the file header, which in the case of many MP4 and Matroska files, doesn't match the actual rate of the video stream. All it seems to do, at best, is cause unwanted activation of transcoding.

  • Like 1
Link to comment
Share on other sites

FrostByte

The framerate check was put in there using the limitations set by Samsung from the table in your user's manual.  Without some of the checks from the table in there then when an incompatible file is played Samsung devices usually throw up some type of error of their own and in those cases it's better to transcode than not play at all. 

 

Can your files also play from usb connected to your Samsung device?  But ya streaming seems to be slowing it down below 30fps

 56c88605c291e_Untitled.jpg

Edited by FrostByte
Link to comment
Share on other sites

While I can appreciate that sensible limits had to be chosen based on the documentation available, a simple table does not and cannot show what the real limitations are because there are so many interrelated factors at work i.e. codec and resolution and bitrate and framerate. The processing power required to decode High Profile H.264 is much higher than for MPEG-1 at any given resolution, bitrate and framerate yet Samsung's documentation implies that they're equivalent. To paraphrase Richard Feynman, it doesn't matter what the documentation states, if it doesn't agree with experiment, then it's wrong.

 

The table you've shown is not particularly relevant for a few reasons. The first is that I have no idea what device that table relates to, it certainly isn't for my TV, that can be found at http://downloadcenter.samsung.com/content/UM/201201/20120128131854991/[Eng]GPDVBADA-1040.pdf. The second is that the Samsung Emby client covers a broad range of devices and as I stated the same issue is observed on an H series BluRay player.

 

56c967f8e4b03_IMG_20160221_180842.jpg

 

The is no reason it should fail in these circumstances when even the manual states that the maximum framerate at this resolution is 60 not 30:

 

56c96835d22f3_IMG_20160221_181027.jpg

 

The third reason is that the table is apparently for a worst case scenario i.e. H.264 High Profile, 1920x1080, 30fps, 30mbps, HE-AAC audio should still play fine regardless of whether it is playing from a network or local source, also note that Samsung generally lists "Other Restrictions" so even if these guidelines are strictly followed there is still no guarantee that any particular video will play. The Emby client checks assume that each of these factors can be taken in isolation, that is reasonable to avoid the weird errors that you mentioned since Samsung's playback engine is a black box which can't be modified by third party developers.

 

That put aside, the reason I included two samples is because Video 2 exhibits a different problem but the fundamental cause is the same. The framerate compatibility check in the log shows a completely different (and incorrect) rate to that shown by the Emby server (which shows the correct average as it's a variable framerate video) this leads me to infer that the client check is not reliable.

 

I actually noticed this was happening some time ago but didn't report it as I didn't know what the root cause was. Some videos that I had remuxed from flv containers using mkvtoolnix had their Default Duration/FPS element incorrectly set and I couldn't understand why (still don't, it appears to be a bug in mkvtoolnix) this caused the videos, that were originally 25fps, to be transcoded instead of direct played. Media Info was showing the video stream as 25 fps yet the client showed 50 fps, so the transcoder was activated, editing the file header so that it contained the corrected fps value made the problem disappear and the videos direct play without issue.

 

Can your files also play from usb connected to your Samsung device?  But ya streaming seems to be slowing it down below 30fps

 

As stated previously "local playback works fine" from USB. I don't understand what you mean by the second sentence.

 

The issue I have is not really whether any particular video plays or not as I can easily modify the client's code to force playback. I'm questioning the usefulness of a client check that gives values inconsistent with those already detected correctly by the server.

Link to comment
Share on other sites

FrostByte

Local playback can mean different things to different people, I was just trying to make sure that you meant from usb and not the server as you really didn't state that from your original post

 

The table was just an example for my TV, but since you seem to be familiar with the code already you should have noticed it detects the model of your device then tries its best to decide what is and isn't compatible

Link to comment
Share on other sites

FrostByte

Does the log on your H-series BD player say it's being properly detected as a H series device?  It should say something right after you logon.

 

It seems like all codecs for H-series devices are being forced at 30 fps and doesn't distinguish between HD and FHD like in your table (this is for h264 like in your samples).  

 

@@cmcg can the code be changed to allow 60fps for anything 720p and less?  That would allow OddbOd's files to play

     		case "h264": 
40     			this.codec = true; 
41     			this.container = ["asf","avi","mkv","mp4","3gpp","mpg","mpeg","ts","m4v","m2ts","mov","vro","tp","trp","flv","vob","svi","mts","divx"]; 
42     			this.resolution = [1920,1080]; 
43     			this.bitrate = 50720000; 
44     			this.framerate = 30; 
45     			this.level = 41; 
46     			this.profile = ["Base","Constrained Baseline","Baseline","Main","High"]; 
47     			break; 

Edited by FrostByte
Link to comment
Share on other sites

FrostByte

I understand what you're saying about the fps in the headers of your file don't match the fps of the video contained within, but how else is one to determine the actual fps of the video within?  That information is passed to the client app from the server which is taking that information from your headers which you stated are incorrect. 

 

What would happen if the framerate was ignored as you suggest and someone actually had a file that was 60fps which their device couldn't handle?

Edited by FrostByte
Link to comment
Share on other sites

Local playback can mean different things to different people, I was just trying to make sure that you meant from usb and not the server as you really didn't state that from your original post

 

The table was just an example for my TV, but since you seem to be familiar with the code already you should have noticed it detects the model of your device then tries its best to decide what is and isn't compatible

 

Fair enough, I can see how that may not have been clear.

 

OK now I'm confused. That table is for the base model of your TV, but since you have an Evo Kit isn't your supported maximum 60 fps as well?

 

 

Does the log on your H-series BD player say it's being properly detected as a H series device?  It should say something right after you logon.

 

It seems like all codecs for H-series devices are being forced at 30 fps and doesn't distinguish between HD and FHD like in your table (this is for h264 like in your samples).  

 

 

Yes, the BD player series is detected correctly.

 

Indeed and that decision is being made on the basis of unreliable information in some cases. Your TV is a good example, the Evo Kit, as far as I can tell, is not detected so it's being treated as if it was an F series when in reality it's equivalent to an H series. My example Video 2 shows evidence that the wrong value is being queried and I finally tracked down the root cause.

 

The server uses ffprobe to obtain two framerate values streamInfo.avg_frame_rate which is displayed under Media Info on the itemdetails page, the other is streamInfo.r_frame_rate which as the ffmpeg documentation notes (https://ffmpeg.org/doxygen/2.7/structAVStream.html#ad63fb11cc1415e278e09ddc676e8a1ad) is a guess because of the way audio and video packets share a common timebase within a container. This second value is the one that is used to decide what the framerate is in the Emby client when in fact it is the average that should be used, this confusion was probably caused by the name  stream.RealFrameRate being used in Emby / MediaBrowser.MediaEncoding / Probing / ProbeResultNormalizer.cs. I'm not the only person who thinks this method is deceptive and useless, Anton Khirnov, one of the libav developers suggested removing it several years ago, nobody objected (https://lists.libav.org/pipermail/libav-devel/2012-June/029761.html).

 

Fixing this is a simple matter of changing the references in GuiPlayer_Transcoding.js from RealFrameRate to AverageFrameRate. This has several side benefits on top of making Video 2 directplay, fps values between client and server are now consistent and other users with variable frame rate videos will be able to play them without unnecessary transcoding.

 

I understand what you're saying about the fps in the headers of your file don't match the fps of the video contained within, but how else is one to determine the actual fps of the video within?  That information is passed to the client app from the server which is taking that information from your headers which you stated are incorrect. 

 

What would happen if the framerate was ignored as you suggest and someone actually had a file that was 60fps which their device couldn't handle?

 

I didn't understand until a few hours ago why there was a difference between the two reported fps values, now that I know why I can say definitively that it can be determined by retrieving the AverageFrameRate value from the server. That still won't make the 60 fps video play but I've had some further thoughts about that and would prefer to address that issue separately.

 

In answer to the second question, I don't know and neither will anyone else unless the current 30 fps limit is reconsidered. Ideally any failure to directplay would be caught by an OnRenderError Event Listener, another play request would be made to the server this time with transcoding enabled, and the user wouldn't notice anything had gone wrong.

Link to comment
Share on other sites

FrostByte

Ya, I think your issue can be partially solved fairly easily if/when the code can be rewritten so that 60fps is allowed for up to HD 720p and still transcode anything >30fps for FHD 1080p for devices that support it. 

 

The average framerate option is interesting as the manual really doesn't specify it has to be real or constant.  Good point. 

 

The goal of the app of course is to Direct Play as much as possible for each series of devices (which you know is different every year) and then transcode when necessary so that all files can be played on supported Samsung devices.  It is getting there, but as your table pointed out it can still be tweaked some so that more files can use DP.  Whenever anyone finds these types of issues it is appreciated and can only help the community

 

For right now my evokit is not supported.  The code is written to detect the model of the TV (F-series in my case) and would need to be rewritten some to detect the SmartHub version which is 2014.  So right now I'm still falling into the code for F-series devices and things like H265 still cause some of my files to be transcoded when it technically shouldn't have to be.  I'm not sure, but it may be a big task to rewrite for only 2 people I'm aware of in the forum who have one.

Edited by FrostByte
Link to comment
Share on other sites

I took a look at this but it's a little more effort to do "if this then that" because the resolution is not known when you're setting the max frame rate. Just the way that particular function works. Should be ok though, I'll try to get my it in the upcoming beta. Can you confirm that all H-Series devices behave in this way? Your screenshot and PDF manual don't seem to agree.

  • Like 1
Link to comment
Share on other sites

FrostByte

Ya, it didn't look easy when I was looking at it :)  I downloaded 3 manuals for US version H-series TVs last night and they all indicated they supported 60fps for HD and 30fps for FHD.  I can look some on the Samsung developer forums too

  • Like 1
Link to comment
Share on other sites

FrostByte

Actually, it wasn't that bad. The two most recent commits should do what we want.

 

https://github.com/MediaBrowser/SamsungSmartTV/commits/2.2_dev

 

Nice, I'm willing to bet the whole 60fps at <= 720p works on your TV too :)  The chart just isn't right.  That may be a nightmare to code though with all those exceptions

 

56cb6e3292218_fr.jpg

Edited by FrostByte
Link to comment
Share on other sites

FrostByte

Ahh, so you did an override.  Thanks.  Though I still think I owe you and you should set up a paypal account ;)

Edited by FrostByte
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...