MediaPortal Version: 1.2.0 Beta
MediaPortal Skin: DefaultWide
Windows Version: Windows 7 + SP1
CPU Type: AMD Athlon 64 X2 4600
HDD: WD 1T + WD 1.5T
Memory: 4G
Motherboard: ASUS
Video Card: ATI Radeon HD 4550
Video Card Driver: 11.5
Sound Card: ATI Radeon HD 4550 (HDMI)
Sound Card AC3: HDMI
Sound Card Driver: 11.5
1. TV Card: HDHomerun HDHR2
1. TV Card Type: ATSC
1. TV Card Driver: 20110323
2. TV Card: HDHomerun HDHR3
2. TV Card Type: ATSC
2. TV Card Driver: 20110323
MPEG2 Video Codec: ffdshow SAF 5.01
MPEG2 Audio Codec: ffdshow SAF 5.01
h.264 Video Codec: ffdshow DXVA SAF 5.01
TV - HTPC Connection: HDMI
First, I'm fairly new to MediaPortal-- I've been using it approx 1-2 months now. Before that, I was using GBPVR. I mention this because when I migrated, I had a large backlog of TS files I recorded OTA using GBPVR that I imported into MediaPortal (by way of ForTheRecord).
Most of the files played fine, but a few exhibited 2 problems:
1. Hit OK on the remote to start playback, and MediaPortal would freeze. HDD light goes solid, and after a while (could be minutes), the file starts playing back.
2. After it starts playing back, if you try to skip forward or backward, the HDD light goes solid again, and then after a while, the recording restarts from the beginning.
Needless to say, spousal approval of MediaPortal took a hit upon running into these.
I did some investigating, and found a clue in TsReader.log that lead me to the problem:
26-06-2011 21:22:59.522 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.544 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.568 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.592 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.616 [d2c]PCR rollover normally found ! endPcr 118052298, startPcr 8368037531
The timestamp of the next entry was always a while after this one. I did some digging, and tracked this down to TsDuration.cpp, where there is a loop to read from the TS file in this situation, and it looks like it's been there forever. This leads to a question that perhaps someone more knowledgeable than I can answer-- when MediaPortal records OTA, does it massage the PCRs to make sure this situation doesn't happen (and thus this code rarely gets used), or is this in fact a problem that folks see on a regular basis?
Going further, I did some research on TS files, PCRs, etc. Since my expertise is now up to about 2 days, I can't say I've got this right, but I * think * the algorithm here is not only annoying to spouses, but also produces incorrect results. As I understand what TsDuration is trying to do, it's attempting to determine the length (duration) of the video file (hence the very appropriate name chosen). That being the case, searching the file for the max PCR and using it in a calculation like END + (MAX - START) doesn't actually yield the correct duration. The correct one, I believe is END + (MAXPCRVALUE - START) where MAXPCRVALUE is a constant -- the maximum possible PCR value (i.e. a PCR with the base and extension of all binary 1s). I argue that the maximum PCR value placed in the TS stream is a sample of the PCR at a particular point in time, but after that PCR value, the counter doesn't immediately roll over to 0-- it keeps incrementing until it hits all 1s, and THEN rolls over to 0. It's just that the all 1s value isn't a sample that gets put into the TS file.
That being the case, the whole loop is unnecessary... just replace the loop with code that sets m_maxPcr to the maximum possible PCR value:
To that end, I've attached TsDuration.simple.cpp.patch and TsDuration.h.patch to implement this simple patch. This seems to entirely fix problem 1.
Making that change doesn't affect problem 2. However, quite by accident, my original attempt to fix this was a little more invasive, and it sort-of fixed problem 2 (see the TsDuration.ver2.cpp.patch). With this patch, fast forward and rewind worked just fine in my test file until about 40 minutes into it, at which point, they stopped working and exhibited a variation of problem 2-- at any point after the 40 minute mark, hitting either would make the video restart from the exact same point about 40 minutes into the video, but the time displayed in the bar would be wrong-- it would show the time that SHOULD be playing (e.g. 48 mins) instead of the time that ACTUALLY was playing (40 mins). I've got to believe this is another manifestation handling PCR rollover in other parts of TsReader, but just haven't had the time to dive deeper yet.
Any feedback on the proposed changes, and whether I'm on the right track would be appreciated. And again, since I'm new here, any pointers on how best to contribute to MediaPortal would be welcome too.
MediaPortal Skin: DefaultWide
Windows Version: Windows 7 + SP1
CPU Type: AMD Athlon 64 X2 4600
HDD: WD 1T + WD 1.5T
Memory: 4G
Motherboard: ASUS
Video Card: ATI Radeon HD 4550
Video Card Driver: 11.5
Sound Card: ATI Radeon HD 4550 (HDMI)
Sound Card AC3: HDMI
Sound Card Driver: 11.5
1. TV Card: HDHomerun HDHR2
1. TV Card Type: ATSC
1. TV Card Driver: 20110323
2. TV Card: HDHomerun HDHR3
2. TV Card Type: ATSC
2. TV Card Driver: 20110323
MPEG2 Video Codec: ffdshow SAF 5.01
MPEG2 Audio Codec: ffdshow SAF 5.01
h.264 Video Codec: ffdshow DXVA SAF 5.01
TV - HTPC Connection: HDMI
First, I'm fairly new to MediaPortal-- I've been using it approx 1-2 months now. Before that, I was using GBPVR. I mention this because when I migrated, I had a large backlog of TS files I recorded OTA using GBPVR that I imported into MediaPortal (by way of ForTheRecord).
Most of the files played fine, but a few exhibited 2 problems:
1. Hit OK on the remote to start playback, and MediaPortal would freeze. HDD light goes solid, and after a while (could be minutes), the file starts playing back.
2. After it starts playing back, if you try to skip forward or backward, the HDD light goes solid again, and then after a while, the recording restarts from the beginning.
Needless to say, spousal approval of MediaPortal took a hit upon running into these.
I did some investigating, and found a clue in TsReader.log that lead me to the problem:
26-06-2011 21:22:59.522 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.544 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.568 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.592 [d2c]Abnormal start PCR, endPcr 118052298, startPcr 8368037531
26-06-2011 21:22:59.616 [d2c]PCR rollover normally found ! endPcr 118052298, startPcr 8368037531
The timestamp of the next entry was always a while after this one. I did some digging, and tracked this down to TsDuration.cpp, where there is a loop to read from the TS file in this situation, and it looks like it's been there forever. This leads to a question that perhaps someone more knowledgeable than I can answer-- when MediaPortal records OTA, does it massage the PCRs to make sure this situation doesn't happen (and thus this code rarely gets used), or is this in fact a problem that folks see on a regular basis?
Going further, I did some research on TS files, PCRs, etc. Since my expertise is now up to about 2 days, I can't say I've got this right, but I * think * the algorithm here is not only annoying to spouses, but also produces incorrect results. As I understand what TsDuration is trying to do, it's attempting to determine the length (duration) of the video file (hence the very appropriate name chosen). That being the case, searching the file for the max PCR and using it in a calculation like END + (MAX - START) doesn't actually yield the correct duration. The correct one, I believe is END + (MAXPCRVALUE - START) where MAXPCRVALUE is a constant -- the maximum possible PCR value (i.e. a PCR with the base and extension of all binary 1s). I argue that the maximum PCR value placed in the TS stream is a sample of the PCR at a particular point in time, but after that PCR value, the counter doesn't immediately roll over to 0-- it keeps incrementing until it hits all 1s, and THEN rolls over to 0. It's just that the all 1s value isn't a sample that gets put into the TS file.
That being the case, the whole loop is unnecessary... just replace the loop with code that sets m_maxPcr to the maximum possible PCR value:
Code:
if (m_endPcr.PcrReferenceBase < m_startPcr.PcrReferenceBase)
{
m_maxPcr.PcrReferenceBase = 0x1ffffffffULL;
m_maxPcr.PcrReferenceExtension = 0x1ffULL;
m_maxPcr.IsValid = true;
}
To that end, I've attached TsDuration.simple.cpp.patch and TsDuration.h.patch to implement this simple patch. This seems to entirely fix problem 1.
Making that change doesn't affect problem 2. However, quite by accident, my original attempt to fix this was a little more invasive, and it sort-of fixed problem 2 (see the TsDuration.ver2.cpp.patch). With this patch, fast forward and rewind worked just fine in my test file until about 40 minutes into it, at which point, they stopped working and exhibited a variation of problem 2-- at any point after the 40 minute mark, hitting either would make the video restart from the exact same point about 40 minutes into the video, but the time displayed in the bar would be wrong-- it would show the time that SHOULD be playing (e.g. 48 mins) instead of the time that ACTUALLY was playing (40 mins). I've got to believe this is another manifestation handling PCR rollover in other parts of TsReader, but just haven't had the time to dive deeper yet.
Any feedback on the proposed changes, and whether I'm on the right track would be appreciated. And again, since I'm new here, any pointers on how best to contribute to MediaPortal would be welcome too.