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

TS can't play on ExoPlayer but can on android.media.MediaPLayer #1894

Closed
xuxucode opened this issue Oct 4, 2016 · 10 comments
Closed

TS can't play on ExoPlayer but can on android.media.MediaPLayer #1894

xuxucode opened this issue Oct 4, 2016 · 10 comments
Assignees
Labels

Comments

@xuxucode
Copy link

xuxucode commented Oct 4, 2016

HTTP-TS https://raw.githubusercontent.com/edwardaa/aaa/master/exoplay_cannot_play.ts can't play on ExoPlayer, but it can play by using android built in MediaPlayer. I tried it both on Amlogic TV box (6.0.1) and my mobile (4.4).

I am using ExoPlayer r2.0.1.

ExoPlayer demo app log:

10-04 20:15:46.395 1829-1829/com.google.android.exoplayer2.demo I/ExoPlayerImpl: Init 2.0.1
10-04 20:15:46.397 1829-1829/com.google.android.exoplayer2.demo W/ExoPlayerImplInternal: Ignoring messages sent after release.
10-04 20:15:46.399 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: state [0.01, true, I]
10-04 20:15:46.400 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: videoDisabled [38.78]
10-04 20:15:46.407 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: state [0.01, true, B]
10-04 20:15:46.412 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: sourceInfo [periodCount=1, windowCount=1
10-04 20:15:46.412 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   period [?]
10-04 20:15:46.412 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   window [?, false, false]
10-04 20:15:46.412 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: ]
10-04 20:15:46.412 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: loading [true]
10-04 20:15:46.576 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: sourceInfo [periodCount=1, windowCount=1
10-04 20:15:46.576 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   period [?]
10-04 20:15:46.576 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   window [?, false, false]
10-04 20:15:46.576 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: Tracks [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   Renderer:0 [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     Group:0, adaptive_supported=N/A [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:       [X] Track:0, id=null, mimeType=video/avc, res=1920x1080, supported=YES
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   Renderer:1 [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     Group:0, adaptive_supported=N/A [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:       [ ] Track:0, id=null, mimeType=audio/mpeg-L2, channels=2, sample_rate=48000, supported=NO_EXCEEDS_CAPABILITIES
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   Renderer:2 [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     Group:0, adaptive_supported=N/A [
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:       [ ] Track:0, id=null, mimeType=application/cea-608, supported=YES
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:     ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: ]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: videoEnabled [0.19]
10-04 20:15:46.581 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: positionDiscontinuity
10-04 20:15:46.604 1829-20778/com.google.android.exoplayer2.demo I/OMXClient: Using client-side OMX mux.
10-04 20:15:46.618 1829-1839/com.google.android.exoplayer2.demo W/art: Suspending all threads took: 14.689ms
10-04 20:15:46.631 1829-20777/com.google.android.exoplayer2.demo I/MediaCodec: [OMX.amlogic.avc.decoder.awesome] setting surface generation to 1872902
10-04 20:15:46.640 1829-20778/com.google.android.exoplayer2.demo E/ACodec: [OMX.amlogic.avc.decoder.awesome] storeMetaDataInBuffers failed w/ err -2147483648
10-04 20:15:46.667 1829-20778/com.google.android.exoplayer2.demo D/SurfaceUtils: set up nativeWindow 0xe2936008 for 1920x1088, color 0x11, rotation 0, usage 0x2002900
10-04 20:15:46.668 1829-20778/com.google.android.exoplayer2.demo W/ACodec: [OMX.amlogic.avc.decoder.awesome] setting nBufferCountActual to 8 failed: -1010
10-04 20:15:46.668 1829-20778/com.google.android.exoplayer2.demo W/ACodec: [OMX.amlogic.avc.decoder.awesome] setting nBufferCountActual to 7 failed: -1010
10-04 20:15:46.701 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: videoDecoderInitialized [0.31, OMX.amlogic.avc.decoder.awesome]
10-04 20:15:46.701 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: videoFormatChanged [0.31, id=null, mimeType=video/avc, res=1920x1080]
10-04 20:15:47.281 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: sourceInfo [periodCount=1, windowCount=1
10-04 20:15:47.281 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   period [4.84]
10-04 20:15:47.281 1829-1829/com.google.android.exoplayer2.demo D/EventLogger:   window [4.84, false, false]
10-04 20:15:47.281 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: ]
10-04 20:15:47.291 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: loading [false]
10-04 20:15:47.295 1829-1829/com.google.android.exoplayer2.demo D/EventLogger: state [0.90, true, R]

@AquilesCanta AquilesCanta self-assigned this Oct 4, 2016
@xuxucode
Copy link
Author

xuxucode commented Oct 9, 2016

Hi, this happens frequently when playing HD ts, any progress on this? Thanks for your help.

@gpinigin
Copy link
Contributor

gpinigin commented Oct 9, 2016

Do your sample have IDR frames? If not - you should alter Exoplayer implementation (TSExtrator) to setup workaround flag in default constructor.

@xuxucode
Copy link
Author

@gpinigin Yes, it has IDR frames.

Frames:

[FRAME]
... audio frames
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=4380960183
pkt_pts_time=48677.335367
pkt_dts=4380960183
pkt_dts_time=48677.335367
best_effort_timestamp=4380960183
best_effort_timestamp_time=48677.335367
pkt_duration=3600
pkt_duration_time=0.040000
pkt_pos=564
pkt_size=235758
width=1920
height=1080
pix_fmt=yuv420p
sample_aspect_ratio=1:1
pict_type=I
coded_picture_number=4
display_picture_number=0
interlaced_frame=1
top_field_first=1
repeat_pict=0
[/FRAME]
[FRAME]
... audio and video frames
[/FRAME]

As your suggestion I changed two places:

public TsExtractor(TimestampAdjuster timestampAdjuster) {
  this(timestampAdjuster, new DefaultStreamReaderFactory(DefaultStreamReaderFactory.WORKAROUND_ALLOW_NON_IDR_KEYFRAMES));
}
int workaroundFlags = DefaultStreamReaderFactory.WORKAROUND_MAP_BY_TYPE | DefaultStreamReaderFactory.WORKAROUND_ALLOW_NON_IDR_KEYFRAMES;

It works for this media and other medias that don't have IDR frames! Thank you very much!

But this media mentioned above has IDR frame, I don't know why it can't play normally.

@AquilesCanta
Copy link
Contributor

I will be closing this now. I think the file contains I-Frames, which are not actual IDR frames. We will possibly investigate this in the future, but it's not high priority right now. As @gpinigin said, try using the FLAG_ALLOW_NON_IDR_KEYFRAMES flag.

@needz
Copy link

needz commented Feb 3, 2017

How is it possible to apply this FLAG_ALLOW_NON_IDR_KEYFRAMES workaround in ExoPlayer 2 (preferably during player preparation)? I found H264Reader parameter, but is it possible to do without modifying the library code? Thanks!

@AquilesCanta
Copy link
Contributor

Have a look at DefaultTsPayloadReaderFactory. The constructor's flags argument allows you to set the flag. No library code needs modification.

@needz
Copy link

needz commented Feb 6, 2017

Thanks, I found it, but it seems to be buried deep inside TsExtractor and I can't figure out where exactly I should override it during player preparation. Could you point me in the right direction? Should I override it in buildMediaSource somehow?

case C.TYPE_OTHER: return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, eventLogger);

@AquilesCanta
Copy link
Contributor

You will need to provide your own ExtractorsFactory(instead of the default one), replacing the default TsExtractor constructor for the one that takes a PayloadReaderFactory. If you know you are going to play only Ts files, you can just provide that one.

@needz
Copy link

needz commented Apr 6, 2017

@ojw28, sorry to bother you, but do you think it's somehow possible to add an easy way to pass FLAG_ALLOW_NON_IDR_KEYFRAMES argument in ExtractorMediaSource or DefaultExtractorsFactory to avoid building complex custom ExtractorsFactory etc., since it's the only thing I have to change in the library for many TS streams to work?

@ojw28
Copy link
Contributor

ojw28 commented Apr 7, 2017

Filed #2657.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants