Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count droppedFrames in tunneling mode #7100

Open
Cizor opened this issue Mar 17, 2020 · 5 comments
Open

Count droppedFrames in tunneling mode #7100

Cizor opened this issue Mar 17, 2020 · 5 comments
Assignees

Comments

@Cizor
Copy link
Contributor

Cizor commented Mar 17, 2020

Searched documentation and issues

  1. Exoplayer Issues
  2. https://medium.com/google-exoplayer/tunneled-video-playback-in-exoplayer-84f084a8094d

[REQUIRED] Question

How to count dropped frames count when tunneling mode is enabled?
For non tunneling mode I am using decoderCounters.droppedBufferCount but code in MediaCodecVideoRenderer doesn't seem to handle it for tunneling mode. Please advise.

Link to test content

Content used from Demo app

@Cizor
Copy link
Contributor Author

Cizor commented Mar 17, 2020

I am not very sure about it but since decoding of video is not in exoplayer code, it cannot determine if a frame is late, very late or should be dropped when tunneling mode is enabled

@krocard
Copy link
Contributor

krocard commented Mar 27, 2020

The tunneling decoder reports rendered frames with the callback MediaCodec.OnFrameRenderedListener.onFrameRendered which calls onProcessedTunneledBuffer which updates renderedOutputBufferCount but not the drop counter.
onProcessedTunneledBuffer could try to guess if a frame was not rendered by comparing the received timestamps to the expected ones.

As the tunneling decoders are not required to call onFrameRendered for every frame (and I have not tested if they do either). So it's not sure if the resulting metrics will be reliable.

Unfortunately I will not access to a tunneling setup until the London office reopens (COVID-19 confinement).

@krocard
Copy link
Contributor

krocard commented Jun 26, 2020

@Cizor, changxiangzhong in #7544 has done some testing regarding the tunneling onFrameRendered callback and it seems that the callback is reliable enough to detect frame drops, at least for their device.

I would encourage you to try the same methodology if possible to validate that it successfully detects drop frames for your devices.

@changxiangzhong
Copy link
Contributor

changxiangzhong commented Jul 5, 2020

@krocard I've found in the DebugMediaCodecVideoRenderer::onProcessedOutputBuffer() in dev-v2 branch, there are some logic regarding frame drop detecting. Source code is as following. I think we can reuse and modify it to detect frame drops.

    @Override
    protected void onProcessedOutputBuffer(long presentationTimeUs) {
      super.onProcessedOutputBuffer(presentationTimeUs);
      bufferCount++;
      long expectedTimestampUs = dequeueTimestamp();
      if (expectedTimestampUs != presentationTimeUs) {
        throw new IllegalStateException("Expected to dequeue video buffer with presentation "
            + "timestamp: " + expectedTimestampUs + ". Instead got: " + presentationTimeUs
            + " (Processed buffers since last flush: " + bufferCount + ").");
      }
    }

Essentially, this DebugMediaCodecVideoRenderer maintains a queue of PTS. After a packet has been pushed into the InputBuffer, its PTS would be put into the queue and sorted. So this queue contains all the PTS of frames that has been pushed to the codec but has not yet output to the Surface. Whenever there's a new output, it would compare the PTS and see if there's a frame drop.

@krocard
Copy link
Contributor

krocard commented Jul 6, 2020

I agree that this should be an effective approach to detect missing frame.

@krocard krocard assigned tonihei and unassigned krocard May 12, 2022
@tonihei tonihei changed the title count droppedFrames in tunneling mode Count droppedFrames in tunneling mode May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants