google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

Incorrect playing of Coub video #3077

Open sshurick opened 7 years ago

sshurick commented 7 years ago

Hi all!

Issue description

I've tried to embed playing of Coub's videos in my app with ExoPlayer and I'm faced with the problem that ExoPlayer incorrectly reports length of those videos and as a consequence fails to loop/replay them. Coub's videos have video steam only (no audio) coded with H264 and packet into mp4 container.

Reproduction steps

Add the following to the demo App:
"name": "Misc",
"samples": [
  {
    "name": "Coub sample",
    "uri": "https://coubsecure-s.akamaihd.net/get/b102/p/coub/simple/cw_file/010b9332a46/0ec149d027f8d844f52f8/muted_mp4_med_size_1477783374_muted_med.mp4"
  },
]
Expected result:
  Reported length of the video is 8 seconds.
  The video can be replayed/rewinded.

Actual result:
  Reported length of the video is 2 seconds only
  The player fails to replay/rewind.

}

Link to test content

https://coubsecure-s.akamaihd.net/get/b102/p/coub/simple/cw_file/010b9332a46/0ec149d027f8d844f52f8/muted_mp4_med_size_1477783374_muted_med.mp4 https://coubsecure-s.akamaihd.net/get/b175/p/coub/simple/cw_file/54e7b85e97a/07582b3a1d6ae594bac15/muted_mp4_med_size_1499090722_muted_med.mp4 These videos are ripped from standard Coub API, I can provide more samples if needed.

Version of ExoPlayer being used

2.4.1 & 2.4.3

Device(s) and version(s) of Android being used

4.4 (Huawei honor) 7.0 (Emulator)

A full bug report captured from the device

                                                                                   --------- beginning of system
07-18 11:45:03.696 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: videoDisabled [90.89]
07-18 11:45:06.077 11469-11469/com.google.android.exoplayer2.demo I/ExoPlayerImpl: Init ExoPlayerLib/2.4.1 [generic_x86, Android SDK built for x86, Google, 24]
07-18 11:45:06.080 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [0.00, true, I]
07-18 11:45:06.085 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [0.01, true, B]
07-18 11:45:06.086 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: sourceInfo [periodCount=1, windowCount=1
07-18 11:45:06.086 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   period [?]
07-18 11:45:06.086 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   window [?, false, false]
07-18 11:45:06.086 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: ]
07-18 11:45:06.086 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: loading [true]
07-18 11:45:06.160 11469-14960/com.google.android.exoplayer2.demo I/OMXClient: MuxOMX ctor
07-18 11:45:06.175 11469-14959/com.google.android.exoplayer2.demo I/MediaCodec: [OMX.google.h264.decoder] setting surface generation to 11744260
07-18 11:45:06.176 11469-14960/com.google.android.exoplayer2.demo E/ACodec: [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
07-18 11:45:06.215 11469-11496/com.google.android.exoplayer2.demo D/EGL_emulation: eglMakeCurrent: 0xb60050c0: ver 2 0 (tinfo 0xb6003220)
07-18 11:45:06.241 11469-11496/com.google.android.exoplayer2.demo D/EGL_emulation: eglMakeCurrent: 0xb60050c0: ver 2 0 (tinfo 0xb6003220)
07-18 11:45:06.245 11469-14959/com.google.android.exoplayer2.demo D/MediaCodec: [OMX.google.h264.decoder] setting dataspace on output surface to #103
07-18 11:45:06.248 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: sourceInfo [periodCount=1, windowCount=1
07-18 11:45:06.248 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   period [1.92]
07-18 11:45:06.248 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   window [1.92, true, false]
07-18 11:45:06.248 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: ]
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: Tracks [
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   Renderer:0 [
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:     Group:0, adaptive_supported=N/A [
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:       [X] Track:0, id=1, mimeType=video/avc, res=640x328, supported=YES
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:     ]
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger:   ]
07-18 11:45:06.251 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: ]
07-18 11:45:06.252 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: videoEnabled [0.17]
07-18 11:45:06.252 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: videoFormatChanged [0.17, id=1, mimeType=video/avc, res=640x328]
07-18 11:45:06.268 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [0.19, true, R]
07-18 11:45:06.272 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: loading [false]
07-18 11:45:06.273 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: videoDecoderInitialized [0.19, OMX.google.h264.decoder]
07-18 11:45:06.273 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [0.19, true, B]
07-18 11:45:06.275 11469-14959/com.google.android.exoplayer2.demo D/SoftwareRenderer: setting dataspace on output surface to #103
07-18 11:45:06.278 11469-11496/com.google.android.exoplayer2.demo D/EGL_emulation: eglMakeCurrent: 0xb60050c0: ver 2 0 (tinfo 0xb6003220)
07-18 11:45:06.296 11469-11496/com.google.android.exoplayer2.demo D/EGL_emulation: eglMakeCurrent: 0xb60050c0: ver 2 0 (tinfo 0xb6003220)
07-18 11:45:06.387 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: renderedFirstFrame [Surface(name=null)/@0xb177275]
07-18 11:45:06.464 11469-11496/com.google.android.exoplayer2.demo D/EGL_emulation: eglMakeCurrent: 0xb60050c0: ver 2 0 (tinfo 0xb6003220)
07-18 11:45:06.477 11469-11496/com.google.android.exoplayer2.demo D/OpenGLRenderer: endAllActiveAnimators on 0xa88acc00 (ExpandableListView) with handle 0x98b16ac0
07-18 11:45:06.495 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [0.42, true, R]
07-18 11:45:14.184 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: state [8.11, true, E]
07-18 11:45:14.185 11469-11469/com.google.android.exoplayer2.demo D/EventLogger: droppedFrames [8.11, 1]

Thank you in advance. bugreport-NYC-2017-07-18-11-44-01.zip

andrewlewis commented 7 years ago

I had a quick look at the second stream provided above. It has a sidx box that declares a 1.92 second long chunk, while the trak box declares a duration of about 8 seconds. So I suspect the media is not valid.

ojw28 commented 7 years ago

The media appears to have 6 sidx boxes interleaved through the file. Each contains only a single entry, that presumably corresponds to the following chunk of media.

It's unclear how you're really supposed to seek in such a file, since there doesn't seem to be anything akin to a top level index. It's also unclear what purpose the single entry sidx boxes actually serve.

This might not be an actual violation of the FMP4 spec, but it's certainly extremely weird, and I'm unsure what the best way of handling this kind of media is. I'd suggest you report the issue to Coub in the first instance. If they're intending these files to be consumed elsewhere then they'd do well to structure them in a more standard way (i.e. a single sidx box near the start of the media, that indexes the whole file).

sshurick commented 7 years ago

Guys, thank you for the quick reply! Glad to see that Exo is alive and kicking!

Not sure if Coub team will tackle this issue soon since they have all the media in this format. One more thing that I've noticed about Coub's mpegs is that VLC for Android & all my desktop players play them like a charm

ojw28 commented 7 years ago

We could probably just use the trak box duration when it's longer, since the sidx box can legitimately index only part of the stream. And then probably ignore all but the first sidx box as well.

Seeking wont work properly in that case. I doubt seeking works quite right in other players either, since there's no actual top level index for the stream as far as I can see. Perhaps it doesn't matter though; if the videos are always short.