Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Please check FLAC-in-MP4 support on Mac (Read 1671 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Please check FLAC-in-MP4 support on Mac

I'd like to know whether playback of FLAC-in-MP4 is supported in the Safari browser, and possibly in other Mac software. I can check Windows and Linux software, but I do not have access to Mac hardware, therefore this question.

There's a file here: http://audiograaf.nl/misc_stuff/test-FLAC-in-MP4.mp4 Source material has been licensed under Creative Commons Attribution 3.0. (c) copyright 2008, Blender Foundation / www.bigbuckbunny.org. I converted a small chunk with latest ffmpeg git to H264 + FLAC in an MP4 container.

Please let me know whether Safari (or other software) accepts this, whether you can hear audio while playing back and what version you're testing with.
Music: sounds arranged such that they construct feelings.

Re: Please check FLAC-in-MP4 support on Mac

Reply #1
Works on macOS Monterey 12.4, it is supported from the OS, it works always.

Re: Please check FLAC-in-MP4 support on Mac

Reply #2
Could you be a little more specific? If I understand you correctly you say that an OS component does the demuxing and decoding, how do you know? Still, it is useful to know which program used these OS components.
Music: sounds arranged such that they construct feelings.

Re: Please check FLAC-in-MP4 support on Mac

Reply #3
I tried, but if you don't trust my eyes and ears you can query it from the command line.

Webm is supported by the browser, in general for an operating system it is a bad idea, it is better to have the possibility to convert each format into an internal metaformat, this command also allows you to encode to other formats. Also BeOS in the 90's did it this way.

afconvert -hf

Audio file and data formats:
    '3gpp' = 3GP Audio (.3gp)
               data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
                             'aacl' 'aacp' 'samr'
    '3gp2' = 3GPP-2 Audio (.3g2)
               data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
                             'aacl' 'aacp' 'samr'
    'adts' = AAC ADTS (.aac, .adts)
               data_formats: 'aac ' 'aach' 'aacp'
    'ac-3' = AC3 (.ac3)
               data_formats: 'ac-3'
    'AIFC' = AIFC (.aifc, .aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw'
                             'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2'
                             'Qclp' 'agsm'
    'AIFF' = AIFF (.aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32
    'amrf' = AMR (.amr)
               data_formats: 'samr' 'sawb'
    'm4af' = Apple MPEG-4 Audio (.m4a, .m4r)
               data_formats: '.mp1' '.mp2' '.mp3' 'aac ' 'aace' 'aacf'
                             'aacg' 'aach' 'aacl' 'aacp' 'ac-3' 'alac'
                             'ec-3' 'flac' 'paac' 'pac3' 'pec3'
    'm4bf' = Apple MPEG-4 AudioBooks (.m4b)
               data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl'
                             'aacp' 'paac'
    'caff' = CAF (.caf)
               data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp'
                             'Qclq' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
                             'aacl' 'aacp' 'ac-3' 'alac' 'alaw' 'dvi8'
                             'ec-3' 'flac' 'ilbc' 'ima4' I8 BEI16 BEI24
                             BEI32 BEF32 BEF64 LEI16 LEI24 LEI32 LEF32
                             LEF64 'ms\x00\x02' 'ms\x00\x11' 'ms\x001'
                             'opus' 'paac' 'pac3' 'pach' 'pacp' 'pec3'
                             'pusa' 'qaac' 'qac3' 'qach' 'qacp' 'qec3'
                             'qflc' 'qlac' 'qusa' 'samr' 'ulaw' 'usac'
                             'zaac' 'zac3' 'zach' 'zacp' 'zec3' 'zlac'
    'ec-3' = EC3 (.ec3)
               data_formats: 'ec-3'
    'flac' = FLAC (.flac)
               data_formats: 'flac'
    'loas' = LATM/LOAS (.loas, .latm, .xhe)
               data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl'
                             'aacp' 'usac'
    'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
               data_formats: '.mp1'
    'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
               data_formats: '.mp2'
    'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
               data_formats: '.mp3'
    'mp4f' = MPEG-4 Audio (.mp4)
               data_formats: '.mp1' '.mp2' '.mp3' 'aac ' 'aace' 'aacf'
                             'aacg' 'aach' 'aacl' 'aacp' 'ac-3' 'alac'
                             'ec-3' 'flac' LEF32 BEF32 LEF64 BEF64 LEI32
                             BEI32 UI0 UI0 UI0 UI0 'paac' 'pusa' 'qaac'
                             'qac3' 'qec3' 'qflc' 'qlac' 'qusa' 'usac'
    'NeXT' = NeXT/Sun (.snd, .au)
               data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 'ulaw' 'alaw'
    'Sd2f' = Sound Designer II (.sd2)
               data_formats: I8 BEI16 BEI24 BEI32
    'WAVE' = WAVE (.wav)
               data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
                             'alaw'
    'BW64' = WAVE (BW64 for length over 4 GB) (.wav)
               data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
                             'alaw'
    'RF64' = WAVE (RF64 for length over 4 GB) (.wav)
               data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
                             'alaw'
    'W64f' = Wave64 (.w64)
               data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
                             'alaw'


Re: Please check FLAC-in-MP4 support on Mac

Reply #5
p* q* z* are variants, for example pusa it is an usac variant, etc.

Re: Please check FLAC-in-MP4 support on Mac

Reply #6
Thanks for the info, but did you try the file I supplied? That was created with ffmpeg. I see flac is also supported in m4a, that is something ffmpeg isn't able to create. I do hope Apple used the same identifiers as ffmpeg does, otherwise this is going to be an incompatible mess.
Music: sounds arranged such that they construct feelings.

Re: Please check FLAC-in-MP4 support on Mac

Reply #7
Okay, I just found this: https://developer.apple.com/safari/technology-preview/release-notes/ Under release 89 is says
Quote
Fixed support for FLAC-in-MP4

Anyway @celona, thanks for the input. I'll try to get hold of a Mac soon to use this afconvert utility to create a bunch of FLAC-in-MP4, FLAC-in-CAF and FLAC-in-M4A to take a good look at them.
Music: sounds arranged such that they construct feelings.

 

Re: Please check FLAC-in-MP4 support on Mac

Reply #8
Hi there! Thought I'd chime in.

So with regard to .m4a files - in ffmpeg, ".m4a" triggers the "ipod" format, which changes the listed major/compatible brands of the MPEG4 file, and I believe restricts codecs to be iPod/iPad-compatbile. You should be able to create an MP4 and rename it M4A, it'll change the major and compatible brands but otherwise be a valid MP4 file.

Here's some of the output of boxdumper on an m4a. I'm just looking at the file type box, because I'm somewhere around 99% sure that's all that really changes, but I'll admit I haven't combed through every single box.

Code: [Select]
    [ftyp: File Type Box]
        position = 0
        size = 28
        major_brand = M4A  : iTunes MPEG-4 audio protected or not
        minor_version = 512
        compatible_brands
            brand[0] = M4A  : iTunes MPEG-4 audio protected or not
            brand[1] = isom : ISO Base Media file format version 1
            brand[2] = iso2 : ISO Base Media file format version 2

Whereas here's a normal MP4:

Code: [Select]
    [ftyp: File Type Box]
        position = 0
        size = 28
        major_brand = isom : ISO Base Media file format version 1
        minor_version = 512
        compatible_brands
            brand[0] = isom : ISO Base Media file format version 1
            brand[1] = iso2 : ISO Base Media file format version 2
            brand[2] = mp41 : MP4 version 1

Also, I did some testing with Safari and that FLAC-in-MP4 file. I figure what you're mostly interested in is working with HTML video + audio elements? Just clicking the link played the video + audio, but I figure that may not be quite the same as using HTML5 video + audio elements.

I made a quick webpage:

Code: [Select]
<html>
<head><title>FLAC-in-MP4</title></head>
<body>
<video controls><source src="test-FLAC-in-MP4.mp4"></video>
</body>
</html>

Served it up using good ol "python -m SimpleHTTPServer", opened the page in Safari - video played, audio played.

Then I converted it to an m4a file using ffmpeg, using "-f mp4" to override that "ipod" format:

Code: [Select]
fmpeg -i test-FLAC-in-MP4.mp4 -c:a copy -vn -strict -2 -f mp4 -movflags +faststart test-FLAC-in-MP4.m4a

(I also tried it without the "-movflags +faststart" flags to be thorough, though in most real-world scenarios you'd want to use that).

Similar concept - made a simple audio page:

Code: [Select]
<html>
<head><title>FLAC-in-M4A</title></head>
<body>
<audio controls><source src="test-FLAC-in-MP4.m4a"></video>
</body>
</html>

Served it the same way as video, and it played without issue.

I've also done some testing with using hls.js to stream FLAC in a fragmented mp4 stream. I had to modify hls.js (I have a PR open here: https://github.com/video-dev/hls.js/pull/4772) - that worked in Safari as well.

I also tested your MP4 using Quicktime Player, the default video player - FLAC audio played back fine.

All working in Version 15.5 (16613.2.7.1.9, 16613), which corresponds to macOS 11.6.6 (Big Sur) - I'm behind by a major release, still.