I want to convert a bunch of FLAC files to OPUS, keeping the folder structure and all metadata (including the cover art). Does anyone know the best way to do that? All the finished scripts I found don't fulfill all of those requirements.

Needs to be something for Linux

@LilaHexe every time I do this I whip out a custom ffmpeg invocation… probably something like this could work (didn’t test, use with caution)

find '.' -name '*.flac' -type f -exec ffmpeg -i {} -acodec libopus -b:a 192k {}.opus \;

and then another pass to rename all .flac.opus files into .opus

@domi yep that seems to work :D

hehehe uhhhhh any way to multi-thread it?
👀

@LilaHexe i would add echo before ffmpeg, and then | parallel at the end

i’m like 45% sure this will just work, you have to check, i’m not good at GNU parallel XD

@domi @LilaHexe using `find '.' -name '*.flac' -type f -print0 | parallel -0 ffmpeg -i {} -acodec libopus -b:a 192k {}.opus`
should be more robust in regards to newlines in file names, but otherwise perform the same stuff
@fogti @domi lmao, I shit you not, I got it working with something very similar about 20 seconds ago. But mine involved saving the find results to a file, cuz I couldn't figure out how to pass it to parallel. Thanks!
@fogti @domi nooooo it doesn't transfer the album art

@LilaHexe @fogti i tested it and it worked for me…

can you try -vcodec copy ?

@LilaHexe @fogti sorry for the rollercoaster, dmi’s discount shell coding advice tends to end up like this on low-spoon days xD
@domi @fogti no luck. picard shows the album art on the FLAC, but on the OPUS it needs to fetch it from the internet first :(

@LilaHexe @fogti oh, okay, mpv goofed me and i didn’t actually have it working

one moment please

@LilaHexe @fogti okay, i found the issue:

  • opus doesn’t allow for embedding album art
  • webm only allows certain formats (not a static JPG)
  • mka works if you add -vcodec copy -map 0:v:0

mka is matroska audio if you haven’t heard of it before

@LilaHexe @fogti correction: -vcodec copy -map 0:v:0 -map 0:a:0, otherwise there’s no audio

but now i’m having weird slowdowns when playing those files… wth

@domi @LilaHexe @fogti ogg+opus absolutely allows for embedded album art. attached is an opus file containing music I made with the album art set to a dankpods screenshot (in png format, no clue if other formats do or don’t work). I set it in picard, and it shows for me in mpv and deadbeef.

I don’t know anything about the rest tho, including how to set album art in ffmpeg, sorry

@_r @LilaHexe @fogti well, it didn’t work with ffmpeg and jpeg. please no bully.
@domi @LilaHexe @fogti I was just trying to offer my knowledge, sorry if it came off as mean. embedded album art in opus just happens to be something I use for my own music playlist (though I’m slowly migrating to flac where I can)

@domi @LilaHexe @fogti actually, I just remembered that I solved this myself a couple years ago. sorry! memory bad  

here’s the relevant code I used to embed youtube thumbnails into opus files using ffmpeg: https://github.com/RiedleroD/RYTD/blob/9fa6a0750e7171ed2c1f97a1e66fc5324a6289e9/rytd.py#L76

to save you the search: the resulting base64 string gets passed to ffmpeg using -metadata metadata_block_picture=<base64img>

the code is pretty shit, but it does work. It’s also hardcoded to 128x128 quantized png, but I don’t see a reason why other stuff wouldn’t work. idk, it’s been ages since I touched this. I hope it can be useful to you anyway

@_r @domi @LilaHexe https://superuser.com/questions/1708793/how-to-add-an-art-cover-in-ogg-audio-file/1816195#1816195 mentions similar info.

the python code I linked should be easily adaptable to work in the general case.

How to add an art cover in OGG audio file?

My intention is to add a cover art in OGG file containing only audio without it being created as a video. Output: ffrobe audio.ogg Input #0, ogg, from 'audio.ogg': Duration: 00:03:26.60, start: 0.

Super User
Add album art cover to an OGG/opus file from the command line

I managed to add an album art cover to an OGG/opus file with Kid3 - Audio Tagger but I'd like to do it via the command line on all the files of an album. I tried with ffmpeg but it did not work : $

Super User