How to Record, Convert and Extract Videos & Audios using Avconv on Ubuntu
avconv is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter.
In this article we’re going to see how we use “avconv” command.
Install “Avconv”
avconv is available to install from the official repositories for all Debian-based distributions like Ubuntu and Mint, using following commands.
# sudo apt-get update # sudo apt-get install libav-tools
Get Video and Audio Information
If you want to check the information about any multimedia file, then run the following command to know information:
# avconv -i My-Video-File.mp4
Extract Audio from Video File
To extract the audio file from any video file, you may run the following command:
# avconv -i My-Video-File.mp4 -vn -f mp3 My-Audio-File.mp3
Note:
Convert .avi to .mkv Format
To convert an .avi file to .mkv format, use the following command:
# avconv -i source_file.avi -vcodec libx264 output_File.mkv
Note:
-vcodec is an option that we use to choose a video codec, this option is important in order to keep the video quality as it is.
Convert .mp4 to avi Format
To convert an .mp4 file to .avi format, use the following command:
# avconv -i My-Video-File.mp4 -vcodec libx264 output_File.avi
Convert .mp3 to .wav Format
To convert an .mp3 file to .wav format, use the following command:
# avconv -i My-Audio-File.mp3 output_File.wav
Convert .yuv to .avi Format
You can change the format accourding to your requirement. To convert an .yuv file to .avi format, use the following command:
# avconv -i source_file.yuv output_File.avi
Merge Video and Audio Together
To merge video file with an audio file, use following command:
# avconv -i My-Audio-File.wav -i My-Video-File.avi output_File.mkv
Convert Video into Images
To convert a video file into multiple images, you run the following command:
# avconv -i My-Video-File.mp4 -r 1 -s 1366x768 -f image2 image-%01d.png
Note:
More Options to use with Libav
In Libav, there are an astounding things called “filters”, using filters, you can do numerous extraordinary things to your multiple files.
# avconv -i input_file.avi -vcodec libx264 -vf "drawbox=x=50:y=50:width=400:height=300:color=red@0.5" output_File.avi
Note:
Record tty as a Video
This command must be used by the root user, it won’t work without sudo, because it requires access to the framebuffer device (fbdev). fbdev is the Linux framebuffer input device, this device is the responsible device for showing the graphics in the console.
# sudo avconv -f fbdev -r 30 -i /dev/fb0 output_File.avi
Note:
Enjoy It!