Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Why on Ubuntu 12.04, when I extract audio in M4A from a video (MP4 or FLV, etc.) with avconv:

avconv -i video.mp4 -c:a libvo_aacenc sound.m4a 

there is a video stream in it, and if I want only audio stream, I have to add the -vn option, like this:

avconv -i video.mp4 -c:a libvo_aacenc -vn sound.m4a

I mean, isn't M4A an audio format?


Is it possible to add the artwork to the audio output ?

with this command I can extract one frame,

avconv -i vid.mp4 -vsync 1 -frames 1 -s 1024x768 -an -y image.jpeg

but is it possible to associate it with the audio output? The solution is a part of both I guess, but I can't figure it out.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

.m4a is just another commonly used file extension for the MPEG-4 Part 14 container, usually called MP4. The container can carry video, audio and subtitles. The extension doesn't change that fact, although often, you'd only put audio in .m4a files, and video in .m4v files.

See Wikipedia for more info:

… since MPEG-4 Part 14 is a container format, MPEG-4 files may contain any number of audio, video, and even subtitle streams, making it impossible to determine the type of streams in an MPEG-4 file based on its filename extension alone. In response, Apple Inc. started using and popularizing the .m4a filename extension, which is used for MP4 containers with audio data in the lossy Advanced Audio Coding (AAC) or its own lossless Apple Lossless (ALAC) formats. Software capable of audio/video playback should recognize files with either .m4a or .mp4 filename extensions, as would be expected, since there are no file format differences between the two. Most software capable of creating MPEG-4 audio will allow the user to choose the filename extension of the created MPEG-4 files.


If you want one static picture shown together with the audio, you'll have to convert it to a video. For example, create the frame you want and call it image.png (or image.jpg):

avconv -i input.mp4 -frames:v 1 image.png 

This will give you the first frame of the video. If you want one from another timestamp, add the -ss option before -i to skip to, e.g. 10 seconds: avconv -ss 10 -i ….

Then:

avconv -i input.mp4 -i image.png \
-c:v libx264 -pix_fmt yuv420p -r 1 -c:a copy -map 0:a:0 -map 1 output.mp4

Here, choose x264 for encoding a video from the still image, and just copy the audio stream from the original file. A frame rate of -r 1 should be enough, although you can leave that part out.

With -map 0:a:0 you select the first audio stream from the first file, and with -map 1 you select the image to be muxed into the output. (The \ is just to escape the newline.)

The -map switches work fine for the recent (and decent) latest FFmpeg versions—I can't talk about Ubuntu's Libav though. If it doesn't work for you just download FFmpeg instead.


If you want to set the album artwork for an .m4a file, use AtomicParsley:

AtomicParsley input.m4a --artwork image.jpg

This will create a new file with the image embedded as artwork, which now correctly shows in most media players. To overwrite the input file itself, use the --overWrite switch as well.

share|improve this answer
    
thank you for your detailed answer. But may be I explained it wrong : what I want to do is associate an image with an audio file, like you would be able to do it in iTunes, and to have, for example, the picture of the album when playing the sound. May be this is a matter of metadata, still I can't find the way to manage it (neither in vlc or rythm box or else...). –  riimzzai Mar 8 '13 at 15:35
    
Oh, you mean you have an audio track and want to set the artwork? I'll update my answer. –  slhck Mar 8 '13 at 15:37
    
great, now I can batch all this :D –  riimzzai Mar 8 '13 at 15:41
    
After managing a bit with AtomicParsley, I have noticed that the artwork is not displayed when the song is played on the Ipod. But it appears when playing when Mplayer. If you have any suggestion... –  riimzzai Mar 18 '13 at 11:03
    
Good question. I'm not sure if there's anything special about iTunes artwork. –  slhck Mar 18 '13 at 11:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.