.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.
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 – 2013-03-08T15:35:40.873
Oh, you mean you have an audio track and want to set the artwork? I'll update my answer. – slhck – 2013-03-08T15:37:43.857
great, now I can batch all this :D – riimzzai – 2013-03-08T15:41:05.407
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 – 2013-03-18T11:03:54.397
Good question. I'm not sure if there's anything special about iTunes artwork. – slhck – 2013-03-18T11:32:57.977