Commits

Frédéric Yhuel  committed a663dc2

esds box (continued)

  • Participants
  • Parent commits f049f01

Comments (0)

Files changed (1)

File build_moov_box.py

             CodecPrivateData = qlevel.attributes["CodecPrivateData"].value
         except KeyError:
             CodecPrivateData = qlevel.attributes["WaveFormatEx"].value
+        try:
+            SamplingRate = qlevel.attributes["SamplingRate"].value
+        except KeyError:
+            SamplingRate = 44100
+        res[("SamplingRate", Index)] = int(SamplingRate)
 
         if FourCC == "WMAP":
             res[("WaveFormatEx", Index)] = b16decode(CodecPrivateData)
             audio_extra = build_wfex(params)
 
         sample_entry_size = 36 + len(audio_extra)
-        sample_rate = 0xac440000 #FIXME 0xac44 = 44100
+        sample_rate = params[("SamplingRate", 0)]<<16
+        print "sample_rate is %x" % sample_rate
         SampleEntry = pack(">L4sLHH", sample_entry_size, audio_fmt, 0, 0, 1)
         SampleEntry += pack(">QHHLL", 0, 2, 16, 0, sample_rate)
         SampleEntry += audio_extra
 
 def build_esds(params):
 
-    const = pack(">H3L", 0x0380, 0x80807000, 0x00000480, 0x80806240)
-    const += pack(">4LB", 0x15003000, 0x0001f400, 0x0001f400, 0x05808080, 0x50)
     CodecPrivateData = params[("AACL", 0)]
+    tag = 3
+    length = 0x80808070 #FIXME
+    ES_ID = 0
+    priority = 0
+
+    ES_Descriptor_header = pack(">BLHB", tag, length, ES_ID, priority)
+
+    tag = 4
+    length = 0x80808062 #FIXME
+    stype = 0x40
+    buf = (0x15, 0x00, 0x30)
+    max_bitrate = 0x000001f4
+    avg_bitrate = 0x000001f4
+
+    dec_config_descr_header = pack(">BLB3B", tag, length, stype, *buf)
+    dec_config_descr_header += pack(">LLB", max_bitrate, avg_bitrate, 0)
+
+    tag = 5
+    length = 0x80808050 #FIXME
+
+    dec_specific_info_header = pack(">BL", tag, length)
+
     end = pack(">3H", 0x0680, 0x8080, 0x0102)
-    esds_size = 12 + len(const) + len(CodecPrivateData) + len(end)
+
+    esds_size = 12 + len(ES_Descriptor_header) + len(dec_config_descr_header) +\
+            len (dec_specific_info_header) + len(CodecPrivateData) + len(end)
+
     esds_header = pack(">L4sL", esds_size, "esds", 0)
-    esds = esds_header + const + CodecPrivateData + end
+
+    esds = esds_header + ES_Descriptor_header + dec_config_descr_header +\
+            dec_specific_info_header + CodecPrivateData + end
 
     return esds