-
Notifications
You must be signed in to change notification settings - Fork 213
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
Feat: change remux after initial creation #276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ var AdtsStream = require('../codecs/adts.js'); | |
var H264Stream = require('../codecs/h264').H264Stream; | ||
var AacStream = require('../aac'); | ||
var isLikelyAacData = require('../aac/utils').isLikelyAacData; | ||
var ONE_SECOND_IN_TS = require('../utils/clock').ONE_SECOND_IN_TS; | ||
|
||
var ONE_SECOND_IN_TS = 90000; // 90kHz clock | ||
|
||
// constants | ||
var AUDIO_PROPERTIES = [ | ||
|
@@ -709,14 +709,21 @@ CoalesceStream = function(options, metadataStream) { | |
// important information required for the construction of | ||
// the final segment | ||
this.pendingTracks.push(output.track); | ||
this.pendingBoxes.push(output.boxes); | ||
this.pendingBytes += output.boxes.byteLength; | ||
|
||
// TODO: is there an issue for this against chrome? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what caused the test change, and a lot of the headache I was seeing getting this to work |
||
// We unshift audio and push video because | ||
// as of Chrome 75 when switching from | ||
// one init segment to another if the video | ||
// mdat does not appear after the audio mdat | ||
// only audio will play for the duration of our transmux. | ||
if (output.track.type === 'video') { | ||
this.videoTrack = output.track; | ||
this.pendingBoxes.push(output.boxes); | ||
} | ||
if (output.track.type === 'audio') { | ||
this.audioTrack = output.track; | ||
this.pendingBoxes.unshift(output.boxes); | ||
} | ||
}; | ||
}; | ||
|
@@ -867,6 +874,10 @@ CoalesceStream.prototype.flush = function(flushSource) { | |
this.emittedTracks = 0; | ||
} | ||
}; | ||
|
||
CoalesceStream.prototype.setRemux = function(val) { | ||
this.remuxTracks = val; | ||
}; | ||
/** | ||
* A Stream that expects MP2T binary data as input and produces | ||
* corresponding media segments, suitable for use with Media Source | ||
|
@@ -1119,6 +1130,16 @@ Transmuxer = function(options) { | |
} | ||
}; | ||
|
||
this.setRemux = function(val) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows us to set the |
||
var pipeline = this.transmuxPipeline_; | ||
|
||
options.remux = val; | ||
|
||
if (pipeline && pipeline.coalesceStream) { | ||
pipeline.coalesceStream.setRemux(val); | ||
} | ||
}; | ||
|
||
this.alignGopsWith = function(gopsToAlignWith) { | ||
if (videoTrack && this.transmuxPipeline_.videoSegmentStream) { | ||
this.transmuxPipeline_.videoSegmentStream.alignGopsWith(gopsToAlignWith); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ var Stream = require('../utils/stream.js'); | |
var mp4 = require('../mp4/mp4-generator.js'); | ||
var audioFrameUtils = require('../mp4/audio-frame-utils'); | ||
var trackInfo = require('../mp4/track-decode-info.js'); | ||
var ONE_SECOND_IN_TS = require('../utils/clock').ONE_SECOND_IN_TS; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a required change but we use it this way in most other files. I think I missed this during the original rebase. |
||
|
||
// constants | ||
var AUDIO_PROPERTIES = [ | ||
|
@@ -14,8 +15,6 @@ var AUDIO_PROPERTIES = [ | |
'samplesize' | ||
]; | ||
|
||
var ONE_SECOND_IN_TS = 90000; // 90kHz clock | ||
|
||
/** | ||
* Constructs a single-track, ISO BMFF media segment from AAC data | ||
* events. The output of this stream can be fed to a SourceBuffer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,15 @@ var Transmuxer = function(options) { | |
} | ||
}; | ||
|
||
this.setRemux = function(val) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently this won't do anything as we don't have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it was intentional that there is no coalesceStream for the partial transmuxer in order to reduce the time to return data |
||
options.remux = val; | ||
|
||
if (pipeline && pipeline.coalesceStream) { | ||
pipeline.coalesceStream.setRemux(val); | ||
} | ||
}; | ||
|
||
|
||
this.setAudioAppendStart = function(audioAppendStart) { | ||
if (!pipeline || !pipeline.tracks.audio || !pipeline.audioSegmentStream) { | ||
return; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3738,7 +3738,7 @@ validateTrackFragment = function(track, segment, metadata, type) { | |
QUnit.test('parses an example mp2t file and generates combined media segments', function() { | ||
var | ||
segments = [], | ||
i, j, boxes, mfhd, trackType = 'video', trackId = 256, baseOffset = 0, initSegment; | ||
i, j, boxes, mfhd, trackType = 'audio', trackId = 257, baseOffset = 0, initSegment; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we now always output video first, this test had to be changed. |
||
|
||
transmuxer.on('data', function(segment) { | ||
if (segment.type === 'combined') { | ||
|
@@ -3780,15 +3780,16 @@ QUnit.test('parses an example mp2t file and generates combined media segments', | |
} | ||
|
||
validateTrackFragment(boxes[i].boxes[1], segments[0].data, { | ||
trackId: trackId++, | ||
trackId: trackId, | ||
width: 388, | ||
height: 300, | ||
baseOffset: baseOffset, | ||
mdatOffset: boxes[i].size | ||
}, trackType); | ||
|
||
trackId--; | ||
baseOffset = 0; | ||
trackType = 'audio'; | ||
trackType = 'video'; | ||
} | ||
} | ||
}); | ||
|
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.
This isn't a required change but we use it this way in most other files. I think I missed this during the original rebase.