Skip to content

Commit

Permalink
fix: Fire trackinfo for audio only transmuxers
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jun 24, 2019
1 parent a3fcf47 commit 9b917e0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 35 deletions.
6 changes: 6 additions & 0 deletions lib/mp4/transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,12 @@ Transmuxer = function(options) {
.pipe(pipeline.audioSegmentStream)
.pipe(pipeline.coalesceStream);
}

// emit pmt info
self.trigger('trackinfo', {
hasAudio: !!audioTrack,
hasVideo: !!videoTrack
});
});

// Re-emit any data coming from the coalesce stream to the outside world
Expand Down
27 changes: 13 additions & 14 deletions lib/partial/transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ var aacPipeline = function(options) {
pipeline = {
type: 'aac',
tracks: {
audio: {
timelineStartInfo: {
baseMediaDecodeTime: options.baseMediaDecodeTime
}
}
audio: null
},
metadataStream: new m2ts.MetadataStream(),
aacStream: new AacStream(),
Expand Down Expand Up @@ -197,9 +193,9 @@ var aacPipeline = function(options) {
return;
}

pipeline.tracks.audio = {
pipeline.tracks.audio = pipeline.tracks.audio || {
timelineStartInfo: {
baseMediaDecodeTime: pipeline.tracks.audio.timelineStartInfo.baseMediaDecodeTime
baseMediaDecodeTime: options.baseMediaDecodeTime
},
codec: 'adts',
type: 'audio'
Expand All @@ -208,19 +204,13 @@ var aacPipeline = function(options) {
// hook up the audio segment stream to the first track with aac data
pipeline.audioSegmentStream = new AudioSegmentStream(pipeline.tracks.audio, options);

pipeline.audioSegmentStream.on('timingInfo',
pipeline.trigger.bind(pipeline, 'audioTimingInfo'));

// Set up the final part of the audio pipeline
pipeline.adtsStream
.pipe(pipeline.audioSegmentStream);

pipeline.audioSegmentStream.on('data', function(data) {
pipeline.trigger('data', {
type: 'audio',
data: data
});
});

pipeline.audioSegmentStream.on('partialdone',
pipeline.trigger.bind(pipeline, 'partialdone'));
pipeline.audioSegmentStream.on('done', pipeline.trigger.bind(pipeline, 'done'));
Expand All @@ -229,6 +219,14 @@ var aacPipeline = function(options) {
pipeline.audioSegmentStream.on('timingInfo',
pipeline.trigger.bind(pipeline, 'audioTimingInfo'));

// Set up the final part of the audio pipeline
pipeline.adtsStream
.pipe(pipeline.audioSegmentStream);

pipeline.trigger('trackinfo', {
hasAudio: !!pipeline.tracks.audio,
hasVideo: !!pipeline.tracks.video
});
});

// set the pipeline up as a stream before binding to get access to the trigger function
Expand Down Expand Up @@ -266,6 +264,7 @@ var Transmuxer = function(options) {
hasFlushed = true;

Transmuxer.prototype.init.call(this);
options.baseMediaDecodeTime = options.baseMediaDecodeTime || 0;

this.push = function(bytes) {
if (hasFlushed) {
Expand Down
65 changes: 44 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b917e0

Please sign in to comment.