1. Frédéric Yhuel
  2. Python scripts

Commits

Frédéric Yhuel  committed 921c717

improve wfex box

  • Participants
  • Parent commits e5e20c9
  • Branches master

Comments (0)

Files changed (1)

File build_moov_box.py

View file
     astream = None
     streams = ss_media.getElementsByTagName("StreamIndex")
     global next_track_ID
+    stream_nb = len(streams)
     for stream in streams:
         if stream.attributes["Type"].value == "video":
             vstream = stream
             if track_ID["video"] == 0:
-                track_ID["video"] = next_track_ID
+                track_ID["video"] = 3 - next_track_ID
                 next_track_ID += 1
         if stream.attributes["Type"].value == "audio":
             astream = stream
             if track_ID["audio"] == 0:
-                track_ID["audio"] = next_track_ID
+                track_ID["audio"] = 3 - next_track_ID
                 next_track_ID += 1
         #if stream.attributes["Type"].value == "text":
             #tstream = stream
         except KeyError:
             SamplingRate = 44100
         res[("SamplingRate", Index)] = int(SamplingRate)
+        try:
+            Bitrate = qlevel.attributes["Bitrate"].value
+        except KeyError:
+            Bitrate = 96000
+        res[("Bitrate", Index)] = int(Bitrate)
+
 
         if FourCC == "WMAP":
             res[("WaveFormatEx", Index)] = b16decode(CodecPrivateData)
         if params["vcodec"] == "H264":
             video_fmt = "avc1"
             video_extra = build_avcC(params)
+            #video_extra = ""
         elif params["vcodec"] == "WVC1":
             video_fmt = "vc-1"
             video_extra = build_dvc1(params)
+            #video_extra = ""
 
         sample_entry_size = 86 + len(video_extra)
         width = params["MaxWidth"]
         if params["acodec"] == "AACL":
             audio_fmt = "mp4a"
             audio_extra = build_esds(params)
+            #audio_extra = ""
 
         elif params["acodec"] == "WMAP":
             audio_fmt = "wma "
             audio_extra = build_wfex(params)
+            #audio_extra = ""
 
         sample_entry_size = 36 + len(audio_extra)
         sample_rate = params[("SamplingRate", 0)]<<16
     return esds
 
 def build_wfex(params):
-    const = pack(">4LH", 0x62010200, 0x44ac0000, 0xe32e0000, 0x6b111000, 0x1200)
+    sample_rate = params[("SamplingRate", 0)]
+    bitrate = params[("Bitrate", 0)]
+    bitrate /= 8
+    const = pack(">L", 0x62010200)
+    # byte order is not as usual there
+    const += pack("2L", sample_rate, bitrate)
+    const += pack(">LH", 0x6b111000, 0x1200)
     WaveFormatEx = params[("WaveFormatEx", 0)]
     wfex_size = 8 + len(const) + len(WaveFormatEx)
     wfex_header = pack(">L4s", wfex_size, "wfex")