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

playing modified MPEG-TS files #1101

Closed
amoussawi opened this issue Jan 3, 2016 · 9 comments
Closed

playing modified MPEG-TS files #1101

amoussawi opened this issue Jan 3, 2016 · 9 comments
Assignees

Comments

@amoussawi
Copy link

Hello...
I'm trying to play a sample from a TS file on my app...what i did was to trim the first ~1MB from the file which is ~5MB total...and i also tried to trim certain byte ranges from the file...both resulting files are played as expected on my PC with VLC and Windows media player....but exoplayer did not play them...my case is that im receiving a video with no reliable transmission(UDP) so there might be some packet loss... i learned that MPEG-TS was made for non reliable transmissions(TV broadcasting)...and i guess the way MPEG-TS is structured using packetized elementary streams is the reason why trimming the video file wont make the stream totally corrupted and it would still be playable on PC but i have no clue why it's not playing on exoplayer....any idea?

@ojw28
Copy link
Contributor

ojw28 commented Jan 3, 2016

ExoPlayer does not currently support this. Please clarify why you need to use UDP as opposed to TCP. I asked this on #966, but you didn't answer. Thanks!

@amoussawi
Copy link
Author

Sorry i missed that question...I'm trying to multicast a video from a master device to other decices using wifi-direct.

@amoussawi
Copy link
Author

there's a trick to fix that I just noticed it.....since a TS packet is of fixed size 188B, then all I have to do skip the stream to closest multiple of 188 if possible, this is in case I want to trim the first ~1MB of the file, and this helps in case of live streaming UDP. and in case of packet loss all i have to do is to fill the gap with random bytes as long as the total stream length is a multiple of 188.

@ojw28
Copy link
Contributor

ojw28 commented Jan 4, 2016

Note that #1083 will probably also (partially) fix this issue. Do you feel like generating and sharing some test files? I imagine the following cases are of interest:

  1. Start of the stream not aligned with a TS packet boundary.
  2. Some fractional number of TS packets removed from the middle of the stream.
  3. End of the stream not aligned with a TS packet boundary.
  4. All three of the above in a single stream.

@amoussawi
Copy link
Author

oh nice good work...actually I already tried working on the sync byte such that if the first byte is not the sync byte then go the next byte and try again until it finds the sync byte, though I was not sure if it would work since there might be a a byte in the stream that has the same value (0x47) as the sync byte but it's not the sync byte and I guess that's why it did not work :( .
1-the first test I already tried it with the old code not with the modification made by issue #1083 but exoplayer couldn't played it, it said none of the extractors available could read the stream.
2-second one not yet.
3- do you mean the last TS packet is not 188 byte in length but less?
I will share the tests sure. Thanks for your reply.

@amoussawi
Copy link
Author

1-https://drive.google.com/file/d/0B0tCREqCqqYccDBWSmU1eDkyem8/view?usp=sharing
2-https://drive.google.com/file/d/0B0tCREqCqqYcRkVkVlFGZ0FHNk0/view?usp=sharing
3-https://drive.google.com/file/d/0B0tCREqCqqYcUlV4eE9jOXhrMWc/view?usp=sharing
exoplayer couldn't play the first test file at all.
in the second test file i removed ~10000 packets from the middle of the file, and exoplayer played successfully, and as expected it issued an error Discontinuity detected [expected 19551201, got 42213883], and I guess this is the range from which I removed the packets, but it continued the playback normally.
in the third test I removed ~94B from the last packet, exoplayer only played the first few seconds when it detected a lot of discontinuities and stopped the playback.

ojw28 pushed a commit that referenced this issue 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 Sep 9, 2016

All three of the samples above appear to play fine in dev-v2, so closing as fixed!

@ojw28 ojw28 closed this as completed Sep 9, 2016
@amoussawi
Copy link
Author

amoussawi commented Sep 9, 2016

Great! Thank you! Though I couldn't wait for the v2 to be out to get these features. I already modified TsExtractor in order to get things done as I want.

@ojw28
Copy link
Contributor

ojw28 commented Sep 9, 2016

:). FYI the fixes are probably in the dev-v1 branch too, although I didn't check. If they're not already, they likely will be soon (i.e. next week), since we've been back-porting most of our fixes around MPEG-TS robustness.

@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.
Projects
None yet
Development

No branches or pull requests

3 participants