[mythtv] [mythtv-commits] Ticket #799: DTV recordings sometimes show doubled recording length

Chris Pinkham cpinkham at bc2va.org
Sun Sep 30 17:45:02 UTC 2007

* On Sun Sep 30, 2007 at 04:27:40PM -0000, MythTV wrote:
> #799: DTV recordings sometimes show doubled recording length

> Comment(by Tom Dexter <digitalaudiorock at hotmail.com>):

totalLength is also set in NuppelVideoPlayer::SetLength.

When a recording ends, the recorder (TVRec) sends a DONE_RECORDING
event.  This event contains the card number and the recording
length.  This gets received by the TV class (tv_play.cpp) and
TV::customEvent calls NuppelVideoPlayer::SetLength().

This is how the totalLength is getting set without you seeing it
in your debugging code.

I think the reason that the length is getting hosed up is that
the DVB recorder (and possibly others) doesn't know/set the frame
rate of the video that it is recording, so it defaults to the
29.97 that is set in the construction of RecorderBase.

TVRec::TeardownRecorder() does this:

	filelen = (int)((float)GetFramesWritten() / GetFramerate());

TVRec::GetFramerate() calls RecorderBase::GetFrameRate() which
just returns Recorderbase::video_frame_rate.

RecoderBase::video_frame_rate is only set by the DVB recorder
in RecorderBase's constructor.

I see there is even a comment about this in the code in tv_rec.cpp.
It's not specifically about the double length, but saying the way
it calculates the length is wrong because of changing framerates
in DTV recordings.

        // This is a bad way to calculate this, the framerate
        // may not be constant if using a DTV based recorder.
        filelen = (int)((float)GetFramesWritten() / GetFramerate());

The only accurate way for the player to know how long the recording
is in this case is for the recorder to keep track of it which it
doesn't currently.  The recorder could look at the frame rate and
do a calculation based on that, but that is not foolproof since
the frame rate could change in the recording (and does in some
places where commercials are at different rates than the show).

The player knows the _current_ frame rate, so the numbers
will jump around when you are playing a video that changes
frame rates in the middle.  Calculations based on these changing
frame rates are another big issue that hasn't been solved yet.
The player doesn't handle them in a lot of cases, and neither does
the commercial flagger.


More information about the mythtv-dev mailing list