Mp4

Convert MP4 to MP3
To OGG: ffmpeg -i videofile.mp4 -vn -acodec libvorbis audiofile.ogg

for vid in *.mp4; do ffmpeg -i "$vid" -vn -acodec libvorbis "${vid%.mp4}.ogg"; done

To MP3: ffmpeg -i videofile.mp4 -vn -acodec libmp3lame audiofile.mp3

Copy Audio Track: ffmpeg -i videofile.mp4 -vn -acodec copy audiofile.aac
 * 1) directly copy audio stream from file

ffmpeg -i videofile.mp4 -vn -acodec copy audiofile.mp3
 * 1) assuming codec was mp3 - which may not be correct

See codec: (assuming your ffprobe supports these options) ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -print_format csv=p=0 "videofile.mp4"

Automate: mkdir -p output for vid in *.mp4; do  codec="$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -print_format csv=p=0 "$vid")" case "$codec" in   mp3    ) filetype=mp3 ;;    vorbis ) filetype=ogg ;; *     ) filetype= ;;   esac
 * 1) current directory has to contain at least one .mp4 file

if [ "$filetype" ]; then ffmpeg -i "$vid" -vn -acodec copy output/"${vid%.*}"."$filetype" else ffmpeg -i "$vid" -vn -acodec libvorbis output/"${vid%.*}".ogg done

References:
 * bash - how can I batch extract audio from mp4 files with ffmpeg without decompression (automatic audio codec detection)? - Ask Ubuntu - http://askubuntu.com/questions/221026/how-can-i-batch-extract-audio-from-mp4-files-with-ffmpeg-without-decompression

---

Constant Bitrate Mode (CBR):

ffmpeg -i inputfile.m4a -c:a libmp3lame -ac 2 -b:a 190k outputfile.mp3

Variable Bitrate Mode (VBR):

ffmpeg -i inputfile.m4a -c:a libmp3lame -ac 2 -q:a 2 outputfile.mp3

avconv
apt-get install libav-tools

Using avconv extract aac: avconv -i "INPUT FILE" -map 0:1 -c:a copy "OUTPUT FILE" # or avconv -i MyVideoFile.mp4 -vn -acodec copy MyAudioFile.aac

for i in *.mp4; do   avconv -i "${i}" -map 0:1 -c:a copy "${i%.mp4}.aac" done
 * 1) back conversion

extract to mp3: (convert) avconv -i "infile.mp4" "outfile.mp3"

Source: http://askubuntu.com/questions/235892/batch-extract-audio-with-avconv-without-transcoding

---

Get Video and Audio File Information avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4

Extract Audio from Video File avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -vn -f wav sound.wav

Extract Video avconv -i You-Rock-My-World.avi -vcodec libx264 -an -f mp4 video.mp4

Convert .avi to .mkv Format avconv -i You-Rock-My-World.avi -vcodec libx264 You-Rock-My-World.mkv

Convert .mp4 to avi Format avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -vcodec libx264 newfile.avi

Convert .mp3 to .wav Format avconv -i michael-jackson-dangerous.mp3 newfile.wav

Merge Video and Audio Together avconv -i the-sound-file.wav -i the-video-file.avi the-output-file.mkv

Convert Video into Images avconv -i Michael-Jackson-You-Rock-My-World-HD.mp4 -r 1 -s 1366x768 -f image2 image-%03d.png

Rotate video: avconv -i input-file.avi -vcodec libx264 -vf "transpose=cclock" output-file.avi
 * 1) transpose=cclock is a video filter that rotates the video by 90 degree clockwise

Examples: http://www.tecmint.com/avconv-command-examples/

Convert MKV to MP4
Change container: ffmpeg -i input.mkv -codec copy output.mp4

Re-encode Audio
To re-encode any format to AAC-LC in an ADTS container (.aac file) using FFmpegs's native AAC encoder (second best after non-free Fraunhofer's libfdk_aac according to https://trac.ffmpeg.org/wiki/Encode/AAC -- doesn't support any HE-AAC though), you also need to specify -strict experimental (or -strict -2):

Rencode mp3 to aac: ffmpeg -i input.mp3 -strict experimental -c:a aac -b:a 128k output.aac

Rencode audio in an mp4: ffmpeg -i input.mp4 -codec:a aac output.mp4

MP4 Splitter and Joiner
http://avidemux.sourceforge.net/download.html