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

Restore the flow of Transport Stream packets if synchronisation is lost #1083

Closed
wants to merge 3 commits into from

Conversation

algrid
Copy link

@algrid algrid commented Dec 22, 2015

For some reason TsExtractor can get a TS packet with wrong length and all the following packets become shifted by several bytes which completely breaks the video playback. This code restores the synchronisation if it's possible.

See: #90

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@algrid
Copy link
Author

algrid commented Dec 22, 2015

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@sreenadhkondru
Copy link

For me this issue surfaced only when using UDP as the transport. When a TS packet sent by the server is spread across two UDP packets, and one of the UDP packets is lost (which happens quite often since UDP is a lightweight unreliable transport) the TSExtractor goes out of sync. An incomplete TS packet rather than being discarded is fed with wrong bytes from another TS packet.

On the server side the fix is to set the UDP payload packet size to a multiple of 188 bytes ( I set it to 7*188 = 1316 bytes). That way even if a UDP packet gets lost, we do not end up with an incomplete TS packet. This worked for me and I never got the issue with TSExtractor again.

On the client side I tested the fix by Algrid, and it works even If the server is not configured to send UDP packets of consistent size. This approach should possibly be expanded so that on any error detected in the current TS packet the extractor should rollback to the sync bit of this TS packet and search for the next sync bit from there.

# Conflicts:
#	library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@googlebot
Copy link

CLAs look good, thanks!

# Conflicts:
#	library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
@algrid
Copy link
Author

algrid commented Jun 16, 2016

In my case it fixed problems with MPEG2 TS over HTTP.

ojw28 pushed a commit that referenced this pull request Jul 8, 2016
…r lost sync.

Issue: #1332
Issue: #1101
Issue: #1083
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=125659191
@ojw28
Copy link
Contributor

ojw28 commented Jul 28, 2016

I believe we've fixed this in dev-v2, here, so closing this.

@ojw28 ojw28 closed this Jul 28, 2016
@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants