add an mp3 audio track to a video

mencoder -idx Your_Input_Video_File -ovc lavc -oac mp3lame -audiofile Your_Audio_track.mp3 -o Output_File.avi
Sample Output
gnu@robby:~$ mencoder -idx out2.ogv -ovc lavc -oac mp3lame -audiofile /home/gnu/snowballz/data/music/snowballz2.mp3  -o snow.avi
MEncoder 2:1.0~rc2-0ubuntu19 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Pentium(R) D CPU 2.80GHz (Family: 15, Model: 4, Stepping: 7)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x76c7ec5
Ogg stream 0 is of an unknown type
[Ogg] stream 1: video (Theora v3.2.1), -vid 0
Ogg file format detected.
VIDEO:  [theo]  1024x768  24bpp  15.000 fps    0.0 kbps ( 0.0 kbyte/s)
Audio file file format detected.
[V] filefmt:65536  fourcc:0x6F656874  size:1024x768  fps:15.00  ftime:=0.0667
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
[theora @ 0x88423b0]Missing extradata!
Could not open codec.
VDecoder init failed :(
Opening video decoder: [theora] Theora/VP3
VDec: vo config request - 1024 x 768 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
videocodec: libavcodec (1024x768 fourcc=34504d46 [FMP4])
Selected video codec: [theora] vfm: theora (Theora (free, reworked VP3))
MP3 audio selected.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos: 169.7s   2546f ( 0%) 12.61fps Trem:   0min   0mb  A-V:0.139 [815:231]
Skipping frame!
Pos: 170.4s   2557f ( 0%) 12.62fps Trem:   0min   0mb  A-V:0.135 [816:230]
Skipping frame!
Pos: 331.8s   4979f ( 0%) 13.60fps Trem: 603min 3609mb  A-V:0.102 [791:230]
Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream:  791.586 kbit/s  (98948 B/s)  size: 32831029 bytes  331.800 secs  4979 frames

Audio stream:  230.839 kbit/s  (28854 B/s)  size: 4917529 bytes  170.423 secs

By: eastwind
2009-12-11 23:50:37

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: