3

I try to parse WMV (ASF) files without any SDK, just by decoding raw bytes. Now I have problem with ASF_Data_Object, where I can't find length of data packet. More precise, Single payload data packet.

See image: Sample

Here I have 9 packets, but unable to find size of individual packet. How I can determine border between packets?

I think, my problem at byte 0x411, where field "Length type flags". As you can see, here 0 value, so all flags are zero. Even Packet Length Type.

enter image description here enter image description here

Yes, 0 value here allowed here. But how to read this type of content?

This is now compressed payload, as replication data is 8, not 1. So, this is single payload without additional fields of size.

Sample of WMV file: https://files.catbox.moe/b51l2j.wmv

bukkojot
  • 1,526
  • 1
  • 11
  • 16
  • 1
    Isn't it fixed-sized packet objects with size derived from data object reduced by 5.1 ASF Data Object header (9 packets, 3200 bytes each). – Roman R. Mar 08 '18 at 18:29
  • I tried it, but after 3200 bytes I expect 0x82 0x00 0x00 as new data packet, but here nothing like this. – bukkojot Mar 08 '18 at 21:23
  • 1
    `82 00` at 0x040E (packet 0), then next `82 00` at 0x108E (packet 1), then at 0x1D0E. 3200 byte increments. – Roman R. Mar 08 '18 at 21:39
  • Many thanks! I incorrectly calculated payload size, so try to find size of payload somewhere in data block. It very strange for me, using "minimal packet size", which equals to "maximum packet size" for every packet in file, even if sometimes payload side defined in packet itself. Reading ffmpeg sources was very helpful, your help is better. Write answer and I will accept it. – bukkojot Mar 09 '18 at 08:49

1 Answers1

2

You seem to be having fixed size packets with no explicit payload length included, meaning that payload data size is derived from top level data object structure.

Spec quote commented:

enter image description here

That is, the ASF data object carries 9 packets, 3200 bytes each, then internally the packets contain payload 3174 bytes of payload per packet except the last one which has less data and some padding.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Amazing! I just used field MinimumDataPacketSize in ASF_FILE_PROPERTIES_OBJECT and was a bit confused. Thank you again! – bukkojot Mar 11 '18 at 09:03
  • Roman, I have another problem. I have strange WMV file, where (object_size-50)/totaldatapackets produces non-integer result (2787.52). And this value less than MinimumDataPacketSize in ASF_FILE_PROPERTIES_OBJECT (2888 bytes). File not truncated, as after data section exists indexes and size of Data Object is correct. More, every packet has field "packet size" and it's value is 2886 bytes (and 0 bytes of padding). Currently I just ignore all values of "padding data" and "packet size" and just pad with zeros if need, all works fine... But I don't know in correctness of this. What you think? – bukkojot Mar 18 '18 at 12:48
  • @bukkojot: perhaps you could share the file? – Roman R. Mar 19 '18 at 18:08
  • magnet:?xt=urn:btih:10C470ED654D35F00111E42180E8CC7A58DF0697 (wmv file only) – bukkojot Apr 17 '18 at 10:16