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.7k stars 6.02k forks source link

How do I differentiate I-FRAME only tracks? #8313

Closed nishantkp closed 3 years ago

nishantkp commented 3 years ago

Question

I have a HLS manifest, which supposedly has 5 video tracks but ExoPlayer shows 8 video tracks. There is a total of 5 variants and 3 keyframes. How do I differentiate between variants and keyframes? I am only interested in variants for video track selection.

Link to test content

This is the manifest file, it shows 5 variants and 3 keyframes, but when I play it with the ExoPlayer demo app and open track selection dialog...it shows 8 video tracks instead of 5.

# AUDIO groups
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=“audio-aacl-96”,NAME=“English”,LANGUAGE=“en”,AUTOSELECT=YES,DEFAULT=YES,CHANNELS=“2",URI=“1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-audio_eng=96000.m3u8”
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=“audio-aacl-128",NAME=“English”,LANGUAGE=“en”,AUTOSELECT=YES,DEFAULT=YES,CHANNELS=“2”,URI=“1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-audio_eng=128000.m3u8"
# CLOSED-CAPTIONS groups
#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=“textstream”,NAME=“In stream captions”,AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID=“CC1”
# variants
#EXT-X-STREAM-INF:BANDWIDTH=668000,CODECS=“mp4a.40.2,avc1.42C01E”,RESOLUTION=640x360,FRAME-RATE=29.97,AUDIO=“audio-aacl-96”,CLOSED-CAPTIONS=“textstream”
1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=538408.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1020000,CODECS=“mp4a.40.2,avc1.42C01E”,RESOLUTION=640x360,FRAME-RATE=29.97,AUDIO=“audio-aacl-128",CLOSED-CAPTIONS=“textstream”
1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=839904.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1339000,CODECS=“mp4a.40.2,avc1.42C01F”,RESOLUTION=640x360,FRAME-RATE=29.97,AUDIO=“audio-aacl-128”,CLOSED-CAPTIONS=“textstream”
1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=1141117.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1978000,CODECS=“mp4a.40.2,avc1.4D401F”,RESOLUTION=960x540,FRAME-RATE=29.97,AUDIO=“audio-aacl-128",CLOSED-CAPTIONS=“textstream”
1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=1743733.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2791000,CODECS=“mp4a.40.2,avc1.4D401F”,RESOLUTION=1280x720,FRAME-RATE=29.97,AUDIO=“audio-aacl-128”,CLOSED-CAPTIONS=“textstream”
1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=2510400.m3u8
# keyframes
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=72000,CODECS=“avc1.42C01E”,RESOLUTION=640x360,URI=“keyframes/1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=538408.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=232000,CODECS=“avc1.4D401F”,RESOLUTION=960x540,URI=“keyframes/1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=1743733.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=333000,CODECS=“avc1.4D401F”,RESOLUTION=1280x720,URI=“keyframes/1606695616_nodrm_b6be931d-6512-4b1d-9779-65015b1c8f24-video=2510400.m3u8"

This is the log from ExoPlayer demo,

D/EventLogger: videoEnabled [eventTime=0.43, mediaPos=0.00, window=0, period=0]
D/EventLogger: audioEnabled [eventTime=0.43, mediaPos=0.00, window=0, period=0]
D/EventLogger: tracks [eventTime=0.43, mediaPos=0.00, window=0, period=0
D/EventLogger:   MediaCodecVideoRenderer [
D/EventLogger:     Group:0, adaptive_supported=YES [
D/EventLogger:       [X] Track:0, id=0, mimeType=video/avc, bitrate=668000, codecs=avc1.42C01E, res=640x360, supported=YES
D/EventLogger:       [X] Track:1, id=1, mimeType=video/avc, bitrate=1020000, codecs=avc1.42C01E, res=640x360, supported=YES
D/EventLogger:       [X] Track:2, id=2, mimeType=video/avc, bitrate=1339000, codecs=avc1.42C01F, res=640x360, supported=YES
D/EventLogger:       [X] Track:3, id=3, mimeType=video/avc, bitrate=1978000, codecs=avc1.4D401F, res=960x540, supported=YES
D/EventLogger:       [X] Track:4, id=4, mimeType=video/avc, bitrate=2791000, codecs=avc1.4D401F, res=1280x720, supported=YES
D/EventLogger:       [ ] Track:5, id=5, mimeType=video/avc, bitrate=72000, codecs=avc1.42C01E, res=640x360, supported=YES
D/EventLogger:       [ ] Track:6, id=6, mimeType=video/avc, bitrate=232000, codecs=avc1.4D401F, res=960x540, supported=YES
D/EventLogger:       [ ] Track:7, id=7, mimeType=video/avc, bitrate=333000, codecs=avc1.4D401F, res=1280x720, supported=YES
D/EventLogger:     ]
D/EventLogger:     Metadata [
D/EventLogger:       HlsTrackMetadataEntry
D/EventLogger:     ]
D/EventLogger:   ]
D/EventLogger:   MediaCodecAudioRenderer [
D/EventLogger:     Group:0, adaptive_supported=YES_NOT_SEAMLESS [
D/EventLogger:       [X] Track:0, id=audio-aacl-96:English, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=en, label=English, supported=YES
D/EventLogger:       [ ] Track:1, id=audio-aacl-128:English, mimeType=audio/mp4a-latm, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=en, label=English, supported=YES
D/EventLogger:     ]
D/EventLogger:     Metadata [
D/EventLogger:       HlsTrackMetadataEntry [audio-aacl-96, English]
D/EventLogger:     ]
D/EventLogger:   ]
D/EventLogger:   TextRenderer [
D/EventLogger:     Group:0, adaptive_supported=N/A [
D/EventLogger:       [X] Track:0, id=textstream:In stream captions, mimeType=application/cea-608, supported=YES
D/EventLogger:     ]
D/EventLogger:   ]
D/EventLogger:   MetadataRenderer [
D/EventLogger:     Group:0, adaptive_supported=N/A [
D/EventLogger:       [X] Track:0, id=null, mimeType=application/id3, supported=YES
D/EventLogger:     ]
D/EventLogger:     Group:1, adaptive_supported=N/A [
D/EventLogger:       [ ] Track:0, id=null, mimeType=application/id3, supported=YES
D/EventLogger:     ]
D/EventLogger:   ]
D/EventLogger:   CameraMotionRenderer []
D/EventLogger: ]

ExoPlayer version : 2.12.1

apptrash commented 3 years ago

https://github.com/google/ExoPlayer/issues/474

Take a look at this ticket. Seems like there is no support for #EXT-X-I-FRAME-STREAM-INF tag.

And also look at this: https://github.com/google/ExoPlayer/pull/6270

AquilesCanta commented 3 years ago

Hi, just a quick update, I've updated the referenced bugs to reflect that they have already been addressed (sorry for lagging behind on them!). So I-FRAME only variants are now fully supported. I'll leave the original question to @christosts.

christosts commented 3 years ago

The keyframes tracks have a format that is flagged with C.ROLE_FLAG_TRICK_PLAY. To identify keyframe tracks, inspect the formats inside the TrackGroup and check if any for the Format's roleFlags contains C.ROLE_FLAG_TRICK_PLAY:

format.roleFlags & C.ROLE_FLAG_TRICK_PLAY == C.ROLE_FLAG_TRICK_PLAY

Alternatively, to keep only the video tracks, check that their formats are not flagged with C.ROLE_FLAG_TRICK_PLAY:

format.roleFlags & C.ROLE_FLAG_TRICK_PLAY == 0

Closing this ticket, feel free to re-open if the answer is not sufficient.