pacpl can't handle double-quote characters in title tags

Bug #533111 reported by Robin Munn
28
This bug affects 6 people
Affects Status Importance Assigned to Milestone
pacpl (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: pacpl

While using pacpl to convert a batch of .flac files to .m4a, I noticed it failing on a randomly-selected set of music files. Closer examination revealed that they were all classical music pieces whose tags I had gotten from MusicBrainz, and that the files that were failing were the pieces whose title contained double-quotes with a space character inside them. For example, the Mozart album at http://musicbrainz.org/release/45179fbc-62c0-4992-9511-c61310dc0f9f.html (title too long to copy here) has the following track titles:

...
Track 7: Mass No. 15 for Soloists, Chorus & Orchestra in C major, K. 317 "Coronation Mass": VI. "Agnus Dei"
Track 8: Missa solemnis No. 16 for Soloists, Chorus & Orchestra in C major, K. 337: I. "Kyrie"
...

After much poking at the problem, I have figured out what is happening. After decompressing the .flac files to .wav, pacpl is calling the following commands to encode the M4A files:

For track 7:

faac --title "Mass No. 15 for Soloists, Chorus & Orchestra in C major, K. 317 "Coronation Mass": VI. "Agnus Dei"" --track "7" --artist "Wolfgang Amadeus Mozart" --album "Masses: Mass in C minor K. 427, Coronation Mass in C major K. 317, Missa Solemnis in C major K. 337, Kyrie in D minor K. 341 (Kölner Kammerchor & Collegium Cartusianum feat. conductor: Peter Neumann)" --comment "" --year "1990-01-01" --genre "Classical" -w -q 100 "/home/rmunn/tmp/music/classical/Masses/02.07.19776.wav" -o "/home/rmunn/tmp/music/classical/Masses/02.07.m4a"

For track 8:

faac --title "Missa solemnis No. 16 for Soloists, Chorus & Orchestra in C major, K. 337: I. "Kyrie"" --track "8" --artist "Wolfgang Amadeus Mozart" --album "Masses: Mass in C minor K. 427, Coronation Mass in C major K. 317, Missa Solemnis in C major K. 337, Kyrie in D minor K. 341 (Kölner Kammerchor & Collegium Cartusianum feat. conductor: Peter Neumann)" --comment "" --year "1990-01-01" --genre "Classical" -w -q 100 "/home/rmunn/tmp/music/classical/Masses/02.08.19813.wav" -o "/home/rmunn/tmp/music/classical/Masses/02.08.m4a"

Track 8 works, but track 7 fails with the error message "Cannot encode several input files to one output file."

Because the double-quotes in the title string aren't quoted or backslash-escaped, the shell sees them as the end of the title string. If the double-quote characters contain just a single word (as in track 8, where it's the word "Kyrie") then this doesn't matter, as the shell still sees that whole title (from "Missa solemnis" to the word "Kyrie") as a single string. But in track 7, the parameter "Mass No. 15 for Soloists, Chorus & Orchestra in C major, K. 317 "Coronation Mass": VI. "Agnus Dei"" gets interpreted by the string as:

First parameter: "Mass No. 15 for Soloists, Chorus & Orchestra in C major, K. 317 "Coronation
Second parameter: Mass": VI. "Agnus
Third parameter: Dei""

And thus, faac thinks it's being asked to encode several input files (one file called Mass": VI. "Agnus and another file called Dei"") with just a single output file, and so it gives up.

Since the original files that triggered this bug for me are copyrighted, I can't upload them here. I have, however, managed to reproduce this bug using a .flac file I created myself (from a Creative-Commons licensed file downloaded from www.freesound.org), so I'll upload that file to this bug report so that the bug can be reproduced.

Revision history for this message
Robin Munn (rmunn) wrote :
Revision history for this message
Robin Munn (rmunn) wrote :
Revision history for this message
Robin Munn (rmunn) wrote :

Audio source for those two .flac files is the sound sample from http://www.freesound.org/samplesViewSingle.php?id=983. The only difference between the two files is the title tag; everything else should be identical.

Revision history for this message
Robin Munn (rmunn) wrote :

To reproduce the bug:

1) Download both nightengale*.flac files into the same directory.
2) Run "pacpl -v -t m4a nightengale*.flac"

For extra debugging output:

sudo $EDITOR /usr/bin/pacpl
Search for the regex "pnotice.*encode_string"
Delete the words "if $dryrun" from the end of the line, so that the debug message will print even in non-dryrun mode. (In dryrun mode, the title tag isn't actually extracted, so the debug information printed in dryrun mode is not the actual command that gets edited in non-dryrun mode).
Run the pacpl command above, and note the combination of spaces and quotes in the call to the faac encoder.

Revision history for this message
Robin Munn (rmunn) wrote :

I believe the solution to this bug would be to check the title tag for double-quote characters (and possibly other "special" shell characters like dollar signs, etc.) and backslash-escape them before passing them to the encoder.

Revision history for this message
Robin Munn (rmunn) wrote :

Upstream doesn't have a bug tracker, but http://pacpl.sourceforge.net/faq.html lists an email address to contact to report bugs. I've reported this bug upstream by emailing them the URL of this Launchpad report.

Revision history for this message
discord (colin.williams) wrote :

Hello, I think maybe I'm suffering the same bug.

I'm facing the issue also going flac -> aac

> I'm having trouble encoding aac's from my flac files. I believe there is a bug.

I've tried the following:

$ pacpl --to aac -r -o flac --outdir /tmp /home/discord/Music/flac/

Converting: [01 - Air - Do The Joy.flac] -> [aac] encode failed with exit status: 256

> Also note that the aacqual option does not seem to work:

$ pacpl --to aac --aacqual 196 -r -V -o flac --outdir /tmp --dryrun /home/discord/Music/flac/

debug: ffmpeg -y -i "/tmp/Björk-Debut-12-Play_Dead.9261.wav" -ab 128.k -ar 44100 -ac 2 "/tmp/Björk-Debut-12-Play_Dead.aac"

removed temporary file: /tmp/Björk-Debut-12-Play_Dead.9261.wav

Converting: [07 Moon 83.flac] -> [aac]

debug: flac -f -d "/home/discord/Music/flac/B52's/07 Moon 83.flac" -o "/tmp/07 Moon 83.24947.wav"

debug: ffmpeg -y -i "/tmp/07 Moon 83.24947.wav" -ab 128.k -ar 44100 -ac 2 "/tmp/07 Moon 83.aac"

removed temporary file: /tmp/07 Moon 83.24947.wav

$ pacpl --to aac --aacqual 450 -r -V -o flac --outdir /tmp --dryrun /home/discord/Music/flac/

>I don't know why the manual for pacpl states the default value is 300 when it seems to be 128K. As you probably already know, the -ab option in ffmpeg specifies the bitrate.

>I found and tried a fix mentioned on the ubuntu forums, but it didn't work for me:

>Here is a fix for the "encode failed with exit status: 256" error message.
>
>I was getting the "encode failed with exit status: 256" error message when trying to convert flac to m4a to use on my >ipod. The problem was that pacpl is passing the wrong command line options to ffmpeg, as the --verbose option >reveals (see output below). The fix is to edit line 2036 of /usr/bin/pacpl to read
>
>case /mp4|m4a|m4b/ { return "-title \"$tag_name{title}\" -track \"$tag_name{track}\" -author \"$tag_name{artist}\" ->album \"$tag_name{album}\" \"$tag_name{comment}\" -year \"$tag_name{year}\""; }
>
>(all one line). ffmpeg is expecting single dashes for options, "author" instead of "artist", and has no genre field. I've >filed a bug report.

Revision history for this message
Douglas Bodden (dcb-76) wrote :

I'd like to offer some help on this.

Basically, there are two things going on:
1) ffmpeg is getting the wrong options from pacpl for handling of metadata.
2) faac is having another issue, possible related to the special characters previously mentioned.

I'd be happy to look into fixing both (I'm already well along on the ffmpeg issue). I'm going to try to apply fixes to pacpl, and will be talking to the author of that package (upstream) as well as the Ubuntu team to get a fix tested and into an update for their repositories.

I know it's been a while for you (7 months?) but please give me a few weeks and I'm hopeful I'll get this fixed.

Changed in pacpl (Ubuntu):
status: New → Confirmed
Revision history for this message
Alexander A. (the2ndhare) wrote :

Time sure flies by.

As for #1 (wrong ffmpeg options) the corrections would be:
-metadata title=
instead of
-title
etc.
So the whole line (2064 in /usr/bin/pacpl in 4.0.5) would look like:

return "-metadata title=\"$tag_name{title}\" -metadata track=\"$tag_name{track}\" -metadata author=\"$tag_name{artist}\" -metadata album=\"$tag_name{album}\" -metadata comment=\"$tag_name{comment}\" -metadata year=\"$tag_name{year}\" -metadata genre=\"$tag_name{genre}\"";

That at least gets us through the 256 error, but the output files are still left with empty tags.

Revision history for this message
Matteo Cypriani (mcy) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.