mirror of
https://github.com/samsonjs/media.git
synced 2026-04-25 14:47:40 +00:00
move Matroska specific code back to the Matroska extractor
This commit is contained in:
parent
d71707f220
commit
ff64d2b382
2 changed files with 12 additions and 18 deletions
|
|
@ -56,6 +56,7 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static android.R.attr.data;
|
||||||
import static android.R.attr.format;
|
import static android.R.attr.format;
|
||||||
import static android.R.attr.longClickable;
|
import static android.R.attr.longClickable;
|
||||||
import static android.R.attr.mimeType;
|
import static android.R.attr.mimeType;
|
||||||
|
|
@ -1110,8 +1111,17 @@ public final class MatroskaExtractor implements Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSSASample(Track track) {
|
private void writeSSASample(Track track) {
|
||||||
String s = SSADecoder.buildDialogue(track.ssaSample, blockDurationUs);
|
long startUs = 0; // blockTimeUs
|
||||||
ParsableByteArray out = new ParsableByteArray(s.getBytes());
|
StringBuffer s = new StringBuffer();
|
||||||
|
s.append("Dialogue: ");
|
||||||
|
s.append(SSADecoder.formatTimeCode(startUs));
|
||||||
|
s.append(",");
|
||||||
|
long endUs = startUs + blockDurationUs;
|
||||||
|
s.append(SSADecoder.formatTimeCode(endUs));
|
||||||
|
s.append(",");
|
||||||
|
s.append(track.ssaSample);
|
||||||
|
s.append("\n");
|
||||||
|
ParsableByteArray out = new ParsableByteArray(s.toString().getBytes());
|
||||||
track.output.sampleData(out, out.limit());
|
track.output.sampleData(out, out.limit());
|
||||||
sampleBytesWritten += out.limit();
|
sampleBytesWritten += out.limit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,22 +192,6 @@ public class SSADecoder extends SimpleSubtitleDecoder {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildDialogue(String data, long durationUs) {
|
|
||||||
StringBuffer s = new StringBuffer();
|
|
||||||
s.append("Dialogue: ");
|
|
||||||
s.append(SSADecoder.formatTimeCode(0)); // blockTimeUs
|
|
||||||
s.append(",");
|
|
||||||
long endUs = durationUs; // + blockTimeUs
|
|
||||||
if (endUs == C.TIME_UNSET) {
|
|
||||||
endUs = 2*_1e6; // 2 second default duration
|
|
||||||
}
|
|
||||||
s.append(SSADecoder.formatTimeCode(endUs));
|
|
||||||
s.append(",");
|
|
||||||
s.append(data);
|
|
||||||
s.append("\n");
|
|
||||||
return s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatTimeCode(long tc_us) {
|
public static String formatTimeCode(long tc_us) {
|
||||||
long seconds = tc_us / _1e6;
|
long seconds = tc_us / _1e6;
|
||||||
long us = tc_us - _1e6*seconds;
|
long us = tc_us - _1e6*seconds;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue