0

I can play all the elements in a playlist using

mplayer -playlist file.m3u

but when I dump the stream using

mplayer -dumpfile file.ts -dumpstream -playlist file.m3u

file.ts will only contain the first entry in the M3U playlist. How can I tell mplayer to dump everything?

1 Answer 1

1

An m3u or m3u8 file is just a list of links (one per line) mixed with comments. I used the following small Python program to download all parts of the playlist one-by-one:

#!/usr/bin/env python3

import subprocess
import os

def dump(playlist):
    urls = []

    with open(playlist, 'r') as fh:
        for line in fh:
            if line[0] == '#':
                continue

            urls.append(line.strip())

    count = 1
    for url in urls:
        dumpfile = 'part%04d.ts' % count
        count += 1

        if os.path.exists(dumpfile):
            print('Skipping %s...' % dumpfile)

        cmd = [
            'mplayer',
            '-dumpfile', dumpfile,
            '-dumpstream',
            url
        ]

        print('%s -> %s' % (url, dumpfile))
        rc = subprocess.call(cmd)
        if rc != 0:
            raise Exception('dump failed')

if __name__ == '__main__':
    import sys

    playlist = sys.argv[1]
    dump(playlist)

If the parts are MPEG .ts files ("transport stream"), see this question how to join them: Use ffmpeg copy codec to combine *.ts files into a single mp4

For other types of files, you will probably need tools. (see here for mp3)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .