Page 3 of 3

Re: Labels to id3v2 mp3 chapters spec

Posted: Mon May 27, 2019 2:57 pm
by vxm
Image
Audacity labels run through the Nyquist command, and then FFmpeg in terminal. Result opening in Podcast Chapters.app - shows that labels can become chapters.
Image

Audacity labels run through the Nyquist command, and then FFmpeg in terminal. Result opening in Forecast.app - shows that labels can become chapters.

That is, using the command

Code: Select all

./ffmpeg -i /Users/vmarks/Downloads/ai\ pod\ mono.mp3 -i /Users/vmarks/Downloads/metadata\ audacity.txt -map_metadata 1 -codec copy -id3v2_version 3 -write_id3v1 1 /Users/vmarks/Downloads/audacitytest.mp3
This works in that it shows chapters created from labels show up as chapters in two out of three alternative tools for creating chapters.

It is *not* recognized by the audio editor Fission.app, which has slightly different header information in the metadata file it creates with FFmpeg:

Code: Select all

;FFMETADATA1
encoded_by=Fission
TLEN=3624228
encoder=Lavf58.27.103
[CHAPTER]
TIMEBASE=1/1000
START=0
END=10997
title=ch0
[CHAPTER]
TIMEBASE=1/1000
START=10997
END=73848
title=Intro
Notably, they insert a line TLEN=

And there's some differences in how Podcast Chapters creates it - which is recognized as chapters in Fission.

Code: Select all

;FFMETADATA1
title=ai pod mono.mp3
Length=3624202
encoded_by=Podcast Chapters
date=2019
encoder=Lavf58.27.103
which is recognized as chapters in Fission.

The Nyquist code

Code: Select all

;FFMETADATA1
title=
encoded_by=
artist=
date=2019
encoder=Lavf58.27.103
Lacks the "length" or "TLEN" and is not recognized as chapters. I wonder if that's needed for this to work? Can we add the total length to that header to try?

When I play files with it in Quicktime Player, it respects chapters. When I play files with chapters, but without that in the header, it doesn't respect them as chapters (next and previous chapter are grayed out.)

This is so close. Also, I don't know why I can run the Nyquist command, but cannot run it as a plugin.

Re: Labels to id3v2 mp3 chapters spec

Posted: Mon May 27, 2019 9:23 pm
by steve
vxm wrote:
Mon May 27, 2019 2:57 pm
Lacks the "length" or "TLEN" and is not recognized as chapters. I wonder if that's needed for this to work? Can we add the total length to that header to try?
Try adding it manually to the "metadata.txt" and see if it works. If it does, then the plug-in could be easily modified to do that.
vxm wrote:
Mon May 27, 2019 2:57 pm
I don't know why I can run the Nyquist command, but cannot run it as a plugin.
What's happening? Have you managed to install it and enable it?

Re: Labels to id3v2 mp3 chapters spec

Posted: Thu Jun 20, 2019 8:18 pm
by vxm
When I attempt to install the Nyquist plugin, the error message is "Error: labelstochapters.ny is not a supported plug-in."

Re: Labels to id3v2 mp3 chapters spec

Posted: Thu Jun 20, 2019 9:59 pm
by steve
vxm wrote:
Thu Jun 20, 2019 8:18 pm
When I attempt to install the Nyquist plugin, the error message is "Error: labelstochapters.ny is not a supported plug-in."
Please attach that file to your reply so I can see what's wrong with it.

Re: Labels to id3v2 mp3 chapters spec

Posted: Fri Jul 26, 2019 1:14 pm
by vxm

Code: Select all

;version 4
;type tool
;codetype lisp
;name "Labels to Chapters"
;author "Steve Daulton"
;release 2.3.2
;copyright "Released under terms of the GNU General Public License version 2"

;control timebase "Time base" int "" 1000 100 2000
;control title "Title" string "" ""
;control encodedby "Encoded by" string "" ""
;control artist "Artist" string "" ""
;control date "Date" string "" "2019"
;control filename "Save file as" file "" "*default*/metadata.txt" "Text file|*.txt;*.TXT|All files|*.*;*" "save,overwrite"


(setf metadata
  (format nil ";FFMETADATA1~%~
              title=~a~%~
              encoded_by=~a~%~
              artist=~a~%~
              date=~a~%~
              encoder=Lavf58.27.103~%"
              title
              encodedby
              artist
              date))

;;  Get label data from first label track
(setf labels (second (first (aud-get-info "Labels"))))


(dolist (label labels)
  (setf chapter
    (format nil "[CHAPTER]~%~
                TIMEBASE=1/~a~%~
                START=~a~%~
                END=~a~%~
                title=~a~%"
                timebase
                (round (* timebase (first label)))
                (round (* timebase (second label)))
                (third label)))
  (string-append metadata chapter))


(setf fp (open filename :direction :output))
(format fp metadata)
(close fp)
(format nil "File written to~%~a" filename)
Is the contents of the file labelstochapters.ny -
when I try and install it, I get "Error. "labelstochapters.ny" is not a supported plug-in." I've attached it and a second attempt that also didn't work, so you can see where I'm running into trouble there.

After this, I'd like to figure out the custom ffmpeg export so I don't have to keep using terminal - this is getting very good.

Re: Labels to id3v2 mp3 chapters spec

Posted: Sat Jul 27, 2019 6:47 pm
by steve
Ah ha, it's missing the first required plug-in header line.

Add this as the first line in the file:

Code: Select all

;nyquist plug-in

Re: Labels to id3v2 mp3 chapters spec

Posted: Fri Aug 02, 2019 11:30 am
by vxm
That fixed the plug-in installer! Thank you.

My current steps are:
  • Run the labels to chapters plug-in.
    Export the audio to mp3.
    in terminal, run

    Code: Select all

    ./ffmpeg -i /Users/vmarks/Downloads/ai\ pod/ai\ pod\ destri.mp3 -i /Users/vmarks/Downloads/ai\ pod/metadata.txt -map_metadata 1 -codec copy -id3v2_version 3 -write_id3v1 1 /Users/vmarks/Downloads/ai\ pod/out.mp3
    
I'm trying to figure out if I can get this all into Audacity, to automate saving the audio and metadata and prompting me for where to save the output file with chapters.

But even if I can't get there, this has gotten me so much further. Thank you!

Re: Labels to id3v2 mp3 chapters spec

Posted: Fri Aug 02, 2019 12:08 pm
by steve
You could perhaps write a Python script to send commands to Audacity to:
1) Run the labels to chapters plug-in.
2) Export the audio as MP3

and then:
3) Sleep long enough for the export to complete
4) Run the FFmpeg command.