webrtc icon indicating copy to clipboard operation
webrtc copied to clipboard

IVF writer writing invalid timestamp value into frame headers?

Open radekg opened this issue 2 years ago • 2 comments

Hey maintainers, thank you for this awesome work.

While working a little bit with some VP8-based streams, I have noticed something interesting related to IVF writers. Is it possible that the value written for the IVF frame timestamp is incorrect?

  • what's being written is a sequence number: https://github.com/pion/webrtc/blob/master/pkg/media/ivfwriter/ivfwriter.go#L112
  • the reader correctly expects it to be a timestamp: https://github.com/pion/webrtc/blob/master/pkg/media/ivfreader/ivfreader.go#L97,

And, of course, Duck IVF says that 8 bytes at offset 4 are 64-bit presentation timestamp: https://wiki.multimedia.cx/index.php/Duck_IVF.

Shouldn't the writer write the RTP header timestamp value into the IVF frame header?

I would propose the following:

  • https://github.com/radekg/boos/pull/3/files#diff-652bfa3efcbaa4c9f2876f1b72e4c566f6539428d6ac738050aa074370b192f1R112-R123

with the following call-site changes:

  • https://github.com/radekg/boos/pull/3/files#diff-652bfa3efcbaa4c9f2876f1b72e4c566f6539428d6ac738050aa074370b192f1R156
  • https://github.com/radekg/boos/pull/3/files#diff-652bfa3efcbaa4c9f2876f1b72e4c566f6539428d6ac738050aa074370b192f1R172

With these changes, I can handle variable stream framerate when reading frames.

I can provide a PR, if this change is acceptable.

Your environment.

  • Version: Release or SHA
  • Browser: include version
  • Other Information - stacktraces, related issues, suggestions how to fix, links for us to have context

What did you do?

What did you expect?

What happened?

radekg avatar Jan 10 '23 20:01 radekg

Hi @radekg

Are you still interested in doing this! Anything we can do to improve the timing handling with IVF would be greatly appreciated. I haven't looked into it lately, but is a common complaint.

Sean-Der avatar May 09 '24 03:05 Sean-Der

Sure, sorry for the delay, I'm not often on my private github recently but I can follow up on this.

radekg avatar Jun 11 '24 12:06 radekg

Any updates on this issue? @Sean-Der. In my case, IVF writer produces a video file with invalid duration

For example I stream 30-second video, audio track has valid duration, while video track lasts for only 15 seconds

trekvartista avatar Jul 24 '24 12:07 trekvartista

Hey @Sean-Der, I have opened a pull request.

radekg avatar Aug 04 '24 20:08 radekg