Correct way to determine FPS of video that is about to play?
#1
I've almost finished commercial skip support for myth://. The last confusing part is converting from the frame offsets stored in MythTV to time offsets for XBMC.

I'm using the following code to get the FPS of the video to then use for the conversion from frame markers to time. For some test files this code is returning 50.000 FPS. However, after comparing the frame markers to the time that the commercial breaks are being skipped to when using mythfrontend, MythTV seems to have used 25.000 FPS.

The following is the code snippet I'm using within DVDPlayer.cpp

Code:
double dFramesPerSecond = 25.0; // Default to 25 FPS if demux stream is not available.
      CDemuxStream* pStream = m_pDemuxer->GetStream(m_CurrentVideo.id);
      if (pStream && pStream->type == STREAM_VIDEO)
      {
        CDemuxStreamVideo* pVideoStream = (CDemuxStreamVideo*)pStream;
        if (pVideoStream->iFpsRate && pVideoStream->iFpsScale)
          dFramesPerSecond = (double)pVideoStream->iFpsRate / (double)pVideoStream->iFpsScale;
      }

Have I misunderstood what the iFpsRate and iFpsScale fields hold, or is something else fishy going on. MythTV seems to think the content is 25 FPS. ffmpeg seems to think it's 50 FPS.
Reply
#2
50 FIELDS per second

25 FRAMES per second

atleast that's my (somewhat educated) guess
Reply
#3
spiff Wrote:50 FIELDS per second

25 FRAMES per second

atleast that's my (somewhat educated) guess

If that is the case, any idea how I could get the frames per second value from somewhereHuh I need that to do the conversion between frames and time.
Reply
#4
i suspect you need logic like

if( isInterlaced() )
fps /= 2;
Reply
#5
Couldn't see any obvious way to check for whether the content about to be played was interlaced or not. Below is the hack that I've got in place for the moment.

Code:
if (dFramesPerSecond > 23.976 * 2)
      {
        // Assume Fps from ffmpeg is Fields Per Second for interlaced content rather than Frames Per Second for progressive
        // content. TODO: Figure out how to determine if interlaced for sure.
        dFramesPerSecond /= 2;
        CLog::Log(LOGDEBUG, "%s - Converted assumed Fields Per Second to Frames Per Second: %.3f", __FUNCTION__, m_filename.c_str(), dFramesPerSecond);
      }

If anyone knows how to determine if the content is interlaced that would be great.
Reply
#6
I believe myth also stores a FPS value. So use that instead to calculate the time offset. You can't trust whatever dvdplayer says is the fps.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
elupus Wrote:I believe myth also stores a FPS value. So use that instead to calculate the time offset. You can't trust whatever dvdplayer says is the fps.

Yeah, I thought that would be the case as well. I couldn't see anything relevant in any of the libcmyth API's though. I guess I should check the MythTV documentation further and see if there is some API to get it that libcmyth doesn't currently expose.
Reply
#8
As expected my hack didn't last long. The 720p DVB-T broadcast is 50fps.

I've another hack in place for my testing of the commercial break skipping but this will only work for the DVB-T recordings for New Zealand.

I really need some way of knowing the frames per second value, or whether the video is interlaced so I can halve what is currently coming back in the fps field.
Reply

Logout Mark Read Team Forum Stats Members Help
Correct way to determine FPS of video that is about to play?0