Python Forum
MPEG DASH Package implementation similar to M3U8 package
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MPEG DASH Package implementation similar to M3U8 package
#1
I'm currently using the following package for working with .m3u8 (HLS) playlist files

m3u8 Package

I'm attempting to find a similar implementation for .mpd(MPEG-DASH) manifest files but all I found were simple parsers.Here are the 2 functions which have been implemented for .m3u8 playlist files. My purpose is to do the same for .mpd manifest files as well.

import logging
from datetime import timedelta
from os.path import basename

from furl import furl
from m3u8 import M3U8, Media, Playlist, Segment
from m3u8 import load as load_m3u8

def make_master_manifest(request, stream):
    if stream.info:
        bandwidth = int(stream.info["bw_out"])
        width = stream.info["meta"]["video"]["width"]
        height = stream.info["meta"]["video"]["height"]
        stream_info = {
            "bandwidth": bandwidth,
            "resolution": f"{width}x{height}",
            "codecs": "avc1.640028,mp4a.40.2",
        }
    else:
        stream_info = {"bandwidth": 1000}

    p = Playlist(basename(stream.index_manifest_url), stream_info, None, None)
    m = M3U8()
    m.add_playlist(p)

    for feed in stream.feeds.all():
        media = Media(
            type="SUBTITLES",
            group_id="feeds",
            name=f"feed-{feed.uuid}",
            language="en",
            default="YES",
            autoselect="YES",
            uri=furl(feed.manifest_url).set({"stream": stream.uuid}).url,
        )
        p.media.append(media)
        m.add_media(media)

    return m.dumps()

def make_feed_manifest(request, stream, feed):
    url = request.build_absolute_uri(stream.index_manifest_url)
    p = load_m3u8(url)
    m = M3U8()
    m.version = p.version
    m.target_duration = p.target_duration
    m.media_sequence = p.media_sequence
    for s in p.segments:
        if not m.program_date_time:
            m.program_date_time = s.current_program_date_time

        vtt_url = furl(basename(feed.webvtt_url)).set({"stream": stream.uuid})
        if s.current_program_date_time:
            vtt_url.args.update(
                {
                    "start": s.current_program_date_time.isoformat(),
                    "end": (
                        s.current_program_date_time + timedelta(seconds=s.duration)
                    ).isoformat(),
                    "epoch": stream.started_at.isoformat(),
                }
            )
        v = Segment(
            base_uri=vtt_url.url,
            uri=vtt_url.url,
            duration=s.duration,
            discontinuity=s.discontinuity,
            program_date_time=s.current_program_date_time,
        )
        m.add_segment(v)

    return m.dumps()
Spent quite a few hours attempting to find the same. Any guidance in the right direction would be great.
Reply
#2
I’ve been down the same road—unfortunately, there’s no direct equivalent to the m3u8 package for .mpd manifests. Most libraries are parsers only. You might need to build something on top of mpd-parser or xml.etree.ElementTree for full read/write support. Let me know if you start building one!
buran write May-06-2025, 09:34 AM:
spam link removed
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How To Easily Package a Tkinter GUI Tuurbo46 0 63 Mar-01-2026, 06:29 PM
Last Post: Tuurbo46
  How to package code for different python environments mayukun 2 1,194 Jul-17-2025, 11:36 AM
Last Post: snippsat
  NEED HELP WITH REQUEST PACKAGE Ishan69 1 1,165 Mar-05-2025, 06:55 PM
Last Post: noisefloor
  qpython package error Creepy 5 4,801 Apr-19-2024, 10:35 AM
Last Post: masonsbore
  problem install somewhere package akbarza 1 2,665 Dec-27-2023, 01:25 PM
Last Post: Gribouillis
  How to run utilities from a Python package? LugosisGhost 1 1,848 Dec-27-2023, 12:00 PM
Last Post: Larz60+
  Not able to install package caldwellpy and requirement txt file Samta282006 1 2,600 Dec-07-2023, 11:59 PM
Last Post: Larz60+
  imdby package problem lunacy90 8 5,242 Sep-04-2023, 07:13 PM
Last Post: deanhystad
  when package built, requirements not installed sabuzaki 1 1,816 Apr-07-2023, 09:01 AM
Last Post: sabuzaki
  Confused over Conda Package manager vs PIP JanOlvegg 3 10,691 Mar-09-2023, 02:09 PM
Last Post: JanOlvegg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020