Welcome Guest, please login or register.

AudioBook Bay Forum » Help » How-to Guides » File (chapter) ordering and tagging

Pages: [1]   Go Down
  Print  
Author Topic: File (chapter) ordering and tagging  (Read 1612 times)
Gweilo
Global Moderator
Legendary Member
******
Online Online

Posts: 6997



View Profile
« on: June 17, 2019, 06:42:46 AM »

Some uploads have file names like:

part-1.mp3
part-2.mp3
...
part-10.mp3

This can cause problems with some players, which just order the files alphabetically,
These will play them: chapter-1, chapter-10, chapter-11... chapter-19, chapter-2 chapter-20...

When naming files, you should always use the same number of digits for filenames in a set–-if there are more than 9 chapters, start with -01, -02. Then the alphabetic order will be the correct numeric one.

But also, set the track numbers in the ID3 file tags embedded in the files.
Many players will follow those primarily, and if there are no track tags, they will either not see the files as different, or maybe play them alphabetically, or at random, or not at all. iTunes is particularly fussy about this.


Using MP3tag in Windows

You can fix all these problems using MP3Tag, which shows all the names and tags for a folder of files, and you can change filenames and tags en masse and make them consistent. Though it doesn't take long to individually set each of the first nine files.
MP3Tag can edit tags in both MP3 and M4A files.

To set track numbers: load the folder of files in the book. Get them listed in the correct order. You might rename some files to do that, you can just click on the name in Mp3tag and edit it. Then select all the files and use Tools/autonumbering and they will be numbered in sequence.

You can rename the files from the tags using the "Convert" tools: "Tag -> Filename".
You can also do the inverse: "Filename -> Tag" if it's useful.
The book's title goes in the "Album" tag. Use the "Title" for the chapter name. If just numbers, you can select and set them as "Chapter %track%". Players like "Smart" on Android can display the tag info.

If you have files before Chapter 1, select just the actual chapter files, temporarily use renumbering to set the tracks numbering from 1, then you can use "Tag -> Tag" to construct the "title" tag. Select all the files, use autonumbering again to set the tracks starting from 1. Don't leave any files without track tags, or have duplicate track numbers in the same book.

If you have a list of chapter names, e.g. copied from the ebook, you can put them into a text file, one per line, and insert them into all the files "title" tags at once using "Convert/Text file -> Tag".

I then often make the filenames "Track number-Chapter name" using "Tag -> filename" and code "%track%-%title%", which is good for those players which do not display the tags.
« Last Edit: July 06, 2024, 10:10:53 PM by Gweilo » Logged
neyseyer
Full Member
***
Offline Offline

Posts: 57



View Profile
« Reply #1 on: July 06, 2024, 05:29:25 PM »

Windows, Mac?
This guide is for Linux. These methods can work can also work with WSL (Windows Subsystem for Linux), and some are crossplatform. Maybe can also work on Macs, I have not tried it.

File Chapter Ordering & Metadata [Linux]

Use case:

Happy leech new audiobook. Your audiobook player import files after, there is a mess! All files are "Chapter 1"? What is going on?? Clearly, the files are named 1,2,3...
Why does the audiobook player not know this? File metadata is set incorrectly.
Or other cases, incorrect audiobook title, audiobook artist is "Unknown", incorrect chapter title,... All these are due to wrong metadata. 5 min can fix.

#1 Kid3:
https://kid3.kde.org/ Want GUI, no want black box? This is for you.
Why use it?
  • Like GUI
  • Modern graphics
  • No need guide
Why not use it?
  • Need kde
  • Not like GUI
  • Cannot automate

#2 How: eyeD3:

Why use it?
  • Ease of use
  • Many files same time
  • Instant
Why not use it?
  • No gui
  • Python

First need install: python. Recommend use pipx. https://github.com/nicfit/eyeD3
Code:
pipx eyeD3

Install after can check file info:
Code:
eyeD3 track5.mp3
Here is example of bad metadata, track 5, https://audiobookbay.lu/abss/then-road-less-traveled-and-beyond-m-scott-peck/ :
Code:
Time: 47:06    MPEG1, Layer III
[ ~95 kb/s @ 44100 Hz - Joint stereo ]
--------------------------------------
ID3 v2.3:
title: Track 1
artist:
album:
track: 1
Title expect "Track 5", get "Track 1". Track expect 5, get 1. This can confuse audiobook player. Want to correct? Easy!
Code:
eyeD3 track5.mp3 --title "Track 5" --track 5
Or short:
Code:
eyeD3 track5.mp3 -t "Track 5" -n 5
Fix!
Now, want to fix many file at once. First, view info all file in album.
Code:
eyeD3 *.mp3
This selects all mp3 file. * is wildcard, *.mp3 is all files with type mp3. Want to view info all file wav?
Code:
eyeD3 *.wav
Example results:
Code:
...NF/The road less travelled and beyond/Track 1.mp3  [ 29.32 MB ]
---------------------------------------
Time: 46:44    MPEG1, Layer III
[ ~87 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 1
artist:
album:
track: 1        
---------------------------------------
...NF/The road less travelled and beyond/Track 2.mp3  [ 30.21 MB ]
---------------------------------------
Time: 46:00    MPEG1, Layer III
[ ~91 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 2
artist:
album:
track: 1        
---------------------------------------
...NF/The road less travelled and beyond/Track 3.mp3  [ 32.89 MB ]
---------------------------------------
Time: 48:19    MPEG1, Layer III
[ ~95 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 2
artist:
album:
track: 1        
---------------------------------------
...NF/The road less travelled and beyond/Track 4.mp3  [ 32.41 MB ]
---------------------------------------
Time: 47:47    MPEG1, Layer III
[ ~94 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 2
artist:
album:
track: 1        
---------------------------------------
...NF/The road less travelled and beyond/Track 5.mp3  [ 32.19 MB ]
---------------------------------------
Time: 47:06    MPEG1, Layer III
[ ~95 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 1
artist:
album:
track: 1        
---------------------------------------
...NF/The road less travelled and beyond/Track 6.mp3  [ 4.45 MB ]
---------------------------------------
Time: 06:31    MPEG1, Layer III
[ ~95 kb/s @ 44100 Hz - Joint stereo ]
---------------------------------------
ID3 v2.3:
title: Track 2
artist:
album:
track: 2
Want all set album, artist?
Code:
eyeD3 *.mp3 --album "The road less travelled and beyond" --artist "M. Scott Peck"

This sets album and artist for all mp3 in current directory.

How: Advanced eyeD3:

Not want manual set title, track? This is a little more work. Not intuitive.
#Bash. Create script file in audiobook directory:
Code:
#!/bin/bash
for x in *.mp3; do
    fn="${x%.mp3}"
    eyeD3 "$x" --title="$fn" --track "${fn//[^0-9]/}"
    echo "$a"
done
This is for mp3. Wav? Change *.mp3 to *.wav. Make script file executable:
Code:
chmod +x
Important: this changes all mp3 in that directory. One directory only have one album. You are in correct directory? Then can execute:
Code:
./name_of_script_file
Finish!

#3 How: id3v2:

Same like eyeD3.

#4 How: ffprobe/ffmpeg

Why use it?
  • Already install, no need install new
  • Many user
Why not use it?
  • Slow, cannot overwrite
  • Syntax difficult
Need install? No. Most machine already is install. Check
Code:
ffmpeg
Your version older than 4.4.0?  Upgrade.
Long guide (external): Read and Write Tags of Music Files with FFmpeg

Short guide:

First, examine metadata. Single file:
Code:
ffprobe -i "Track 4.mp3" -show_format -print_format json
All files in dir (mp3):
Code:
find . -name "*.mp3" -print -exec ffprobe -i "{}" -show_format -print_format json \;
For other format, replace ".mp3" with ".YOURFORMAT". For wav, "*.wav".
Example output:
Code:
Metadata:
      encoder         : LAME3.99
    "format": {
        "filename": "./Track 4.mp3",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mp3",
        "format_long_name": "MP2/3 (MPEG audio layer 2/3)",
        "start_time": "0.025057",
        "duration": "2866.703673",
        "size": "33986519",
        "bit_rate": "94844",
        "probe_score": 51,
        "tags": {
            "title": "Track 2",
            "track": "1"
        }
    }
See filename is not same as tags, title. And tags title is not same as tags, track. It is incorrect.
Want to change?
Code:
ffmpeg -i "Track 4.mp3" -metadata title="Track 4" "Track 4_2.mp3" 
Why put "Track 4_2.mp3"? This is output file. FFmpeg cannot change/overwrite file. Only make copy with correct data. Very slow. But can use.
All metadata tags are listed here: FFmpeg Metadata

#5 Tone
Want to edit many many, many files? tone is very good.  

Why use it?
  • Bulk edit, very fast
  • Linux, windows, mac, all can
  • Support many formats (can m4b!)
  • Beautiful CLI
Why not use it?
  • Expert ware, recommend basic script experience
  • Incomplete guide
  • In development

Incomplete guide. WIP.

First need install:
Windows, mac, follow instructions on github.

Linux, find out your architecture, use uname command.
Quote
uname -m
Example:

This example show architecture linux-x64. If say arm, select file for arm.
After, select right file, follow github instructions.

Install after, want inspect file. First use mp3.  Here is example of bad metadata, track 5, https://audiobookbay.lu/abss/then-road-less-traveled-and-beyond-m-scott-peck/ :
Code:
tone dump "Track 6.mp3"
Result:
Code:

                       properties                       
┌───────────────────┬───────────────────────────────────┐
│            format │ MPEG Audio (Layer III): audio/mp3 │
│           bitrate │ 95                                │
│       sample-rate │ 44100                             │
│          duration │ 00:06:31.262                      │
│               vbr │ True                              │
│          channels │ 2 (Joint Stereo)                  │
│    2 meta formats │ ID3v2.3                           │
│                   │ ID3v1.1                           │
└───────────────────┴───────────────────────────────────┘
           metadata           
┌───────────────────┬─────────┐
│             title │ Track 2 │
│      track-number │ 2       │
└───────────────────┴─────────┘
Track title, track number wrong.  No set artist album for file.
Fix:
Code:
tone tag "Track 6.mp3" --meta-title "Track 6" --meta-track-number 6
Result:
Code:
      DIFF: ...tester/Track 6.mp3       
┌───────────────────────────────────┬───────────────────────┬──────────────────────┐
│ property                          │ current               │ new                  │
├───────────────────────────────────┼───────────────────────┼──────────────────────┤
│ Title                             │ Track 2               │ Track 6              │
│ TrackNumber                       │ 2                     │ 6                    │
└───────────────────────────────────┴───────────────────────┴──────────────────────┘
     Update: ...tester/Track 6.mp3 
The command is long. Want automate, change eyeD3 bash script.
Code:
#!/bin/bash
for x in *.mp3; do
    fn="${x%.mp3}"
    tone tag "$x" --meta-title="$fn" --meta-track-number "${fn//[^0-9]/}"
    echo "$a"
done
Make executable:
Code:
chmod +x tone_script_file
Important: the script change all mp3 file in dir. Use in correct dir!

Execute:
Code:
./tone_script_file
Expert hint: Tone offer option, filename to tag via --path-pattern. If you know script, can optimize like that. Run many folder.

Questions? Ask!
« Last Edit: July 07, 2024, 07:54:18 PM by neyseyer » Logged

neyseyer
Cen no cen? NEY!

Beg reseed!
International Poetry Forum 1966-1991
Pages: [1]   Go Up
  Print  
 
Jump to: