1800
you are viewing a single comment's thread
view the rest of the comments
[-] Willer@lemmy.world 2 points 1 year ago

Thats why most of my yotuube downloads is .mka I found that matroska has better support than webm or ogg lol

[-] etuomaala@sopuli.xyz 1 points 1 year ago
I download opus .webm s,
    then use ffmpeg to convert to .opus,
    which I'm pretty sure is just ogg.
IDK, works great in quodlibet.
.webm can't be tagged, though.
Tagging is critical, especially replay_gain tags.

Here is my script:
#!/usr/bin/env python

# Youtube actually hosts audio-only opus tracks, but you can only get them
# in the webm container, which many music players, including quodlibet, don't
# know what to do with. This script downloads the track, then converts it with
# zero loss to the opus container using ffmpeg's `-acodec copy` feature.

import sys
from subprocess import call
from os.path import splitext
from os import remove, walk, listdir
from tempfile import TemporaryDirectory
from shutil import move

urls = sys.argv[1:]

with TemporaryDirectory(prefix='yta-') as tempdir:
    # Do not raise exceptions, because yt-dlp counts failure of a single
    # download in the list as an overall failure, exit code wise.
    call(['env', '-C', tempdir, 'yt-dlp', '-if', 'bestaudio',
        '-o', '%(artist)s - %(title)s - %(id)s.%(ext)s', '--'] + urls)

    for tempdir, dirs, files in walk(tempdir):
        for fn in files:
            path = tempdir+'/'+fn
            name, ext = splitext(path)
            if ext == '.webm':
                if call([
                    'ffmpeg', '-hide_banner',
                    '-i', path,
                    '-acodec', 'copy',
                    name+'.opus'
                ]) == 0:
                    remove(path)

    for node in listdir(tempdir):
        move(tempdir+'/'+node, '.')

this post was submitted on 23 Oct 2023
1800 points (97.5% liked)

memes

10335 readers
1665 users here now

Community rules

1. Be civilNo trolling, bigotry or other insulting / annoying behaviour

2. No politicsThis is non-politics community. For political memes please go to !politicalmemes@lemmy.world

3. No recent repostsCheck for reposts when posting a meme, you can only repost after 1 month

4. No botsNo bots without the express approval of the mods or the admins

5. No Spam/AdsNo advertisements or spam. This is an instance rule and the only way to live.

Sister communities

founded 1 year ago
MODERATORS