【问题标题】:Explanation on Integer to Array整数转数组说明
【发布时间】:2021-04-27 09:42:39
【问题描述】:

请帮忙

我知道您正在阅读这篇文章,如果没有答案,我将不胜感激,因为我觉得只有我一个人在试图解决这个问题。

这是如何工作的?

我已经彻底阅读了this document。它提到了一个名为 TimestampScale 的元素。我已经下载了大约 30 个 WebM 示例文件,并看到 HEX { 0x2AD7B12A D7 B1['2A','D7','B1'] } 或 NON-HEX 整数之后的值 { 42 215 177[42, 215, 177] } 始终相同:HEX { 0x830F424083 0F 42 40['83', '0F', '42', '40'] } 或 非十六进制整数 { 131 15 66 64[131,15,66,64] }。这些值都应该是 1000000 的默认值,如 Matroska 元素规范中所述。所以问题是……0x830F4240 怎么会变成1000000

上面的情况对你来说太草率了或者你想要更多的解释:

The TimestampScale identifier is equal to 0x2AD7B1. This is in Hexadecimal formatting.

The ways I format it in HEX are:
    0x2AD7B1
    2A D7 B1
    ['2A','D7','B1']

The ways I format it in Integers are:
    42 215 177
    [42, 215, 177]



Its preceding values are taken from a Uint8Array: | 131, 15, 66, 64 |
after the Hexadecimal values are taken. This is NOT in Hexadecimal formatting.
The reason why is because that is the raw data and I want to be
as open with you as possible.

The ways I format it in HEX are:
    0x830F4240
    83 0F 42 40
    ['83','0F','42','40']

The ways I format it in Integers are:
    131 15 66 64
    [131,15,66,64]

So question is: how does | 131, 15, 66, 64 | or 0x830F4240 equal 1000000?

所有值如何以 HEX 和整数显示:

    Hex: 2A D7 B1 83 0F 42 40
    Integers: 42 215 177 131 15 66 64

目标:

目标是弄清楚如何将值转换为1000000,这样我就可以在 Matroska 元素规范中的其他元素上使用这种转换(如持续时间转换)。

【问题讨论】:

  • +1,这个我也很好奇。我试图以 WebM/MKV 格式编辑元数据,但可以弄清楚这是如何工作的。

标签: arrays hex webm mkv uint8array


【解决方案1】:

WebM 容器格式是 Matroska 容器格式的子集。

Matroska 基于EBML (Extensible Binary Meta Language)

EBML 文档由元素组成。

元素由元素 ID、元素数据大小和元素数据组成。

元素数据大小是一个可变大小的整数。 (元素 ID 也是可变大小的整数。)

可变大小整数使用如下所示的位模式,其中前导位指示使用了多少字节,x 位存储实际值。

  • 1 字节:1xxxxxxx
  • 2 字节:01xxxxxx xxxxxxxx
  • 3 字节:001xxxxx xxxxxxxx xxxxxxxx
  • 4 字节:0001xxxx xxxxxxxx xxxxxxxx xxxxxxxx

等等

你提到的 TimestampScale 元素是由

  • 元素 ID 2A D7 B1
  • 元素数据大小83(一个 1 字节的可变大小整数,表示后面有 3 个字节的元素数据)
  • 元素数据0F 42 40(十进制1000000的大端编码)

【讨论】:

  • 你怎么知道83是指后面的三个字节?
  • 十六进制 83 是二进制 10000011。因为它是一个可变大小整数,所以最左边的1 位意味着这个可变大小整数是一个字节并且该位不是值的一部分。其余位0000011为实际值,即十进制3。
猜你喜欢
  • 2020-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多