Mp4

From Omnia
Revision as of 14:30, 21 May 2021 by Kenneth (talk | contribs) (→‎Convert MKV to MP4)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Extract Audio

Convert MP4 to MP3

To MP3:

ffmpeg -i in_video_file.mp4 out_audio_file.mp3
ffmpeg -i videofile.mp4 -vn -acodec libmp3lame audiofile.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

Copy Audio Track:

# directly copy audio stream from file
ffmpeg -i videofile.mp4 -vn -acodec copy audiofile.aac
# assuming codec was mp3 - which may not be correct
ffmpeg -i videofile.mp4 -vn -acodec copy audiofile.mp3

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
# current directory has to contain at least one .mp4 file 
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

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

References:

---


Constant Bitrate Mode (CBR): [1]

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
# back conversion
for i in *.mp4; do
   avconv -i "${i}" -map 0:1 -c:a copy "${i%.mp4}.aac"
done

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
# 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


ffmpeg -i input.mkv -vn -acodec copy output.m4a
ffmpeg -i input.mkv -vn -acodec copy output.aac

Extract m4a from MP4

Extract m4a from MP4/MKV [2]

ffmpeg -i input.mp4 -vn -c:a copy output.m4a

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): [3]

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

keywords