29
submitted 5 months ago by jackpot@lemmy.ml to c/asklemmy@lemmy.ml

i have a bunch of .m4a files in one folder, 1000s. can i automate their conversion somehow?

all 23 comments
sorted by: hot top controversial new old
[-] rollingflower@lemmy.kde.social 23 points 5 months ago* (last edited 5 months ago)

No as both are lossy codecs you will always lose quality doing so. You can do it with ffmpeg.

parallel ffmpeg -i {} {.}.opus ::: *.m4a

You may want to tweak parameters for bitrate, etc. But this is not needed at all, as AAC had patents that are now expired.

If you get .flac, .wav or similar lossless music, you should encode that with opus. But lossy to lossy makes nearly no sense (apart from specific players not supporting them)

[-] zurohki@aussie.zone 5 points 5 months ago

GNU Parallel works well for this kind of thing. A lot of audio stuff is single threaded, so unlike video transcoding running multiple conversions simultaneously is a useful thing to do. The command is simpler, too:

parallel ffmpeg -i {} {.}.opus ::: *.m4a
[-] rollingflower@lemmy.kde.social 3 points 5 months ago

Thanks, learning is always good, changed it

[-] otherbarry@lemmy.zip 3 points 5 months ago

If you get .flac, .wav or similar lossless music, you ~~should~~ could encode that with opus.

Fixed.

Unless you have a strong stance against people storing lossless files of their music? But I don't think that's quite what you meant :)

[-] rollingflower@lemmy.kde.social 2 points 5 months ago* (last edited 5 months ago)

"If you get .flac, .wav or similar lossless music, you should encode that with opus."

I am looking forward to similarly useful discussions XD

[-] jackpot@lemmy.ml 1 points 5 months ago

it's my music and i dont like proprietary formats

[-] miracleorange@beehaw.org 11 points 5 months ago

Unless the m4a files are ALAC-encoded, you shouldn't do it. m4a files tend to hold AAC-encoded audio, which is a lossy format. Opus is also a lossy format, so you'll only lose sound quality, basically. You should only convert lossless to lossy.

[-] ArcaneSlime@lemmy.dbzer0.com 4 points 5 months ago

If you're on linux try navigating to the folder in the terminal and running

for i in *.m4a; do ffmpeg -i "$i" "${i%.*}.opus"; done

[-] andrewta@lemmy.world 2 points 5 months ago

before doing anything like that.. back up the folder.

[-] ArcaneSlime@lemmy.dbzer0.com 4 points 5 months ago

Well sure always back up everything but this command will create new .opus files still leaving the original .m4a in the folder too, so even if it errors just delete the bad .opus files and try to resolve your ffmpeg codec issue before retrying the conversion or trying another method. Ffmpeg in my experience always converts with the "makes a new file with your file(s)" method, I've never had it do the "change the file destructively" method.

[-] Max_P@lemmy.max-p.me 2 points 5 months ago

It'll also error out or prompt to overwrite an existing file unless a flag is passed that tells it to overwrite unattended.

[-] ArcaneSlime@lemmy.dbzer0.com 1 points 5 months ago

Sure, but if it errors out no harm no foul, and don't pass any flags to overwrite the input file which I had not included above.

While I'm thinking about it, what is that flag? Because afaik ffmpeg can't overwrite and convert the file simultaneously, you have to use a temp file.

[-] Max_P@lemmy.max-p.me 1 points 5 months ago

That's the point: you have to go out of your way to accidentally overwrite your input files with ffmpeg.

And no it indeed can't output to the same file as input.

[-] steersman2484@sh.itjust.works 3 points 5 months ago* (last edited 5 months ago)

You can use the find command to do the stuff other commenters have posted recursive

[-] leanleft@lemmy.ml 3 points 5 months ago
[-] survivalmachine@beehaw.org 2 points 5 months ago

What platform do you have to work with?

[-] survivalmachine@beehaw.org 9 points 5 months ago

Disregard. The answer is 'no'. Opus is a lossy format, so there is no way to losslessly convert to it, regardless of the tools available to you.

[-] jackpot@lemmy.ml 2 points 5 months ago
[-] hperrin@lemmy.world 1 points 5 months ago

Opus is lossy, so no. But they’re already stored in a lossy format, so you probably won’t notice a difference if you use the same bitrate.

this post was submitted on 02 Apr 2024
29 points (89.2% liked)

Asklemmy

43287 readers
879 users here now

A loosely moderated place to ask open-ended questions

Search asklemmy 🔍

If your post meets the following criteria, it's welcome here!

  1. Open-ended question
  2. Not offensive: at this point, we do not have the bandwidth to moderate overtly political discussions. Assume best intent and be excellent to each other.
  3. Not regarding using or support for Lemmy: context, see the list of support communities and tools for finding communities below
  4. Not ad nauseam inducing: please make sure it is a question that would be new to most members
  5. An actual topic of discussion

Looking for support?

Looking for a community?

~Icon~ ~by~ ~@Double_A@discuss.tchncs.de~

founded 5 years ago
MODERATORS