mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Merge pull request #3843 from kapodamy/drop-writting-application-metadata
Drop writting application metadata in muxed files
This commit is contained in:
commit
af098aaac8
@ -43,7 +43,8 @@ public class DataReader {
|
|||||||
return readBuffer[readOffset++] & 0xFF;
|
return readBuffer[readOffset++] & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long skipBytes(long amount) throws IOException {
|
public long skipBytes(final long byteAmount) throws IOException {
|
||||||
|
long amount = byteAmount;
|
||||||
if (readCount < 0) {
|
if (readCount < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (readCount == 0) {
|
} else if (readCount == 0) {
|
||||||
@ -90,7 +91,10 @@ public class DataReader {
|
|||||||
return read(buffer, 0, buffer.length);
|
return read(buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(final byte[] buffer, int offset, int count) throws IOException {
|
public int read(final byte[] buffer, final int off, final int c) throws IOException {
|
||||||
|
int offset = off;
|
||||||
|
int count = c;
|
||||||
|
|
||||||
if (readCount < 0) {
|
if (readCount < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -464,16 +464,16 @@ public class Mp4FromDashWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initChunkTables(final TablesInfo tables, final int firstCount,
|
private void initChunkTables(final TablesInfo tables, final int firstCount,
|
||||||
final int succesiveCount) {
|
final int successiveCount) {
|
||||||
// tables.stsz holds amount of samples of the track (total)
|
// tables.stsz holds amount of samples of the track (total)
|
||||||
int totalSamples = (tables.stsz - firstCount);
|
int totalSamples = (tables.stsz - firstCount);
|
||||||
float chunkAmount = totalSamples / (float) succesiveCount;
|
float chunkAmount = totalSamples / (float) successiveCount;
|
||||||
int remainChunkOffset = (int) Math.ceil(chunkAmount);
|
int remainChunkOffset = (int) Math.ceil(chunkAmount);
|
||||||
boolean remain = remainChunkOffset != (int) chunkAmount;
|
boolean remain = remainChunkOffset != (int) chunkAmount;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
tables.stsc = 1;
|
tables.stsc = 1;
|
||||||
if (firstCount != succesiveCount) {
|
if (firstCount != successiveCount) {
|
||||||
tables.stsc++;
|
tables.stsc++;
|
||||||
}
|
}
|
||||||
if (remain) {
|
if (remain) {
|
||||||
@ -488,15 +488,15 @@ public class Mp4FromDashWriter {
|
|||||||
tables.stscBEntries[index++] = firstCount;
|
tables.stscBEntries[index++] = firstCount;
|
||||||
tables.stscBEntries[index++] = 1;
|
tables.stscBEntries[index++] = 1;
|
||||||
|
|
||||||
if (firstCount != succesiveCount) {
|
if (firstCount != successiveCount) {
|
||||||
tables.stscBEntries[index++] = 2;
|
tables.stscBEntries[index++] = 2;
|
||||||
tables.stscBEntries[index++] = succesiveCount;
|
tables.stscBEntries[index++] = successiveCount;
|
||||||
tables.stscBEntries[index++] = 1;
|
tables.stscBEntries[index++] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remain) {
|
if (remain) {
|
||||||
tables.stscBEntries[index++] = remainChunkOffset + 1;
|
tables.stscBEntries[index++] = remainChunkOffset + 1;
|
||||||
tables.stscBEntries[index++] = totalSamples % succesiveCount;
|
tables.stscBEntries[index++] = totalSamples % successiveCount;
|
||||||
tables.stscBEntries[index] = 1;
|
tables.stscBEntries[index] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,19 +640,20 @@ public class Mp4FromDashWriter {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] makeMdat(long refSize, final boolean is64) {
|
private byte[] makeMdat(final long refSize, final boolean is64) {
|
||||||
|
long size = refSize;
|
||||||
if (is64) {
|
if (is64) {
|
||||||
refSize += 16;
|
size += 16;
|
||||||
} else {
|
} else {
|
||||||
refSize += 8;
|
size += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(is64 ? 16 : 8)
|
ByteBuffer buffer = ByteBuffer.allocate(is64 ? 16 : 8)
|
||||||
.putInt(is64 ? 0x01 : (int) refSize)
|
.putInt(is64 ? 0x01 : (int) size)
|
||||||
.putInt(0x6D646174); // mdat
|
.putInt(0x6D646174); // mdat
|
||||||
|
|
||||||
if (is64) {
|
if (is64) {
|
||||||
buffer.putLong(refSize);
|
buffer.putLong(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer.array();
|
return buffer.array();
|
||||||
@ -717,18 +718,6 @@ public class Mp4FromDashWriter {
|
|||||||
makeTrak(i, durations[i], defaultMediaTime[i], tablesInfo[i], is64);
|
makeTrak(i, durations[i], defaultMediaTime[i], tablesInfo[i], is64);
|
||||||
}
|
}
|
||||||
|
|
||||||
// udta/meta/ilst/©too
|
|
||||||
auxWrite(new byte[]{
|
|
||||||
0x00, 0x00, 0x00, 0x5C, 0x75, 0x64, 0x74, 0x61, 0x00, 0x00, 0x00, 0x54, 0x6D, 0x65,
|
|
||||||
0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x64, 0x69, 0x72, 0x61, 0x70,
|
|
||||||
0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x27, 0x69, 0x6C, 0x73, 0x74, 0x00, 0x00, 0x00,
|
|
||||||
0x1F, (byte) 0xA9, 0x74, 0x6F, 0x6F, 0x00, 0x00, 0x00, 0x17, 0x64, 0x61, 0x74, 0x61,
|
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65 // "NewPipe" binary string
|
|
||||||
});
|
|
||||||
|
|
||||||
return lengthFor(start);
|
return lengthFor(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,20 +839,10 @@ public class Mp4FromDashWriter {
|
|||||||
|
|
||||||
private byte[] makeHdlr(final Hdlr hdlr) {
|
private byte[] makeHdlr(final Hdlr hdlr) {
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(new byte[]{
|
ByteBuffer buffer = ByteBuffer.wrap(new byte[]{
|
||||||
0x00, 0x00, 0x00, 0x77, 0x68, 0x64, 0x6C, 0x72, // hdlr
|
0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72, // hdlr
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
// binary string
|
0x00// null string character
|
||||||
// "ISO Media file created in NewPipe (
|
|
||||||
// A libre lightweight streaming frontend for Android)."
|
|
||||||
0x49, 0x53, 0x4F, 0x20, 0x4D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x66, 0x69, 0x6C, 0x65,
|
|
||||||
0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x20, 0x4E, 0x65,
|
|
||||||
0x77, 0x50, 0x69, 0x70, 0x65, 0x20, 0x28, 0x41, 0x20, 0x6C, 0x69, 0x62, 0x72, 0x65,
|
|
||||||
0x20, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x73,
|
|
||||||
0x74, 0x72, 0x65, 0x61, 0x6D, 0x69, 0x6E, 0x67,
|
|
||||||
0x20, 0x66, 0x72, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x64, 0x20, 0x66, 0x6F, 0x72, 0x20,
|
|
||||||
0x41, 0x6E,
|
|
||||||
0x64, 0x72, 0x6F, 0x69, 0x64, 0x29, 0x2E
|
|
||||||
});
|
});
|
||||||
|
|
||||||
buffer.position(12);
|
buffer.position(12);
|
||||||
@ -899,7 +878,7 @@ public class Mp4FromDashWriter {
|
|||||||
* characteristics of sample groups. The descriptive information is any other
|
* characteristics of sample groups. The descriptive information is any other
|
||||||
* information needed to define or characterize the sample group.
|
* information needed to define or characterize the sample group.
|
||||||
*
|
*
|
||||||
* ¿is replicabled this box?
|
* ¿is replicable this box?
|
||||||
* NO due lacks of documentation about this box but...
|
* NO due lacks of documentation about this box but...
|
||||||
* most of m4a encoders and ffmpeg uses this box with dummy values (same values)
|
* most of m4a encoders and ffmpeg uses this box with dummy values (same values)
|
||||||
*/
|
*/
|
||||||
|
@ -274,30 +274,15 @@ public class OggFromWebMWriter implements Closeable {
|
|||||||
if ("A_OPUS".equals(webmTrack.codecId)) {
|
if ("A_OPUS".equals(webmTrack.codecId)) {
|
||||||
return new byte[]{
|
return new byte[]{
|
||||||
0x4F, 0x70, 0x75, 0x73, 0x54, 0x61, 0x67, 0x73, // "OpusTags" binary string
|
0x4F, 0x70, 0x75, 0x73, 0x54, 0x61, 0x67, 0x73, // "OpusTags" binary string
|
||||||
0x07, 0x00, 0x00, 0x00, // writing application string size
|
0x00, 0x00, 0x00, 0x00, // writing application string size (not present)
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
|
||||||
0x00, 0x00, 0x00, 0x00 // additional tags count (zero means no tags)
|
0x00, 0x00, 0x00, 0x00 // additional tags count (zero means no tags)
|
||||||
};
|
};
|
||||||
} else if ("A_VORBIS".equals(webmTrack.codecId)) {
|
} else if ("A_VORBIS".equals(webmTrack.codecId)) {
|
||||||
return new byte[]{
|
return new byte[]{
|
||||||
0x03, // ????????
|
0x03, // ¿¿¿???
|
||||||
0x76, 0x6f, 0x72, 0x62, 0x69, 0x73, // "vorbis" binary string
|
0x76, 0x6f, 0x72, 0x62, 0x69, 0x73, // "vorbis" binary string
|
||||||
0x07, 0x00, 0x00, 0x00, // writting application string size
|
0x00, 0x00, 0x00, 0x00, // writing application string size (not present)
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
0x00, 0x00, 0x00, 0x00 // additional tags count (zero means no tags)
|
||||||
0x01, 0x00, 0x00, 0x00, // additional tags count (zero means no tags)
|
|
||||||
|
|
||||||
/*
|
|
||||||
// whole file duration (not implemented)
|
|
||||||
0x44,// tag string size
|
|
||||||
0x55, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x3D, 0x30,
|
|
||||||
0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x2E, 0x30,
|
|
||||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30
|
|
||||||
*/
|
|
||||||
0x0F, // tag string size
|
|
||||||
0x00, 0x00, 0x00, 0x45, 0x4E, 0x43, 0x4F,
|
|
||||||
0x44, 0x45, 0x52, 0x3D, // "ENCODER=" binary string
|
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ????????
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +362,7 @@ public class OggFromWebMWriter implements Closeable {
|
|||||||
return addPacketSegment(block.dataSize);
|
return addPacketSegment(block.dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addPacketSegment(int size) {
|
private boolean addPacketSegment(final int size) {
|
||||||
if (size > 65025) {
|
if (size > 65025) {
|
||||||
throw new UnsupportedOperationException("page size cannot be larger than 65025");
|
throw new UnsupportedOperationException("page size cannot be larger than 65025");
|
||||||
}
|
}
|
||||||
@ -396,8 +381,8 @@ public class OggFromWebMWriter implements Closeable {
|
|||||||
return false; // not enough space on the page
|
return false; // not enough space on the page
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; size > 0; size -= 255) {
|
for (int seg = size; seg > 0; seg -= 255) {
|
||||||
segmentTable[segmentTableSize++] = (byte) Math.min(size, 255);
|
segmentTable[segmentTableSize++] = (byte) Math.min(seg, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extra) {
|
if (extra) {
|
||||||
@ -419,12 +404,13 @@ public class OggFromWebMWriter implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calcCrc32(int initialCrc, final byte[] buffer, final int size) {
|
private int calcCrc32(final int initialCrc, final byte[] buffer, final int size) {
|
||||||
|
int crc = initialCrc;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
int reg = (initialCrc >>> 24) & 0xff;
|
int reg = (crc >>> 24) & 0xff;
|
||||||
initialCrc = (initialCrc << 8) ^ crc32Table[reg ^ (buffer[i] & 0xff)];
|
crc = (crc << 8) ^ crc32Table[reg ^ (buffer[i] & 0xff)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return initialCrc;
|
return crc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,31 +148,27 @@ public class WebMWriter implements Closeable {
|
|||||||
0x11, 0x4d, (byte) 0x9b, 0x74, (byte) 0xbe,
|
0x11, 0x4d, (byte) 0x9b, 0x74, (byte) 0xbe,
|
||||||
0x4d, (byte) 0xbb, (byte) 0x8b,
|
0x4d, (byte) 0xbb, (byte) 0x8b,
|
||||||
0x53, (byte) 0xab, (byte) 0x84, 0x15, 0x49, (byte) 0xa9, 0x66, 0x53,
|
0x53, (byte) 0xab, (byte) 0x84, 0x15, 0x49, (byte) 0xa9, 0x66, 0x53,
|
||||||
(byte) 0xac, (byte) 0x81, /*info offset*/ 0x43,
|
(byte) 0xac, (byte) 0x81,
|
||||||
|
/*info offset*/ 0x43,
|
||||||
0x4d, (byte) 0xbb, (byte) 0x8b, 0x53, (byte) 0xab,
|
0x4d, (byte) 0xbb, (byte) 0x8b, 0x53, (byte) 0xab,
|
||||||
(byte) 0x84, 0x16, 0x54, (byte) 0xae, 0x6b, 0x53, (byte) 0xac, (byte) 0x81,
|
(byte) 0x84, 0x16, 0x54, (byte) 0xae, 0x6b, 0x53, (byte) 0xac, (byte) 0x81,
|
||||||
/*tracks offset*/ 0x6a,
|
/*tracks offset*/ 0x56,
|
||||||
0x4d, (byte) 0xbb, (byte) 0x8e, 0x53, (byte) 0xab, (byte) 0x84, 0x1f,
|
0x4d, (byte) 0xbb, (byte) 0x8e, 0x53, (byte) 0xab, (byte) 0x84, 0x1f,
|
||||||
0x43, (byte) 0xb6, 0x75, 0x53, (byte) 0xac, (byte) 0x84, /*cluster offset [2]*/ 0x00, 0x00, 0x00, 0x00,
|
0x43, (byte) 0xb6, 0x75, 0x53, (byte) 0xac, (byte) 0x84,
|
||||||
|
/*cluster offset [2]*/ 0x00, 0x00, 0x00, 0x00,
|
||||||
0x4d, (byte) 0xbb, (byte) 0x8e, 0x53, (byte) 0xab, (byte) 0x84, 0x1c, 0x53,
|
0x4d, (byte) 0xbb, (byte) 0x8e, 0x53, (byte) 0xab, (byte) 0x84, 0x1c, 0x53,
|
||||||
(byte) 0xbb, 0x6b, 0x53, (byte) 0xac, (byte) 0x84, /*cues offset [7]*/ 0x00, 0x00, 0x00, 0x00
|
(byte) 0xbb, 0x6b, 0x53, (byte) 0xac, (byte) 0x84,
|
||||||
|
/*cues offset [7]*/ 0x00, 0x00, 0x00, 0x00
|
||||||
});
|
});
|
||||||
|
|
||||||
/* info */
|
/* info */
|
||||||
listBuffer.add(new byte[]{
|
listBuffer.add(new byte[]{
|
||||||
0x15, 0x49, (byte) 0xa9, 0x66, (byte) 0xa2, 0x2a, (byte) 0xd7, (byte) 0xb1
|
0x15, 0x49, (byte) 0xa9, 0x66, (byte) 0x8e, 0x2a, (byte) 0xd7, (byte) 0xb1
|
||||||
});
|
});
|
||||||
listBuffer.add(encode(DEFAULT_TIMECODE_SCALE, true)); // this value MUST NOT exceed 4 bytes
|
// the segment duration MUST NOT exceed 4 bytes
|
||||||
|
listBuffer.add(encode(DEFAULT_TIMECODE_SCALE, true));
|
||||||
listBuffer.add(new byte[]{0x44, (byte) 0x89, (byte) 0x84,
|
listBuffer.add(new byte[]{0x44, (byte) 0x89, (byte) 0x84,
|
||||||
0x00, 0x00, 0x00, 0x00, // info.duration
|
0x00, 0x00, 0x00, 0x00, // info.duration
|
||||||
|
|
||||||
/* MuxingApp */
|
|
||||||
0x4d, (byte) 0x80, (byte) 0x87, 0x4E,
|
|
||||||
0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
|
||||||
|
|
||||||
/* WritingApp */
|
|
||||||
0x57, 0x41, (byte) 0x87, 0x4E,
|
|
||||||
0x65, 0x77, 0x50, 0x69, 0x70, 0x65// "NewPipe" binary string
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* tracks */
|
/* tracks */
|
||||||
@ -416,9 +412,10 @@ public class WebMWriter implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long makeCluster(final SharpStream stream, final long timecode, long offset,
|
private long makeCluster(final SharpStream stream, final long timecode, final long offsetStart,
|
||||||
final boolean create) throws IOException {
|
final boolean create) throws IOException {
|
||||||
ClusterInfo cluster;
|
ClusterInfo cluster;
|
||||||
|
long offset = offsetStart;
|
||||||
|
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
// save the size of the previous cluster (maximum 256 MiB)
|
// save the size of the previous cluster (maximum 256 MiB)
|
||||||
@ -449,7 +446,7 @@ public class WebMWriter implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeEBML(final SharpStream stream) throws IOException {
|
private void makeEBML(final SharpStream stream) throws IOException {
|
||||||
// deafult values
|
// default values
|
||||||
dump(new byte[]{
|
dump(new byte[]{
|
||||||
0x1A, 0x45, (byte) 0xDF, (byte) 0xA3, 0x01, 0x00, 0x00, 0x00,
|
0x1A, 0x45, (byte) 0xDF, (byte) 0xA3, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x1F, 0x42, (byte) 0x86, (byte) 0x81, 0x01,
|
0x00, 0x00, 0x00, 0x1F, 0x42, (byte) 0x86, (byte) 0x81, 0x01,
|
||||||
@ -588,8 +585,10 @@ public class WebMWriter implements Closeable {
|
|||||||
return lengthFor(buffer);
|
return lengthFor(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeEbmlVoid(final SharpStream out, int size, final boolean wipe)
|
private void makeEbmlVoid(final SharpStream out, final int amount, final boolean wipe)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
int size = amount;
|
||||||
|
|
||||||
/* ebml void */
|
/* ebml void */
|
||||||
outByteBuffer.putShort(0, (short) 0xec20);
|
outByteBuffer.putShort(0, (short) 0xec20);
|
||||||
outByteBuffer.putShort(2, (short) (size - 4));
|
outByteBuffer.putShort(2, (short) (size - 4));
|
||||||
|
@ -16,21 +16,6 @@
|
|||||||
lines="278,310"/>
|
lines="278,310"/>
|
||||||
|
|
||||||
<!-- org.schabi.newpipe.streams -->
|
<!-- org.schabi.newpipe.streams -->
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="DataReader.java"
|
|
||||||
lines="46,93"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="Mp4FromDashWriter.java"
|
|
||||||
lines="643"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="OggFromWebMWriter.java"
|
|
||||||
lines="380,422"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="WebMWriter.java"
|
|
||||||
lines="419,591"/>
|
|
||||||
<suppress checks="LineLength"
|
<suppress checks="LineLength"
|
||||||
files="WebMWriter.java"
|
files="WebMWriter.java"
|
||||||
lines="156,158"/>
|
lines="156,158"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user