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

Fix frame dropping in filtergraph at EOF #153

Merged
merged 1 commit into from
Sep 18, 2019
Merged

Fix frame dropping in filtergraph at EOF #153

merged 1 commit into from
Sep 18, 2019

Conversation

j0sh
Copy link
Collaborator

@j0sh j0sh commented Sep 12, 2019

ffmpeg: Fix frame dropping in filtergraph at EOF.

This is done by setting the EOF timestamp of the filtergraph
such that the timestamp is after the last frame inserted.

Also add tests exhibiting various cases uncovered in the process
of fixing this.

Fixes #154

@j0sh j0sh force-pushed the ja/dropframes branch 2 times, most recently from c428171 to d722afc Compare September 17, 2019 19:14
@j0sh j0sh changed the base branch from ja/encodeopts to master September 17, 2019 19:15
@j0sh j0sh changed the title Add test exhibiting issue with dropped frames. Fix frame dropping in filtergraph at EOF Sep 17, 2019
Copy link

@mkrufky mkrufky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. However, although unrelated, consider the audio popping issue - I believe that the same affect achieved by this PR would be achieved by the pre-pending and post-pending of one audio frame from the neighboring segments. It's just something to keep in mind.

// to timestamp rounding around EOF. Note this does not happen with
// mpegts formatted output!
if res2.Decoded.Frames != 60 || res.Encoded[0].Frames != 61 {
t.Error("Did not get expected frame counts: is this fixed?!? ",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the "is this fixed?!?" bit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make adjustments to the language if you can think of a better phrasing :) Mostly, the intent was to express some notion of:

  • This behavior is currently broken, and this unit test serves as reproducible documentation (along with Number of encoded frames does not match number of decoded frames #155)
  • But we need to make broken tests "pass"
  • If the broken test no longer passes, maybe it means the underlying issue has been fixed? 🤞
  • If the test breaks, hopefully a distinct error message will prompt more careful review of the issue and any associated changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that makes a lot more sense now - thank you for explaining :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the language a bit in ab98e51

@j0sh
Copy link
Collaborator Author

j0sh commented Sep 17, 2019

I believe that the same affect achieved by this PR would be achieved by the pre-pending and post-pending of one audio frame

This PR doesn't attempt to address the audio popping issue; it only fixes frame dropping from the filtergraph as described in #154 . The audio issue (along with your proposed fix) is still open and documented in #152 .

@darkdarkdragon
Copy link
Contributor

@j0sh can't find way to comment on code that is not changed, so asking here:
here:

  if (!filter || !filter->active) {
    // No filter in between decoder and encoder, so use input frame directly
    ret = encode(encoder, inf, octx, ost);
    if (ret < 0) return ret;
  }

shouldn't it exit unconditionally, like this:

  if (!filter || !filter->active) {
    // No filter in between decoder and encoder, so use input frame directly
    ret = encode(encoder, inf, octx, ost);
    return ret;
  }

@j0sh
Copy link
Collaborator Author

j0sh commented Sep 18, 2019

shouldn't it exit unconditionally, like this:

@darkdarkdragon Ah yes indeed! Fixed in ab98e51

(Note that we don't actually hit this code path in LPMS itself but I've used it in the past for testing the C API directly...)

Copy link
Contributor

@darkdarkdragon darkdarkdragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This is done by setting the EOF timestamp of the filtergraph
such that the timestamp is *after* the last frame inserted.

Also add tests exhibiting various cases uncovered in the process
of fixing this.
@j0sh j0sh merged commit 7f095b3 into master Sep 18, 2019
@j0sh j0sh deleted the ja/dropframes branch September 18, 2019 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transcodes are off by one video frame
4 participants