1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-06-13 17:06:53 +00:00
NewPipe/app/src/main/java/us/shandian/giga/postprocessing/WebMMuxer.java
kapodamy d00dc798f4 more SAF implementation
* full support for Directory API (Android Lollipop or later)
* best effort to handle any kind errors (missing file, revoked permissions, etc) and recover the download
* implemented directory choosing
* fix download database version upgrading
* misc. cleanup
* do not release permission on the old save path (if the user change the download directory) under SAF api
2019-06-03 18:18:20 -03:00

41 lines
1.1 KiB
Java

package us.shandian.giga.postprocessing;
import org.schabi.newpipe.streams.WebMReader.TrackKind;
import org.schabi.newpipe.streams.WebMReader.WebMTrack;
import org.schabi.newpipe.streams.WebMWriter;
import org.schabi.newpipe.streams.io.SharpStream;
import java.io.IOException;
/**
* @author kapodamy
*/
class WebMMuxer extends Postprocessing {
WebMMuxer() {
super(5 * 1024 * 1024/* 5 MiB */, 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;
}
}