mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-04 15:28:21 +03:00
45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
|
package us.shandian.giga.postprocessing;
|
||
|
|
||
|
import org.schabi.newpipe.extractor.utils.WebMReader.TrackKind;
|
||
|
import org.schabi.newpipe.extractor.utils.WebMReader.WebMTrack;
|
||
|
import org.schabi.newpipe.extractor.utils.WebMWriter;
|
||
|
import org.schabi.newpipe.extractor.utils.io.SharpStream;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
|
||
|
import us.shandian.giga.get.DownloadMission;
|
||
|
|
||
|
/**
|
||
|
* @author kapodamy
|
||
|
*/
|
||
|
class WebMMuxer extends Postprocessing {
|
||
|
|
||
|
WebMMuxer(DownloadMission mission) {
|
||
|
super(mission);
|
||
|
recommendedReserve = (1024 + 512) * 1024;// 1.50 MiB
|
||
|
worksOnSameFile = true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
int process(SharpStream out, SharpStream... sources) throws IOException {
|
||
|
WebMWriter muxer = new WebMWriter(sources);
|
||
|
muxer.parseSources();
|
||
|
|
||
|
// youtube uses a webm with a fake video track that acts as a "cover image"
|
||
|
WebMTrack[] tracks = muxer.getTracksFromSource(1);
|
||
|
int audioTrackIndex = 0;
|
||
|
for (int i = 0; i < tracks.length; i++) {
|
||
|
if (tracks[i].kind == TrackKind.Audio) {
|
||
|
audioTrackIndex = i;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
muxer.selectTracks(0, audioTrackIndex);
|
||
|
muxer.build(out);
|
||
|
|
||
|
return OK_RESULT;
|
||
|
}
|
||
|
|
||
|
}
|