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: AAC Gapless playback information (Read 8016 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

AAC Gapless playback information

My current workflow for processing music goes as follows:

1. Buy a CD
2. Rip the CD using DBPowerAmp onto my linux server
3. Use beets (beets.io) to tag the files, add cover art, lyrics, etc and then copy the file over.
4. Use beets to convert the FLAC files to AAC and place them in my listening folder.

I recently purchased an iPod (yeah, yeah, I know it's not 2005) and have been enjoying the heck out of it.

I synced my entire library over to the iPod, and even though the iPod and AAC both support gapless playback, the iPod is playing albums with gaps.

So, I did some homework, and discovered that the iPod requires gapless playback tags.

beets is using the following command line on linux to convert the files from FLAC to AAC:

ffmpeg -i $source -vn -map 0:0 -c:a libfdk_aac -vbr 5 $dest

This converts the files and copies over all ID3 tags, but it doesn't create gapless playback information.

I found out that the tool fdkaac will write gapless playback information using the command line option --gapless-playback with three different options: the iTunes standard, the ISO standard or both.

But fdkaac won't just write the tags to the file. It needs to encode.

I used the example in the wiki to encode a FLAC file to AAC using the fdkaac command line. The file converted to AAC, and had the proper gapless playback tags, but had no other metadata. fdkaac takes either a WAV file or a PCM stream and converts them to AAC.

Since I have already converted 30K+ tracks to AAC, I would prefer to find a tool that will rip through my library and automagically add all the gapless playback tags. I was hoping the fdkaac would let me do it, but it will not just write tags. And I can't find any command line switches that will allow ffmpeg to do it.

So I'm looking for a way either to:

1. Take my existing files and add iTunes gapless playback tags to them, both AAC and MP3
2. Find a command line that will convert FLAC to AAC, add iTunes gapless playback information, and copy over all the tags and album art.

The only option I can think of that might work now is to transcode all the FLAC files to Apple Lossless. I can then dump them into iTunes and tell iTunes to transcode to AAC on the fly as it syncs. But, if I do that, a 30K+ library will probably take DAYS to sync over.

Re: AAC Gapless playback information

Reply #1
Have you tried foobar2000 for iOS? It has support for gapless playback so it could be simpler solution.
lame --abr 288 -f --lowpass 17 (+ mp3gain@92 dB)

Re: AAC Gapless playback information

Reply #2
Don't forget their is a iPod plugin for Foobar2000 that sorts out the gapless data when you transfer your music.

https://yuo.be/ipod-manager

Who are you and how did you get in here ?
I'm a locksmith, I'm a locksmith.

Re: AAC Gapless playback information

Reply #3
Is it really possible to fix these files after they've been encoded?? I really am clueless but I'd never imagine it being possible and I'd just re-encode.

Since you use DBpoweramp, why not use that? I'm sure it writes everything correctly. Failing that, I'd be using QAAC.

Re: AAC Gapless playback information

Reply #4
Is it really possible to fix these files after they've been encoded?? I really am clueless but I'd never imagine it being possible and I'd just re-encode.

Since you use DBpoweramp, why not use that? I'm sure it writes everything correctly. Failing that, I'd be using QAAC.

I could do that, but it would be a lot of work. One of the nice things about beets is that you point it to a directory and it will convert only the lossless files, and copy over the lossy ones.

As a test, I used dBPowerAmp to convert Dark Side of the Moon from FLAC to AAC. Synced it to the iPod.  When I let track 1 finish, before track 2 plays, the iPod reboots.


Re: AAC Gapless playback information

Reply #6
Have you tried foobar2000 for iOS? It has support for gapless playback so it could be simpler solution.

This is an old clickwheel iPod. It doesn't run iOS.


Re: AAC Gapless playback information

Reply #8
I thought one of the main features of DBpoweramp was mass converting large batches of files with minimal effort. If you have a lossless collection ready to go, it should be easy??

The collection is a mix of lossless and lossy files.  They include CD rips, FLAC and MP3 purchases from 7digital and Amazon.

In a perfect world, the tool would convert the lossless files, and just copy over the lossy files to the destination, which is what beets does. Beets just doesn't write the gapless information.

Re: AAC Gapless playback information

Reply #9
oops...

Apple.
EZ CD Audio Converter / FLAC or WavPack

 

Re: AAC Gapless playback information

Reply #10
I use fdkaac when I convert from FLAC.  i use the options -G2 and --tag pgap:1 when encoding.  Hopefully an audio player will use one of the 3 methods.  The tag pgap:1 creates a tag called "Gapless Playback" with a value of 1.  I'm sure it can be manually added.  I'm not sure if the classic ipod will honor that tag.  I have a couple classic ipods, but I haven't touched them in years. 

Re: AAC Gapless playback information

Reply #11
I use fdkaac when I convert from FLAC.  i use the options -G2 and --tag pgap:1 when encoding.  Hopefully an audio player will use one of the 3 methods.  The tag pgap:1 creates a tag called "Gapless Playback" with a value of 1.  I'm sure it can be manually added.  I'm not sure if the classic ipod will honor that tag.  I have a couple classic ipods, but I haven't touched them in years. 

Can you post the exact command line you're using?  I'd like to try it out.



Re: AAC Gapless playback information

Reply #14
I just tried this, and it strips all the metadata from the m4a file.

Yes, the command I gave was simply to generate an m4a file from flac with only gapless information included. 
I'm confused, your first post says your on Linux, your 3rd says your on a Mac?

You could try this command.  It only carries over basic tags from the flac file without cover art, but will add all of the gapless atoms: iTunSMPB, edts + sgpd, and pgap.
Code: [Select]
ffmpeg -i filename.flac -f caf - | fdkaac -S -p2 -m5 -a1 -f0 -G2 --moov-before-mdat --tag pgap:1 - -o "filename.m4a"

Another option to write tags to existing files is to use AtomicParsley.  This will write the "Gapless Playback" tag to every file in the directory, but it will not add the specific iTunSMPB tag that fdkaac adds each file.
Code: [Select]
for file in *; do AtomicParsley "$file" --overWrite --gapless "1"; done

I'm not familiar with beets.io.  Maybe there is a way to modify the command it uses to encode files?
https://beets.readthedocs.io/en/stable/plugins/convert.html

Re: AAC Gapless playback information

Reply #15
I just tried this, and it strips all the metadata from the m4a file.

Yes, the command I gave was simply to generate an m4a file from flac with only gapless information included. 
I'm confused, your first post says your on Linux, your 3rd says your on a Mac?

You could try this command.  It only carries over basic tags from the flac file without cover art, but will add all of the gapless atoms: iTunSMPB, edts + sgpd, and pgap.
Code: [Select]
ffmpeg -i filename.flac -f caf - | fdkaac -S -p2 -m5 -a1 -f0 -G2 --moov-before-mdat --tag pgap:1 - -o "filename.m4a"

Another option to write tags to existing files is to use AtomicParsley.  This will write the "Gapless Playback" tag to every file in the directory, but it will not add the specific iTunSMPB tag that fdkaac adds each file.
Code: [Select]
for file in *; do AtomicParsley "$file" --overWrite --gapless "1"; done

I'm not familiar with beets.io.  Maybe there is a way to modify the command it uses to encode files?
https://beets.readthedocs.io/en/stable/plugins/convert.html

I have a little bit of everything in the house. My main computer is Linux, but I also have a Mac.

Re: AAC Gapless playback information

Reply #16
I did more experimenting this afternoon.

I wrote a small script to do conversion:

Code: [Select]
#!/bin/bash

ffmpeg -i "$1" -f wav - | fdkaac -I -m 5 -G 0 - -o "$2"

This was supposed to write the iTunSMPB atom to the file. I used this script, and took the resulting m4a file and confirmed that the iTunSMPB atom is there using FooBar2000 properties.

I synced that file to the iPod, and I DID NOT get gapless playback.

So, I changed the -G 0 to a -G 2, which is supposed to write both iTunSMPB Atoms and ISO standard (edts + sgpd).

I synced this album over to the iPod, and playing these tracks caused the iPod to reboot.

The one thing that DOES work, is to use the Mac application xld to convert the FLACs to AAC.  They work, and they play gapless. But, I have 33,000+ songs, and I don't think XLD does batch processing.

Re: AAC Gapless playback information

Reply #17
No idea why anyone would touch ffmpeg/fdkaac when you're on a mac and the target device is an ipod. Surely using the built in** apple codecs is the way to go?? I'd have to assume that's what XLD is doing? And according to this...

https://wiki.hydrogenaud.io/index.php?title=XLD_Configuration#.22Batch.22_tab

there is a batch section in the preferences.

** huge assumption on my part about this. I really have no idea.  :))




Re: AAC Gapless playback information

Reply #18
No idea why anyone would touch ffmpeg/fdkaac when you're on a mac and the target device is an ipod. Surely using the built in** apple codecs is the way to go?? I'd have to assume that's what XLD is doing? And according to this...

https://wiki.hydrogenaud.io/index.php?title=XLD_Configuration#.22Batch.22_tab

there is a batch section in the preferences.

** huge assumption on my part about this. I really have no idea.  :))




Ok, here is the full explanation

I have a Linux server at my house. I installed a bunch of drives on that, and I use the python 3 app, beets, to tag and organize my music. I did this because then I can rip CDs on any computer in the house and the get dumped to the server. I ssh into the server and then do the import.  Beets will download cover art, add lyrics from the Internet, apply ReplayGain tags, etc.

At some point in the 2000s, I stopped buying CDs and began to do online music purchases. I did this when iTunes finally went DRM free. But I switched back to CDs in the 2010s, so my music library is a collection of CD rips, AAC purchases from Apple and MP3 purchases from Amazon.

Beets will convert to lossy, maintain all tags and artwork, and copy over lossy files rather than convert them. So, I can tell beets what my music library folder is, and it will convert the FLACs, and just copy over the MP3 and AAC files, making a whole directory tree of lossy music.

But, ffmpeg and cannot create the gapless tags needed by the iPod. Which kind of makes sense, because it's just a command line tool that treats every file individually.

I played with afconvert last night, a command line tool Apple provides, and it will write Apple gapless tags, but you need to know which tracks need them, and to tag manually for the files that need them with command line switches.

It looks like I can only do this on my Mac in one of two ways:

1. Use iTunes to convert the files. To do this, I would need to convert all the files to ALAC, and then use iTunes or Apple Music to convert them to AAC.
2. Use XLD to do this. That will convert FLAC to AAC

XLD batch mode seems to convert everything in a directory and all subdirectories to the format of your choice.  Since I have AAC and MP3 files, I'll need to write a script to pull those out of my directory structure, and then do a batch convert.

Re: AAC Gapless playback information

Reply #19
Probably not worth it, but just throwing out the idea:
Like "image + cue", one MP4 file per album - with MP4 chapters?

Re: AAC Gapless playback information

Reply #20
Ok, here is the full explanation

I was not focusing on what beets can do better than other tools for converting/copying depending on whether the source was lossless or not. Sounds cool but I don't really care about it. I know you do but look at your own thread title and the issues you've repeatedly had by these files causing your ipod to reboot itself. I thought the conversion of FLAC to proper lossy m4a with gapless support that you can play on your ipod was the main point of this thread. How you manage your existing lossy collection is entirely up to you.

Personally, I keep my files organised in folders by codec. This is irrelevant when it comes to browsing my music in <any player> because they all use the metadata. I'm huge nerd for foobar2000 on windows but I use gonemad on android which obviously has zero issues with my folder structure because I browse by the basic album artist/album tags. I can see all albums for a given artist transparently regardless if they're lossless/lossy and they live in completely different folders - it just doesn't matter.

I don't transcode anything these days but if I did, I can easily point <any tool> at my FLAC folder and leave my original mp3/m4a files alone. Maybe this is something to consider?? I believe foobar2000 for mac has file operations like the windows version and you could probably move files to new folders based on their tech info.

https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference#.24info.28name.29

edit: just went back and looked that XLD preferences thing and you can restrict it to certain file types. That sounds ideal. Just point it at your base folder and let it run through your flac files. Then use beets or whatever to copy your lossy files without touching the lossless. Surely that's possible?


Re: AAC Gapless playback information

Reply #21
One of things I really want out of music player is to display artists by their name, but sort them by AlbumArtistSort.  That way a group like The Rolling Stones shows up under R and Billy Joel shows up under J. This is the way most record stores organize their, and it's how I have been organizing my music since I first started buying records in the 1980s.

The only apps that seem to do this is MusicBee and iTunes. I tried to do it in FooBar2000, but I if I wanted to sort by AlbumArtistsSort, I needed to display by AlbumArtist.

Re: AAC Gapless playback information

Reply #22
OK, I have a solution.  I can modify beets to import music and sort it by filetype, so I can get a structure like this:

Code: [Select]
music
|
|-flac
   |
   |-artists
      |
      |-album
|-mp3
   |
   |-artist
      |
      |-album

Then I can use XLD on my Mac to convert the FLAC folder to AAC and dump those AAC files into iTunes.

Re: AAC Gapless playback information

Reply #23
foobar2000 can do so, but you have to configure a column for it.

Also beware that more recent versions have an annoying remapping to %albumartistsortorder% - for lossies, but not for Vorbis comments.

Re: AAC Gapless playback information

Reply #24
foobar2000 can do so, but you have to configure a column for it.

Also beware that more recent versions have an annoying remapping to %albumartistsortorder% - for lossies, but not for Vorbis comments.

Since I am on a Mac, Foobar2000 is far more limited than it is on Windows.

Right now, I added the $format variable to my path and am using the beet move command to reorganize my library. When all is said and done, I should have top level directories for FLAC. MP3 and AAC.

This will be very convenient, because I can now see which MP3s I have and create a list of CDs I need to try to find. I'm perfectly aware I can't hear a difference, but for archival purposes, I prefer having lossless music. It gives me the freedom to convert to any format.