Adding a cue file to an MP3 multitrack demo

I have created a number of wav files from Ardour that the form the tracks of a new album. I am able to concatenate them using sox or other tools and I also have a cue or toc file with the correct time codes. If I want to send this single file out to the artists and promotors for album review before pressing, in flac and mp3 form, how can I embed the cue file?

I want the listeners to be able to press track skip forwards and backwards and for the track names to be reflected on the display of their players. Can I do this by just sending them a single flac or mp3 file?

I usually just use lame and then kid3-cli to generate mp3 files for promotional and review copies. But lame does not accept cue files as far as I can see.

I’d prefer a solution that runs from the linux command line or under control of a makefile.

Many thanks for any pointers.

I don’t think the MP3 container can use cue files but the MKV container can, if you convert the cue to chapter format.
Save this script below as ConvertCueToChap.sh and run
bash ./ConvertCueToChap.sh your-cue-file > Chapters.txt

Pre=0
Nr=0
Chap=1
grep -A4 TRACK $1 |  egrep "TITLE|INDEX 00" | while read Line
do
 echo $Line | grep -q TITLE && Tit=`echo $Line | cut -d\" -f2`
 echo $Line | grep -q INDEX && Idx=`echo $Line | awk '{print $3}'| cut -d\: -f1,2`
 let Nr+=1
 test $Chap -ge 10 && Pre=""
 if [ $Nr -eq 2 ]; then
  echo "CHAPTER$Pre$Chap=00:${Idx},000"
  echo "CHAPTER$Pre${Chap}NAME=$Tit"  
  Nr=0
  let Chap+=1
 fi
done

Then run
mkvmerge --chapters Chapter.txt -o Filename.mkv your-file.mp3

Note: it only works for files shorter than one hour. I didn’t include any logic for longer files.
And it truncates the milliseconds.

I’m not sure if the track names are showing in any given media player.
A workaround is to add video and show the names as a subtitle.

Use an image to create a video track that’s the same length as your audio
ffmpeg -loop 1 -i <nice-looking-image> -vcodec libx264 -crf 35 -pix_fmt yuv420p -t <audio-length-in-seconds> -preset veryfast -s 480:360 video.mp4

Save the script below to SubFromCue.sh and run
bash SubFromCue.sh your-cue-file > Sub.srt

Pre=0
Third=0
Nr=0
grep -A4 TRACK $1 |  egrep "TITLE|INDEX 00|INDEX 01" | while read Line
do
 echo $Line | grep -q TITLE && Tit=`echo $Line | cut -d\" -f2`
 echo $Line | grep -q "INDEX 00" && IdxB=`echo $Line | awk '{print $3}'| cut -d\: -f1,2`
 # The first title isn't shown if it starts at 00:00:00
 test "$IdxB" = "00:00" && IdxB="00:01"
 echo $Line | grep -q "INDEX 01" && IdxE=`echo $Line | awk '{print $3}'| cut -d\: -f1,2` 

 let Third+=1
 if [ $Third -eq 3 ]; then
  echo $Nr 
  echo "00:${IdxB},000 --> 00:${IdxE},000"
  echo "$Tit" 
  echo "" 
  Third=0
  let Nr+=1  
 fi
done

Merge the files
mkvmerge --chapters Chapter.txt -o Outfile.mkv video.mp4 -y 0:0 your-audio.mp3 -y 0:0 Sub.srt

To get the precision needed to seek the video you should add -g 10 to the ffmpeg command.

And change
echo "00:${IdxB},000 --> 00:${IdxE},000"
to
echo "00:${IdxB},600 --> 00:${IdxE},000"
in SubFromCue.sh

I was not aware of this until I researched your question, but FLAC does support cuesheet:
FLAC cuesheet metadata spec

Note that the cuesheet is actually embedded in the FLAC file metadata, you would not need to send a separate cuesheet.

I do not think MP3 files support embedding a cue file, but you could send it separately along with the MP3 file. Then the question would be how many players support using a cue file along with a large MP3 file. I know some software players do, but I don’t know how widespread it is, or whether it is commonly supported on phones and hardware players.

Thanks very much for the advice.

The video solution is attractive and I have it mostly working. It plays nicely with the expected captions on the local machine under mplayer.

On a web server, I’ve tried embedding the resulting mkv file using the

For the embedding I am using

<video controls> <source src=“media/blah.mkv” type=“video/x-matroska”> Your browser does not support the video element. </video>

I find that the video element is not working in either browser. It renders a frame and control buttons but no duration or initial still frame is shown: its as though there is no media file linked.

Clicking on the anchor alternative, I find that firefox says ‘open with Videos’ and I say yes and then it works nicely. For chrome it opens and plays without any dialog and plays audio fine, but there are no captions from the Chapter or subtitle file being displayed. I get the same behaviour if I open a file:// url in the browser.
If I remove the type field from the video element then chrome plays the content but no captions shown and firefox displays a frown and a caption about unsupported file formats.

It seems that .mkv is becoming unsupported in recent browsers or HTML 5 ?

I can fix this all by just making a webm or mp4 video with captions using the tools I know well. Maybe that is best afterall?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.