http://askubuntu.com/questions/160869/need-to-downsample-video-to-a-lower-resolution - good
http://www.mpabo.com/2014/12/14/ffmpeg-and-x264-encoding-guide/ - good
http://thomer.com/howtos/ipod_video.html - done reading, good
http://www.ilounge.com/index.php/articles/comments/the-complete-guide-to-ipod-video-formats-and-display-resolutions/ - good


http://www.hongkiat.com/blog/ffmpeg-guide/ - done watching


http://www.systutorials.com/3540/converting-video-files-for-ipod-iphone-ipad/ - done reading
http://superuser.com/questions/624563/how-to-resize-a-video-to-make-it-smaller-with-ffmpeg - done reading

How can we suppress the disclaimer?

Add the -hide_banner option

How can we extract audio from a video file?

ffmpeg -i yourvideoname.mp4 -vn -ab 128 outputaudio.mp3

How can we add a poster image to an audio file?

ffmpeg -loop 1 -i inputimage.jpg -i inputaudio.mp3 -c:v libx264 -c:a 
  -strict experimental -b:a 192k -shortest outputfile.mp4

How can we convert a video file from one format to another format?

ffmpeg -i yourvideoname.mp4 -c:v libx264 outputfilename.wmv

How can we join multiple video files into one?

See http://www.hongkiat.com/blog/ffmpeg-guide/

How can we cut a portion of a video?

ffmpeg -i yourvideoname.mp4 -ss 00:00:45 -codec copy -t 40 outputclip.mp4

How can we split a video file into multiple clips?

ffmpeg -i yourvideoname.mp4 -t 00:00:59 -c copy part1.mp4 
  -ss 00:00:59 -codec copy part2.mp4

How can we remove audio from a video file?

ffmpeg -i yourvideoname.mp4 -an mutevideo.mp4

How can we resize a video file?

ffmpeg -i yourvideoname.mp4 -s 640x480 -c:a copy resizedvideo.mp4

How can we create a video file from a static image and an audio file?

If you want to add audio (e.g. audio.wav) to one "poster" image, you need -shortest to tell it to stop after the audio stream is finished. The internal AAC encoder is used in this example, but you can use any other supported AAC encoder as well:

ffmpeg -hide_banner -loop 1 -i img.jpg 
  -i audio.wav -c:v libx264 
  -pix_fmt yuv420p -c:a aac 
  -strict experimental 
  -b:a 192k -shortest out.mp4

If your audio file is using a codec that the output container supports (e.g. MP3 audio in AVI or M4A/AAC audio in MP4), you can copy it instead of re-encoding, which will preserve the audio quality:

ffmpeg -hide_banner -loop 1 
  -i img.jpg -i audio.m4a -c:v libx264 
  -pix_fmt yuv420p -c:a copy -shortest out.mp4
ffmpeg -hide_banner -loop 1 
  -i HowMuchCanISave-part2.png 
  -i HowMuchCanISave-part2.m4a -c:v libx264 
  -pix_fmt yuv420p -c:a copy 
  -shortest HowMuchCanISave-part2.mp4

How can we use ffmpeg to convert video files to a different video format?

# This command is for converting to format suitable for ipod classic:
ffmpeg -i "$1" 
  -c:v libx264 -crf 22 
  -preset veryslow -profile:v baseline -level 3 
  -refs 6 -vf "scale=640:-1,pad=iw:480:0:(oh-ih)/2,format=yuv420p" 
  -b:a 256k -strict -2 "$2

ffmpeg -i input.wmv -strict -2 output.mp4
ffmpeg -i input.wmv -s 480x320 -b 1000k -strict -2 output.mp4

# we can form this command to a script convert2mp4.sh
ffmpeg -i $1 -s 480x320 -b 1000k -strict -2 /tmp/$1.mp4

ffmpeg -i YOUR-INPUT.wmv 
  -s qvga -b 384k 
  -vcodec libx264 
  -r 23.976 
  -acodec libfaac -ac 2 -ar 44100 
  -ab 64k -vpre baseline 
  -crf 22 -deinterlace 

# this messes up the aspect ratio!
ffmpeg -i some_movie.avi -f mp4 -vcodec libxvid -maxrate 1000 \
       -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac
       -strict experimental -mbd 2 -s 320x240 -ab 128 -b 400 some_movie.mp4

#  figure out the aspect ratio of an existing video file:
ffmpeg -i some_movie.avi

# this maintains the proper aspect ratio for a 16:9 video
ffmpeg -i some_movie.avi -f mp4 -vcodec xvid -maxrate 1000 \
       -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac \
       -mbd 2 -s 320x180 -padtop 30 -padbottom 30 \
       -ab 128 -b 400 some_movie.mp4

ffmpeg -i "input.mp4" \
       -c:v libx264 -crf 22 -preset veryslow \
       -profile:v baseline -level 3 -refs 6 \
       -vf "scale=640:-1,pad=iw:480:0:(oh-ih)/2,format=yuv420p" \
       -c:a libmp3lame -b:a 256k \

ffmpeg -i input.mp4 
  -vcodec libx264 
  -profile:v main 
  -level 3.1 
  -preset medium 
  -crf 23 
  -x264-params ref=4 
  -acodec copy 
  -movflags +faststart 

# If your video is greater than 720p, add the following after the input:
-vf "scale=-2:720:flags=lanczos"

ffmpeg -i test.mov -profile:v baseline -level 3.0  test.mp4

ffmpeg -i the_heist-RRZyz1vXkPE.flv -acodec copy -sameq heist.mpg

The "-acodec copy" will cause ffmpeg to copy the audio from input to output 
file, while "-sameq" causes the output video quality to be the same as the 
source, but output file will be very big. For YouTube videos, you can use 
"-b 320000" instead of "-sameq" to get smaller file sizes.

// http://stackoverflow.com/questions/23260944/encode-video-for-ipod-classic
ffmpeg -i in.mp4 -vcodec libx264 -crf 23 -preset fast -profile:v baseline \
-level 3 -refs 6 -vf "scale=640:-1,pad=iw:480:0:(oh-ih)/2,format=yuv420p" \
-acodec copy output.mp4

ffmpeg -i input.avi -acodec libfaac -ab 128k -ar 44100 -vcodec mpeg4  -b 1250K output.m4v
ffmpeg [other-options] -b bitrate -i "input.avi" "output.mp4"
ffmpeg [other-options] -b bitrate -i "New Year Party.avi" "New Year Party.mp4"

ffmpeg -b 1250k -i japantrip_01.avi japantrip_01.mp4

ffmpeg -i input.avi -acodec libfaac -ab 128k -ar 44100 -vcodec mpeg4 -b 1250K output.m4v

ffmpeg -i "input.avi" -acodec libmp3lame -ab 192 "output.mov"

ffmpeg -i input.mp4 -vcodec libx264 -profile:v main -level 3.1 -preset medium -crf 23 -x264-params ref=4 -acodec copy -movflags +faststart output.mp4

ffmpeg -i input.mp4 -vcodec libx264 -crf 20 output.mp4
ffmpeg -i <inputfilename> -s 640x480 -b 512k -vcodec mpeg1video -acodec copy <outputfilename>

ffmpeg -i input.mp4 -b:v 200k -c:v libx264 -vf scale=640:360 -pix_fmt yuv420p -c:a aac -strict experimental -b:a 128k -ac 2 -ar 44100 -threads 2 -f mp4 output.mp4

ffmpeg -i MyMovie.mkv -vf scale=-1:720 -c:v libx264 -crf 0 -preset veryslow -c:a copy MyMovie_720p.mkv
ffmpeg -i MyMovie.mkv -vf scale=-1:720 -c:v libx264 -crf 18 -preset veryslow -c:a copy MyMovie_720p.mkv

ffmpeg -i input.avi -vf scale=320:240 output.avi
ffmpeg -i input.jpg -vf scale=320:-1 output_320.png

ffmpeg -i input.jpg -vf scale=iw*2:ih input_double_width.png
ffmpeg -i input.jpg -vf scale=iw*.5:ih*.5 input_half_size.png

ffmpeg -i ARM-NewARMLiveTraining.wmv  -vcodec libx264 -crf 20 -strict -2  -vf scale=640:-1 ARM-NewARMLiveTraining.mp4

-b 512k
-preset veryslow
-crf 28
-profile:v baseline -level 3.0
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License