|
13 | 13 | import java.io.IOException; |
14 | 14 | import java.nio.ByteBuffer; |
15 | 15 | import java.nio.ByteOrder; |
| 16 | +import java.time.OffsetDateTime; |
16 | 17 |
|
17 | 18 | /** |
18 | 19 | * @author kapodamy |
@@ -272,11 +273,24 @@ private int makePacketheader(final long granPos, @NonNull final ByteBuffer buffe |
272 | 273 | @Nullable |
273 | 274 | private byte[] makeMetadata() { |
274 | 275 | if ("A_OPUS".equals(webmTrack.codecId)) { |
275 | | - return new byte[]{ |
| 276 | + final var commentFormat = "COMMENT=Downloaded using NewPipe on %s"; |
| 277 | + final var commentStr = String.format(commentFormat, OffsetDateTime.now().toString()); |
| 278 | + final var comment = commentStr.getBytes(); |
| 279 | + final var head = ByteBuffer.allocate(20 + comment.length); |
| 280 | + head.order(ByteOrder.LITTLE_ENDIAN); |
| 281 | + head.put(new byte[]{ |
| 282 | + // Byte order is LE, i.e. LSB first |
276 | 283 | 0x4F, 0x70, 0x75, 0x73, 0x54, 0x61, 0x67, 0x73, // "OpusTags" binary string |
277 | | - 0x00, 0x00, 0x00, 0x00, // writing application string size (not present) |
278 | | - 0x00, 0x00, 0x00, 0x00 // additional tags count (zero means no tags) |
279 | | - }; |
| 284 | + 0x00, 0x00, 0x00, 0x00, // vendor string of length 0 |
| 285 | + 0x01, 0x00, 0x00, 0x00, // additional tags count |
| 286 | + |
| 287 | + // + 4 bytes for the comment string length |
| 288 | + // + N bytes for the comment string itself |
| 289 | + }); |
| 290 | + head.putInt(comment.length); |
| 291 | + head.put(comment); |
| 292 | + |
| 293 | + return head.array(); |
280 | 294 | } else if ("A_VORBIS".equals(webmTrack.codecId)) { |
281 | 295 | return new byte[]{ |
282 | 296 | 0x03, // ¿¿¿??? |
|
0 commit comments