Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M3U VLC Export #2051

Open
4 tasks done
dreamflasher opened this issue Jun 22, 2024 · 3 comments
Open
4 tasks done

M3U VLC Export #2051

dreamflasher opened this issue Jun 22, 2024 · 3 comments

Comments

@dreamflasher
Copy link

The fewer issues I have to read, the more new features I will have time to implement, so I ask that you please try these things first

Description

I'd like to be able to export projects as M3U playlist files, including vlc start-stop info:

#EXTVLCOPT:start-time=28.3
#EXTVLCOPT:stop-time=36.7
video.mp4

This would allow me to play cut videos without storing the cut segments (and thus saving disk space) and allows lossless cutting on a frame level.

@mifi
Copy link
Owner

mifi commented Jun 23, 2024

Interesting use case. So you want to be able to store an m3u playlist which has a bunch of start-stop times for the same video file, thus when a player plays it back, the player effectively just seeks back and forth in the same video?

Is it m3u or m3u8?

@dreamflasher
Copy link
Author

dreamflasher commented Jun 23, 2024

Yeah, meanwhile I actually implemented a python script to convert LLC to M3U, maybe it's helpful for others or could be used as an inspiration:

import urllib.parse
from pathlib import Path

import demjson3
from fire import Fire


def main(llc: Path):
    llc = Path(llc)
    l = demjson3.decode(llc.read_text())
    segments = l["cutSegments"]

    for i, segment in enumerate(segments):
        out = ["#EXTM3U"]
        out.append(f"#EXTVLCOPT:start-time={segment['start']}")
        out.append(f"#EXTVLCOPT:stop-time={segment['end']}")
        out.append(urllib.parse.quote(l["mediaFileName"]))
        Path(llc.parent / f"{llc.stem}-{i}-{segment['name']}.m3u").write_text("\n".join(out))


if __name__ == '__main__':
    Fire(main)

I'm using this with M3U, but it also works with M3U8, I am not attached to the file extension.

And it works like a charm. VLC is fast enough in opening and jumping to the file position. I implemented it the way that it creates an m3u file for each split segment, because I want to reorder the segments or only use specific segments each time – but in lossless cut it could just output it to one file with all segments.

@mifi
Copy link
Owner

mifi commented Jun 23, 2024

thanks. i agree it's a cool feature so i'll consider implementing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants