Electronicdesign 24376 Replaytv Screen
Electronicdesign 24376 Replaytv Screen
Electronicdesign 24376 Replaytv Screen
Electronicdesign 24376 Replaytv Screen
Electronicdesign 24376 Replaytv Screen

A Spell to Cast Out Audio-Video Sync Problems

Oct. 29, 2018
Sifting through gigabytes of compressed data, an unemployed software developer finds the one bad value.

Get the complete compendium of troubleshooting articles. Download Now in PDF Format.

Back in the early 2000’s I was a DVR fanatic. My TiVO and ReplayTV collection and I were mentioned in a New York Times article on DVR users.

In 2003 the ReplayTV 5000 series DVR was released. In addition to the automatic commercial skip found on earlier models, this new model could send shows to a ReplayTV in another room or anywhere in the world.

Even with increased sales from the new products, 2003 was a bad year for the company. TiVO was the number one DVR brand and broadcasters were suing over commercial skip and show sharing features. It wasn’t long before legal costs overwhelmed their parent company, SONICBlue, which filed for bankruptcy protection.

Although the brand was acquired by Denon & Marantz Holdings under the DNNA brand, ReplayTV was struggling to survive.

During the ReplayTV 5000’s first year, users reported losing audio sync in some recordings. Video would momentarily freeze and after resuming the audio was seconds behind. It was only a matter of time before I, too, experienced the same problem.

After talking with tech support, I learned there were no developers left to fix the problem. I was an unemployed software developer taking care of two young kids. I had free time and experience with audio and video compression, so I decided to see if I could find the cause and fix it.

The ReplayTV recording format was known after hackers figured out the disk partition table and file system. Developers created utilities to access the files and those apps were shared on sites like www.avsforum.com. 

That meant that by connecting the DVR drive to a computer, a technical user could extract recordings using command line utilities When show sharing was available, a utility, called DVArchive, allowed everyone to move recordings to a PC without pulling the drive.

DVArchive was a Java application that cleverly mimicked the ReplayTV networking protocol. A PC running DVArchive looks like a DVR to a ReplayTV, which allowed the two to share shows.

A recorded show is a large MPEG2 file. I figured the problem might well be caused by a hardware issue like a bad disk or MPEG encoder/decoder problem; a software bug; or a bad data stream.

MPEG video was designed to gracefully play through data loss and recover completely. Since playback wasn’t recovering it didn’t seem like a decoding error. This could be as simple as one bad key bit, byte, or value in gigabytes of data. Where to begin? 

My brilliant idea was to ask users with bad recordings to send their recordings to my DVRs. After moving the files to a PC with DVArchive I had 15+GB of files to examine!

MPEG files are interleaved streams of audio, video, and proprietary system data. I trimmed each recording down to a few seconds before and after the glitch, hoping the problem existed nearby.  I could only basically hope that was the case, because these trimmed clips played fine on my DVD players and with Cyberlink’s PowerDVD.

I wrote a program to parse the MPEG stream, so I could examine all data packets. After weeks of work I made little progress and the decoded data looked fine.

Because these recordings are generated in a closed system, I ignored much of the data frame headers except data type and size fields. I ignored the decode timestamp (DTS) and presentation timestamp (PTS) that are embedded in every data frame, which tell the decoder when to decode and present the data. I found these values may be ignored by MPEG decoders (including those mentioned above), which correctly play these clips.

Running out of ideas, I decided to check the time stamps, notwithstanding that I had absolutely no idea what constituted a “bad” value. Since encoding and playback rates are consistent, I decided to check offsets between PTS and DTS values in successive data chunks.

I got extremely lucky that among the thousands of values displayed a single negative PTS offset stood out. Could this be the cause?

I confirmed a bad PTS was set for seconds before the prior PTS. This jump backward was found in all shared recordings. Since a PTS is derived from the previous PTS, any error will propagate through until the end.

The fix was simple; I needed to recalculate the bad audio PTS and then update the remaining times.  I shared my streamfix tool with users on avsforum.com. Users began fixing their recordings with my tool.

This troubleshooting escapade took me a lot of time, but it turned out to be well worth the effort as I enjoyed helping the ReplayTV community!

I shared my findings with ReplayTV, but unfortunately they never fixed their problem.

Jeff Davies is a consumer electronic hardware and software designer and developer currently working on intelligent lighting products. He loves tearing things apart to rebuild them to perform better than they did when new.

NOTE: This article is a submission to Electronic Designs Halloween 2018 "Double, Double Toil and Troubleshooting" Contest.

Sponsored Recommendations

Highly Integrated 20A Digital Power Module for High Current Applications

March 20, 2024
Renesas latest power module delivers the highest efficiency (up to 94% peak) and fast time-to-market solution in an extremely small footprint. The RRM12120 is ideal for space...

Empowering Innovation: Your Power Partner for Tomorrow's Challenges

March 20, 2024
Discover how innovation, quality, and reliability are embedded into every aspect of Renesas' power products.

Article: Meeting the challenges of power conversion in e-bikes

March 18, 2024
Managing electrical noise in a compact and lightweight vehicle is a perpetual obstacle

Power modules provide high-efficiency conversion between 400V and 800V systems for electric vehicles

March 18, 2024
Porsche, Hyundai and GMC all are converting 400 – 800V today in very different ways. Learn more about how power modules stack up to these discrete designs.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!