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
[DemuxClient] Parse for mid stream changes (optional) #16642
Conversation
The diff is hard to read because the functional changes are well hidden among the code formatting changes. Could you next time please make separate commits for the functional changes and code formatting changes? Regarding the PVR change: why is this only needed for MPEG2VIDEO and not for instance also for H264? |
It is wrong anyway. Not all content is frame interlaced and behaves like mpeg2. ffmpeg detected fps might be correct already. |
Further, for h264 fps is NOT coded in SPS (extradata). You can parse this as long as you want but ffmpeg won't ever detect a change in fps. |
@FernetMenta fps is in VUI (which is part of SPS). And it is read in ffmpeg: Regarding your first post: what would be your solution to fix the wrong fps for live streams? Edit: "Not all content is frame interlaced and behaves like mpeg2." Do you mean "Not all frame interlaced content behaves like MPEG2" ? Then I would understand, because the interlaced check is done in this implementation. |
@ksooo this is just a "sample" implementation to give you an idea how to trigger. Edit: for RTL SD streams for example TVH provides 1000 / 40 = 25 fps, what is wrong. |
Still don't get why this is wrong. Of course you do not want the display to switch to 25 and later to 50Hz. I do get that. But input/source is still 25fps (50 fields per second = 25 frames per second, either from interlaced or progressive source). It depends on the deinterlacer what the output will be. So probably the info for refresh rate switching is taken at a wrong stage in the pipeline or 25fps should always result in a switch to 50Hz anyway. I might not be seeing the full picture though... |
fps in DVDStreamInfo are meant as progressive fps, our DI produces 50fps for such kind of stream. So it depends on how to interpret the fps in stream, in view of kodi or in view of the stream. And they are different (25 / 50). because of the missing IsInterlaced information the only way to provide a stream start with the "correct" fps is using the kodi one (50) Edit: Conclusion: both values are right or wrong depending where you look at. |
What is "our deinterlacer"? Yadif is configured to 0,-1,1 (0... single frame rate) on Android due to slow boxes/TVs, outputting 25fps. MediaCodec on BRAVIA also outputs 25fps. A switch to 50Hz still isn't bad of course... |
@CiNcH83 you are right, this depends on the deinterlacer (compared DXVA DI (=25fps) with Mediacodec DI (=50fps), so the check for doubling has to be done at an other place, thx. |
What's wrong with setting refresh rate to 50Hz for 25fps content? 50Hz results in more responsive GUI... |
At this place it is wrong, because it could also be needed in its correct value for the later processing. |
VUI is supplementary information and is not mandatory. IIRC it is not available for most TV channels. |
@CiNcH83 that proves nothing. According to the spec this info is optional and does not need to be present in SPS. At the time I wrote the h264 parser for vnsi I did not rely on this field because it was not reliable. |
4b1562b
to
95a9e1a
Compare
{ | ||
int fpsRate = m_hints.fpsrate; | ||
if (m_hints.fieldOrder > AV_FIELD_PROGRESSIVE) | ||
fpsRate *= 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but this confuses me so badly.. in case of PAL, if we have interlaced material but source is actually progressive, you can use WEAVE and you‘ll get a perfect 25fps as you always have two matching fields. If source is truly interlaced, the deinterlacer will either interpolate to 25fps or 50fps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mustn't cunfusing you badly, this is a PR and open for discussion.
Seems that you have lot of knowledge about different codecs and their behaviour, pls. provide information about how it should be solved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The info is wrong in many cases anyway. So it does not seem to be crucial.
The source is 25fps, no matter whether content is truly interlaced or from progressive source or what the deinterlacer does.
I did some testing with 2 DVDs on my BRAVIA Android TV...
(1) The Mummy: Tomb of the Dragon Emperor: progressive 576i25 (50 fields per second with always 2 fields originating from the same point in time)
(2) Rocky: truly interlaced 576i25 (50 fields per second with each originating from a different point in time)
(1) can be deinterlaced with a simple WEAVE, putting 2 fields together to build one single frame, resulting in 25fps. (2) is either interpolated to 25fps or 50fps (frame doubler).
I played those DVDs in Kodi through Android MediaCodec and ffmpeg (MediaCodec disabled).
MediaCodec on BRAVIA outputs 25fps for both DVDs. The BRAVIA therefore does not perform frame doubling for truly interlaced material.
ffmpeg in Kodi is configured to perform "half rate" deinterlacing (Yadif: 0,-1,1) on Android by default (I think @fritsch changed that because of the many slow boxes and TVs), therefore outputting 25fps for both DVDs too.
Deinterlacer can be switched to "full rate" (Yadif: 1,-1,1) in video settings. After doing so, Kodi outputs (1) at 25fps (due to its progressive nature) and (2) at 50fps (check with STRG+SHIFT+O).
I would leave the info at 25fps because it is the correct one from a source/demuxer point of view. Either truly interlaced or interlaced from progressive source, 25fps is correct. Determining true output fps is probably a matter of calculating frame time delta at the video renderer. STRG+SHIFT+O already shows the correct info.
As for refresh rate switching, I would always switch to 50Hz in case of PAL if a respective display mode exists, even if you have 25fps at the renderer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Determining true output fps is probably a matter of calculating frame time delta at the video renderer. STRG+SHIFT+O already shows the correct info.
CVideoPlayerVideo::m_fFrameRate might be the right figure to look at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx @CiNcH83, can you provide a some second snippet of "The Mummy" pls ?
Edit: and some seconds of the other stream, too, pls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure...
The Mummy: Tomb of the Dragon Emperor (progressive 576i25)
Format : MPEG Video
Format version : Version 2
Format profile : Main@Main
Width : 720 pixels
Height : 576 pixels
Frame rate : 25.000 FPS
Standard : PAL
Scan type : Progressive
Scan order : Top Field First
Format : MPEG Video
Format version : Version 2
Format profile : Main@Main
Width : 720 pixels
Height : 576 pixels
Frame rate : 25.000 FPS
Standard : PAL
Scan type : Interlaced
Scan order : Top Field First
Mid-stream changes are not handled for DVBViewer PVR add-on. Is it due to the fact that this add-on uses a file based approach rather than DemuxClient? |
Yes, could be, we can look later on it if the other things are fine. |
CLog::Log(LOGDEBUG, "%s - ProcessInfo reports fps: %0.4f.", __FUNCTION__, framerate); | ||
if (framerate < 1.0E-6) | ||
framerate = static_cast<float>( | ||
DVD_TIME_BASE / CDVDCodecUtils::NormalizeFrameduration((double)DVD_TIME_BASE * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use C++ style cast
m_fFrameRate = codec ? codec->GetFramerate() : 0.0f; | ||
if (m_fFrameRate < 1.0E-6) | ||
m_fFrameRate = DVD_TIME_BASE / CDVDCodecUtils::NormalizeFrameduration( | ||
(double)DVD_TIME_BASE * hint.fpsscale / hint.fpsrate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use C++ style cast
0
…---Original---
From: "Markus Pfau"<notifications@github.com>
Date: Wed, Oct 2, 2019 05:44 AM
To: "xbmc/xbmc"<xbmc@noreply.github.com>;
Cc: "Subscribed"<subscribed@noreply.github.com>;
Subject: Re: [xbmc/xbmc] [DemuxClient] Parse for mid stream changes (optional) (#16642)
@peak3d commented on this pull request.
In xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp:
> @@ -1042,6 +1042,16 @@ unsigned CDVDVideoCodecAndroidMediaCodec::GetAllowedReferences() return 4; } +float CDVDVideoCodecAndroidMediaCodec::GetFramerate() const +{ + int fpsRate = m_hints.fpsrate; + if (m_hints.fieldOrder > AV_FIELD_PROGRESSIVE) + fpsRate *= 2;
Thx @CiNcH83, can you provide a some second snippet of "The Mummy" pls ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@CiNcH83 I removed the interlaced handling for fps doubling completely because it seems that information provided in container are often wrong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Yes, container information being wrong is indeed another problem. But the *2 thingy has just been as wrong...
As for mid-stream change handling, I can't really test it unfortunately as it is not triggered for file. A sample can be found here.
[EDIT]
PR currently not compiling anyway.
@@ -344,6 +344,9 @@ void CInputStreamPVRBase::UpdateStreamMap() | |||
dStream = std::make_shared<CDemuxStream>(); | |||
|
|||
dStream->codec = (AVCodecID)stream.iCodecId; | |||
if (dStream->codec == AV_CODEC_ID_MPEG2VIDEO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peak3d this needs a rebase |
@peak3d do you want to progress this, close it or put it on the backburner? |
Back burner pls. |
PR has merit but will labelled If the author would like it kept open please just request so on the PR. |
Description
This PR implements the option to keep the ffmpeg parser alive even after codec extradata was found to track mid stream changes (@ksooo ). This happens only if the decoder don't have the capability to parse packets (curently only android mediacodec). For other decoders (e.g. ffmpeg) the demuxer will always stopp parsing after first extradata was found.
For PVR this implementation asks the demuxclient to continue parsing only for MPEG2 streams.
This is just for testing / showing what to do and should / could be implemented different.
Motivation and Context
How Has This Been Tested?
Play PVR SD MPEG2 channel on Windos (ffmpeg) and Android.
Types of change