Skip to content
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

fix: Fire trackinfo for audio only transmuxers #277

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 || {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this more like the non-partial transmuxer.

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',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were firing audioTimingInfo twice, woops

pipeline.trigger.bind(pipeline, 'audioTimingInfo'));

// Set up the final part of the audio pipeline
pipeline.adtsStream
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the actual pipe below listener definitions just in case.

.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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this baseMediaDecodeTime defaults to undefined, which is weird.


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.