Audio encoding

Archived from the Transloadit support forum. Originally posted on January 18, 2011; details may be outdated, see our docs for current behavior. Original thread

Hi Felix,
Following on from this thread:
http://transloadit.com/docs/video-encode#comment-130207880
https://community.transloadit.com/t/external_id/tender-problems-24

…I have signed up for an account and am going to develop against Transloadit as it’s cheaper to get started with than Pandastream.

In the previous support discussion you mentioned ‘metadata’ as a to do. I will definitely need to be able to set metadata fields on the encoded files… I’m hoping it will be possible already via ffmpeg commands in the Assembly (http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/) and that the metadata to do at your end is more related with http://transloadit.com/docs/meta-data ?

I have had some difficulty getting ffmpeg to tag ID3 metadata in a way that is readable by Windows:
https://roundup.ffmpeg.org/issue2562
Since I want to provide well-tagged downloads from my app this is important for me.

I suspect the only answer may be to use a dedicated ID3 tagging utility. I believe this would have to operate on the file before it was stored to s3 - does that mean there would need to be a ‘metadata’ robot that could be a front-end onto such tools?

does that mean there would need to be a ‘metadata’ robot that could be a front-end onto such tools?

Yes. Our plan is to add meta data read and write support for audio files, but unfortunately we don’t support either so far.

I can’t give you a date for this yet, but a lot of people want audio improvements lately, so it’s rapidly moving up our todo list.

--fg

In addition to mp3 I’d like to output a couple of other common formats (aac, flac and apple lossless, maybe ogg vorbis too)

I was just trying to get AAC to work but the problem I encountered is that (I think) Transloadit is not giving an output filename with an extension to ffmpeg. In which case ffmpeg seems to need a hint via the -f option.

‘-f mp3’ works for mp3s but I found testing on my local ffmpeg that neither ‘-f aac’ or ‘-f m4a’ work for AAC… they give the same error I get on Transloadit:

“Requested output format ‘m4a’/‘aac’ is not a suitable output format”

I’m just learning ffmpeg as I go so maybe there’s an easy way around this.

Hopefully you have libfaac enabled too:
http://lists.mplayerhq.hu/pipermail/ffmpeg-user/2010-March/024662.html
:slight_smile:

Hey,

I’m pretty sure we support libfaac
Maybe you can try using the acodec flag like so?

 'acodec': 'aac',

if that doesn’t work, give me your full syntax and we’ll work something out

Thanks for the reply.

I have tested locally using a command like:

 ffmpeg -i "D:\Audio Projects\short test.wav" -aq 100 -acodec aac -metadata title="Test Title" -metadata author="Test Artist" -metadata album="Test Album" ../out4

I get the same error as on Transloadit. When trying to encode to either mp3 or AAC if I don’t use the -f option I get an error like:

Unable to find a suitable output format for '/mnt/tmp/scratch/REDACTED'

With mp3 files I can get around that because ‘-f mp3’ works.

I have posted for support on the ffmpeg-users list. I don’t know if it’s the best way but maybe a simple solution would be if I could specify a file extension for the output path in my Assembly somehow.

(on the plus side - meta data for .m4a files output from ffmpeg shows up fine in Windows!)

thanks to help from ffmpeg-users I found the correct -f option for AAC files is ‘mp4’:
http://lists.mplayerhq.hu/pipermail/ffmpeg-user/2011-January/028474.html

bit confusing because in the ffmpeg -formats list there are also ‘aac’ and ‘m4a’ entries which match the codec name and file extension respectively, but in this case they are the wrong ones to use!

so I assume for every output format there is a valid -f option and the file extension thing isn’t an issue.

in my Assembly response I see:

[audio_codec] => ffaac

so it looks like libfaac is used.

Coming back to the thing of file extensions - it looks like Transloadit tries to detect the file type and append an appropriate file extension when copying results to s3 (?)

Due to earlier errors I established that at the ffmpeg encoding stage there was no file extension, but in the s3 bucket my mp3 result file is called ‘originalname.mp3’, which is great.

My AAC file came out as ‘originalname.mp4’, which is not wrong though in my case I’d like to see a .m4a like iTunes uses. The assembly reports a mime of video/mp4 and type video. Seems like this should be ‘audio’, but I don’t know if the mp4 format is ambiguous or something.

I got FLAC working, but the output file is ‘originalname.wav’ …The assembly output shows [mime] => audio/flac so I guess you need more mappings of mime types to extensions.

Or… I think in the end being able to specify my own file extension in the assembly would be useful.

Apologies… I can do the file extension myself by setting up the /s3/store robot properly!

and correct -f option for ALAC (Apple Lossless) is ‘-f ipod’…

So at this point you still need us to fix the mime types of the files on S3? Or could you for the mean time make one export step for each file, and set the mime via the headers ‘Content-Type’ parameter?

Have you fixed the mime types? I am seeing audio/mp4 today which is awesome (I might have had a mistake in my assembly yesterday).

I just processed a much more complete assembly with good success:
https://transloadit.com/assemblies/view/REDACTED (I guess you can peek into my account)

Only the mp3s had their file extension detected when saving the output files, but as you say I can get around that by having individual export steps for each encoding in my assembly.

My only remaining issues are with metadata tagging in the files: Windows needs ID3v2.3 tags in mp3s but I can only output v2.4. Also I haven’t yet been able to write any metadata to the Ogg and the Flac only had partial data visible when played in VLC – Ogg and Flac both use Vorbis Comments format I think.

Both of these are issues with ffmpeg rather than Transloadit, but if no solution is possible on ffmpeg side it means I rely on Transloadit to provide other ways of adding metadata to the files before transfer to S3.

P.S.
it’s great what you guys have built here, impressed!

Ideally I’d like to be able to add album art as metadata to those audio formats where that is possible. I don’t think ffmpeg can do that at all.

Have you fixed the mime types?

No, we made no changes yet.

The stuff you are trying todo will require explicit audio meta data support on our end. If you know of any suitable linux tools for that, we’d be happy to hear about it.

--fg

re metadata tagging. I have been reading up lately and it’s quite a complicated issue.

The two libraries I’ve seen that comprehensively handle multiple formats and look up-to-date are:
http://code.google.com/p/mutagen (Python)
http://www.jthink.net/jaudiotagger (Java)

For me Mutagen is not currently an option as it insists on saving ID3v2.4 tags for mp3s. I believe jAudioTagger can be made to save v2.3 tags.

Both are object-oriented libraries without any command-line interface so you’d have to do some work to wrap them up and expose a nice interface to the Assembly engine. If you’re on Node.js then jAudioTagger might integrate more easily as it’s Java.

The main things for me are:
- ability to set any tag in all the main formats (not just a subset of common tags) - ability to save ID3v2.3 tags in mp3s for Windows-compatible tagging

As a quick fix, it would be great if there way a way to use the metadata option of ffmpeg via an assembly. On the command-line you have to use the -metadata option several times… once for each tag you want to set.

eg

ffmpeg -i "test.wav" -acodec libmp3lame -ab 128k -metadata artist="Artist" -metadata title="Title" ../test2.mp3

I don’t think this is possible via the ‘ffmpeg’ parameter of the encode robot currently?

Maybe if you could give it an object as a value, eg:

      "mp3_320": {
          "use": ":original",
          "robot": "/audio/encode",
          "ffmpeg": {
              "f": "mp3",
              "acodec": "libmp3lame",
              "ab": "320k",
              "metadata": {
                  "artist": "The Artist",
                  "title": "Track Title",
                  "album": "The Album"
              }
          }
      }

This still has the problems of using ffmpeg for the metadata but it would allow setting tags in mp3s (albeit v2.4) and m4a files (doesn’t seem to do much for flac or ogg).

Actually, I think you can get the ffmpeg options to do this right now using this trick:

"mp3_320": {
  "use": ":original",
  "robot": "/audio/encode",
  "ffmpeg": [
    {
      "f": "mp3",
       "acodec": "libmp3lame",
       "ab": "320k",
    },
    { "metadata": "artist=\"The Artist\"" },
    { "metadata": "title=\"Track Title\"" },
    { "metadata": "album=\"The Album\"" }
  ]
}

I have not tested it, but it should pass the parameters to ffmpeg as you’d expected it to.