-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Live alt audio inspired on fredvb and pull 700 #832
Live alt audio inspired on fredvb and pull 700 #832
Conversation
inspired on fredvb pull request 727 and INIT_PTS_FOUND on pull request 700 using 0.6.10 base code
thanks @sergiojm one way to do it would be to add a new state in audio-stream-controller when a new alt audio frag is loaded, you should then check if initPTS is defined.
onInitPtsFound: |
Changing BUFFER_FLUSH on audio with alternative audio On Live alt audio if we FLUSH Buffer imediatly can hold the play and delay that can lead to a moment that Alt audio is not available anymore Also now if it user pauses, gets away from live, switch audio track, would not break cause it will wait until it has a valid frag to flush
…spired_on_fredvb_and_pull_700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @sergiojm I made a couple of comments, some are cosmetic, main point i am not clear about is all the stuff related to this.prevTrackId in audioStreamController. If you could explain in layman's term what you are trying to achieve it ?
thanks !
|
||
var currentTime=this.media.currentTime; | ||
|
||
// When switching audio track the bufferEnd should only be considered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not clear about these code changes, could you explain what you are trying to achieve here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se bellow comments
@@ -229,6 +271,22 @@ class AudioStreamController extends EventHandler { | |||
} | |||
} | |||
if(frag) { | |||
//Only flush when we have a startPTS | |||
//Calculating when we have a new track frag available to play |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not clear as well why flushing is done before FRAG_LOADING, could you explain the logic here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we flush(0 to infinity audio) before loading and parse the stream get stuck until we receive the track, if we ever recieve it.
On VOD no impact since playlists are always available on any current time.
On Live streams, especially with low chunk durations, you get error on playlists and the player just hangs the playback since it cannot download a playlist with chunk for the current time, just downloads forward chunks and get a hole on the buffer since we already flushed.
The ideia is, trigger that a audio switch occur, dont flush, and when the frag is loaded and parsed(with correct start), then flush and append to buffer. Meantime it just continues to play the current audio buffer until is safe to make the proper flush and append.
The problem increases if u change multiple times the audio track, cause every time u just get delay from the live pos(due to the flush 0 to inifity). Will lead u to a position when the playlist simple doesn't have any valid ts for the currentTime.
Also if u pause a live stream with alt audio, then resume and switch the audio track, the player will immediatly crash, cause you are forcing the behavour.
So now with flushing only when you download and parsed a valid frag for the currentTime you can even pause for long secondes cause it will use the current audio track in buffer until
its safe to flush and append.
let accurateTimeOffset = details.PTSKnown || !details.live; | ||
this.demuxer.push(data.payload, audioCodec, null, start, fragCurrent.cc, trackId, sn, duration, fragCurrent.decryptdata, accurateTimeOffset, this.initPTS); | ||
} else { | ||
logger.log(`No video PTS for audio frag ${sn} of [${details.startSN} ,${details.endSN}],track ${trackId} , waiting for video pts`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest renaming 'No video PTS' into 'unknown video PTS'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good point will patch tomorrow
@@ -47,6 +47,8 @@ module.exports = { | |||
AUDIO_TRACK_LOADING: 'hlsAudioTrackLoading', | |||
// fired when an audio track loading finishes - data: { details : levelDetails object, id : audio track id, stats : { trequest, tfirst, tload, mtime} } | |||
AUDIO_TRACK_LOADED: 'hlsAudioTrackLoaded', | |||
// fired when the first timestamp is found. | |||
INIT_PTS_FOUND: 'hlsInitPtsFound', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you also describe the data object dispatched along with this event ?
you need to make it consistent with other events dispatched by demuxer:
{ id : demuxerId, initPTS: initPTS}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good point will patch tomorrow
@@ -149,6 +153,7 @@ class MP4Remuxer { | |||
if (computePTSDTS) { | |||
initPTS = Math.min(initPTS,videoSamples[0].pts - pesTimeScale * timeOffset); | |||
initDTS = Math.min(initDTS,videoSamples[0].dts - pesTimeScale * timeOffset); | |||
this.observer.trigger(Event.INIT_PTS_FOUND, {initPTS}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you change the dispatched object (for consistency) as being something like :
{ id : demuxerId, initPTS: initPTS}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good point will patch tomorrow
//Always update the new INIT PTS | ||
//Can change due level switch | ||
this.initPTS = data.initPTS; | ||
logger(`InitPTS , ${this.initPTS}, found from video track`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/logger/logger.log
this PR breaks support of alt audio VoD stream with discontinuity such as |
initPTS should be linked to a continuity counter index. |
closing in favor of https://github.com/dailymotion/hls.js/pull/860 that also contains these changes |
Live alternative audio inspired on
fredvb pull request 727 and INIT_PTS_FOUND on pull request 700
using base code 0.6.10