How can I convert an album that is FLAC (high quality lossless) into an MP4 specifically without losing quality or is it even possible?
from sopularity_fax@sopuli.xyz to nostupidquestions@lemmy.ca on 08 Nov 16:06
https://sopuli.xyz/post/36422536
from sopularity_fax@sopuli.xyz to nostupidquestions@lemmy.ca on 08 Nov 16:06
https://sopuli.xyz/post/36422536
I have an album thats a bit more than 200MB, converted to just an audio only M4a or MP4 its still under 80MB
Is that 120+MB all chaff or is there another way to prevent losing all muh damn wheat
CONSTRAINT/NON-CONSTRAINTS
FILE SIZE DOES NOT MATTER AT ALL TO ME. JUST TO BE CLEAR
MUST BE AN MP4 “video” file. I get that MP4 is a container or whatever but that is a hard constraint—Please respect that
M4A/AAC are not acceptable. It must be within the container that is MP4, non-negotiable
#nostupidquestions
threaded - newest
Flac has all the sounds a computer can detect. “Lossy” formats (like AAC typically used in mp4 containers) strive to only retain the sounds a person can detect.
en.wikipedia.org/wiki/Advanced_Audio_Coding
Unless you’re a particularly astute listener AND are listening on high end gear you are unlikely to care about the difference in sound quality.
It might matter if you’re going to do further conversions, though. If you want to convert the album to 2-3 lossy formats it’s best to start with something lossless. But that’s a pretty niche use case in 2025.
MP4 is a “container format” designed for having multiple media streams (typically video, audio, and subtitles) in one file. Despite the name, it’s not the successor to MP3. The fact that a file is an MP4 doesn’t tell you what compression was used to compress whatever audio (or other) streams might happen to be in the file. You can make an MP4 file with a single FLAC audio stream in it. Or an MP4 file with a single MP3 or OGV or Speex stream in it. And the size of an MP4 can vary wildly based on what codecs were used to compress whatever streams might be in it. An .m4a file is just an MP4 file with a different extension intended to indicate that that particular MP4 file only has audio in it.
But anyway, to your question, the thing with lossless compression like FLAC is that it gives better fidelity at the cost of larger file sizes. Not as large as uncompressed audio files like WAVE files, but much larger typically than lossy-compressed formats like MP3, OGV, Speex, Opus, AAC, WMA, etc.
If you’re wanting to keep the same level of fidelity (that is, lossless), your options are basically (and being honest here, I got this list with like 30 seconds of googling) FLAC, ALAC, Ape, and WavePack. I’ve seen a couple of mentions that Ape may be a very tiny bit better than FLAC, but at the cost of much more computational complexity (e.g. more CPU usage). And WavePack might (I’m not sure) be a tiny bit better in some fairly narrow cases. ALAC seems mostly agreed to be inferior to FLAC in almost every way.
So, you could play with other lossless formats and see if you could shave a tiny bit off of your file sizes relative to FLAC, but the chances you’ll get a significant savings over FLAC without using a lossy format is are basically nil. And other lossless formats are likely to be more computationally intensive and less supported by hardware and software.
And this isn’t just because FLAC is not as good as it could be. Lossless compression is inherently going to give you bigger file sizes than lossy. FLAC has a certain amount of information it has to pack into a stream and, being lossless, it’s not allowed to strategically thow away part of that information to achieve a “balance” of fidelity versus file size the way lossy formats do. (Lossy formats mostly prioritize for discarding things that the human ear isn’t likely to hear like frequencies above or below the range of human hearing.) There’s only so much a compression algorithm can do to reduce file size within those constraints. And honestly, FLAC is really good at compressing efficiently within those constraints.
Now, all that said, I think most FLAC encoders offer the option of tuning the tradeoff between compression efficiency and CPU usage when decoding. If you wanted smaller FLAC files, again, the savings aren’t likely to be huge, but you could just up the compression level to 11 and let your CPU do a lot of extra work during playback just to save hard drive space. How to tune that compression-level parameter would depend what software you’re using to do the encoding. FFMPEG, for instance, has a compression level parameter.
I think its 48 khz or something i used
Also i really do not care about file size when it comes to quality for certain things. I just haplen to need an MP4 for my use case and id like to explore the options to do that exactly. I cant overemphasize how insignificant the file sizes are to me, id like to optimize for fidelity above all but in an mp4
Ah. Ok. Well, in that case, I’ve got an idea.
And, being honest here, I’ve learned this in the last few minutes, but apparently MP4 can technically only hold a certain number of different kinds of audio. There are some not-to-spec ways to put things like uncompressed WAV or FLAC into an MP4, but a lot of tools don’t support that.
I just did some tests with FFMPEG and was not able to embed FLAC or WAV (pcm_s16le or pcm_s24le) into an M4A container, but I was able to embed ALAC into an M4A file with the following command:
And mpv is able to play the resulting M4A file just fine.
So, it seems like what you’re going for is doable, at least depending which tool you use. But FFMPEG can do it. Whether your player of choice can play it is another question, but it definitely seems worth a try.
Oh, by the way, the M4A file is a tiny bit larger than the FLAC file:
(Username and computer hostname changed to protect the guilty.)
Lossless formats (flac, wav) will be bigger file sizes comparatively.
Do a test, convert CD/DVD audio to wave and aac, play them both back on the system/speakers that you intend to use, can you notice a difference?
If not, don’t worry about it. If you can, then welcome to the audiophile club.
Personally I prefer lossless because they sound clean and detailed, lossy formats always sound muddy to me, like I’m listening to an album behind a heavy curtain. But I can hear my neighbours ceiling fan motor droning at night…so take that as a hearing acuity rating.
Why .mp4 specifically?
Based on the conversion ratio the mp4s are 220kbps~ which is more than enough to capture all perceptible differences.
The rule of thumb for perceivably perfect bitrates, especially if you don’t have audiophile hardware:
mp3: 256-360kbps
aac(mp4): 128-160kbps
opus: 96-128kbps
If its not mp4, the app doesnt accept it okay?
I put this bit in the body cuz everyone is gonna wanna ask why but i need it to be rocognized as a constraint and simply work within that fence
At risk of being pedantic:
mp4 and m4a are containers. They are the “buckets” audio sits in. You can’t transcode a file to mp4.
flac is the actual compression algorithm that sits in a bucket. Other ‘codecs’ include mp3, aac, alac, opus, and such
To save you a bunch of rambling:
You want to convert the flac audio to opus. Its the most efficient codec. 256K is basically indistinguishable, 384K is literally indistinguishable.
And you want the container to be a .webm file, because everything supports that. To reiterate, opus inside webm.
I need that “container” to be an MP4 because that is the only format that is acceptable to the app i want to use, it needs to be “seen” by my app as an MP4 “video”.
Needs to be mp4, that is a hard constraint. Nonnegotiable
Again, putting on pedantic hat:
…Are you sure it only supports mp4? webm is a video container, too.
MP4, being a container (not a codec), may or may not support various codecs inside it: en.wikipedia.org/wiki/MP4_file_format
Opus was apparently added to the mp4 spec in 2018.
I’m getting what you’re really asking though.
You converted files from flac to “MP4” via some app, but what it actually did is convert them to AAC and just didn’t tell you any of those details.
What you want to do, is convert them all to MP4 that way, but specify the AAC bitrate. I suggest 320K. Or 384K if you are not short on space for the music.
If you want to be super efficient, you can try putting opus inside MP4, or just see if your app will play a webm.
I will definitely try a .webm just to test later but i strongly suspect it wont do it
My procees was taking the flac and importing them into a video editing suite and for the audio quality i chose the hughest which is 48kHz and setting all the videostuff to lowest quality because i only care about the audio
48khz (not K, which means kilobytes/s, kilohertz which is the sampling rate) means you’re resampling. This actually drops the audio quality.
Okay, just download this: github.com/edneyosf/Edconv
(Link to the exe): github.com/edneyosf/…/Edconv-1.4.3-x86_64.exe
Disable video, set your audio stuff and set the file name to end in mp4. Just tested, and it works on a flac file for me.
Thank you, im very uninformed about all of this. Will try later thanks!
if your ‘conversion’ reduced the file size by that much (over 200mb to under 80mb), it likely converted the audio from the source lossless flac to lossy aac.
if you desire lossless, and need the m4a container, use alac (apple lossless, it’s what they use). for broader compatibility outside of apple’s ecosystem, just keep the files as-is, as flac.
It needs to be MP4, m4a is only recognized for seperate added audio tracks but not the main one
For the most part .mp4 / .m4a are interchangeable, you can go lossless --> lossless by going FLAC to ALAC like the earlier comment mentioned e.g. using ffmpeg
In fact, now that umt@lemmynsfw.com mentioned it, you can create a out-of-spec .mp4 with a flac codec inside it if you really wanted. again using ffmpeg
You’d have to test that whatever player you’re using can actually play them, I suspect a lot of players won’t know what to do with a .mp4 containing a FLAC codec unless the player already supports FLAC anyway.
PS - The files actually come out a tad bit bigger FYI, I guess there’s more padding and metadata in a .mp4 container.
You can’t go lossless (FLAC codec) to lossy (codec in M4A/MP4) without losing something.
Not sure which codec specifically you’re referring to in your M4A/MP4 but usually those containers are for lossy codecs and judging by the file size going down you definitely went lossless --> lossy. If the resulting file sounds okay to you then maybe you don’t need/want the lossless file anyway, that’s you’re choice.
Personally I keep everything in the original lossless FLAC, only generate lossy MP4 files when needed for a specific purpose. (but I’d still keep the original FLAC regardless)
Im keeping all the source files intact and archived safely, theres no worry on that point. This is all just experimenting on copies without touching the original files
I just want to test or see if there is a way to preserve losseless in an inherently lossy but necessary spec
Haha this thread is full of folks explicitly ignoring what you said.
ffmpegshould be able to do this, since FLAC is one of the supported audio formats (although only since ISO/IEC 14496-14:2018 so your player might not support it). Read the manpage and do some trial and error.Try:
ffmpeg -i audio.flac -c:a copy output.mp4
ffmpeg can do that. It's a command-line utility that can do a ton of media format conversions. Idk what OS you're on, but you'll have to download ffmpeg, extract it, then use the ffmpeg executable file.
for Windows file paths it would be something like:
cd path\to\album\folderC:\path\to\ffmpeg.exe -i song.flac -map 0:a -c:a copy song.mp4to shove a flac file into an mp4 container as is.
If, for whatever reason, the program you're trying to use, still doesn't like the flac format in the mp4 container, you can convert it to a 320kbps mp3 like:
C:\path\to\ffmpeg.exe -i song.flac -map 0:a -c:a libmp3lame -b:a 320k song.mp4(320kbps mp3 would probably have the least loss in perceptual quality from FLAC, while still having a wide range of compatibility)
(Also, the -map 0:a term makes sure that ffmpeg only tries to convert the audio stream. If you've got album art embedded in the FLAC file, it'll get upset trying to convert the album art to a h.264 without the map argument)
As for converting the whole album at once, if you're on Windows, idk how to do that. You'd have to look up how to use ForEach in powershell or something like that.
Anyone reading this on a Unix-like in bash would be able to run it in a loop in the album folder like:
for file in *.flac; do; ffmpeg -i "$file" -map 0:a -c:a libmp3lame -b:a 320k "${file%.*}.mp4"; done