User Tools

Site Tools




image sequence / slideshow to gif

ffmpeg -i %d.png -s hd480 -y -filter:v "setpts=15*PTS" output.gif


ffmpeg -pattern_type glob -i "2017-06-07/*.png" -vcodec mpeg4 -y -q:v 0 test.mp4


HTTPPort 8090

<Feed bunny.ffm>
	Launch ffmpeg -i rtsp://

<Stream bunny.mjpeg>
	Feed bunny.ffm
	Format mpjpeg
	VideoCodec mjpeg
	ACL allow localhost
	ACL allow

<Stream stat.html>
	Format status
	ACL allow localhost
	ACL allow

even een snelle file in elkaar gezet als voorbeeld, zie config

als je dan start: ffserver -f bunny.conf

zie je hier een konijn

en hier de status

In dit geval haal ik een rtsp stream binnen en voer die weer uit als mjpeg stream

Maar het kan nog super veel meer

Ik had het zelf nodig met 10 netwerk camera’s die per stuk maar 3 gelijktijdige streams aankunnen, door het door mijn eigen ffserver heen te gooien gebruik ik op elke camera maar 1 stream en kan ik het naar tientallen clients streamen.

Ook fijn als je een camera achter een router hebt zitten en je wel ergens een server hebt, kun je met ffserver die camera naar die server streamen en weer verder.


-q:v 0 is highest quality
-q:v 31 is lowest quality

get / calculate number of frames

ffmpeg -i FILENAME -f null /dev/null

or add this to ~/.bash_profile

_fps() {
    ffmpeg -i "$1" -f null /dev/null
alias fps=_fps

set volume of audio

ffmpeg -i input.wav -af "volume=0.5" output.wav

gifenc (with speed)



ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2

calculate framerate to get a desired number of frames

say you have 2500 frames. You want to get 300 frames. 2500/300=8.3. Use 8.3 as input framerate and use 1 as output framerate. (or 83 as input framerate and 10 as output framerate)

ffmpeg -r 8.3 -i input.mp4 -vcodec mpeg4 -q:v 0 -r 1 output.mp4 


ffmpeg -r 83 -i input.mp4 -vcodec mpeg4 -q:v 0 -r 10 output.mp4 


ffmpeg -r 7.5 -f concat -i list.txt -vcodec mpeg4 -g 1 -q:v 0 -s 2048x1024 -r 1 -y

HQ animated gifs with custom palette



file ''
file ''
file ''
file ''


ffmpeg -f concat -i list.txt -c copy

change speed

ffmpeg -i input.mp4 -vf "setpts=(1/<speed>)*PTS" output.mp4

resize video to 480p or 720p

ffmpeg -i INPUT.MOV -s hd480 OUTPUT.MOV

create animated GIF from sequence and specify framerate

convert image sequence to movie

ffmpeg -i output/frame%d.jpg -g 1 -y -q:v 0 -r 10  output.mp4

lossless skip first x seconds of mp3

ffmpeg -ss 54 -i input.mp3 -acodec copy -y output.mp3

limit total number of frames (not changing framerate)

ffmpeg -i input.mp4 -vcodec mpeg4 -vframes 500 -q:v 0 output.mp4

cut / split video

ffmpeg -ss 00:01:22 -i Doodle3D.m4v -q 0 -vcodec copy -acodec copy -y
ffmpeg -ss 00:01:14 -t 00:00:31 -i Doodle3D-kickstarter-movie.mp4 -q 0 -vcodec copy -acodec copy -y tmp2.mp4

offset & seek

offset video (0.5 sec) & seek/skip to position in audio (0.3 sec):

ffmpeg -itsoffset 0.3 -i video-input.mp4 -ss 0.5 -i audio-input.mp3 -vcodec copy -acodec copy -y

fix aspect ratio

..... -s 900x720 -aspect 16:9 

-sameq vs -qscale

  • for video
-q:v 0
  • for audio
-q:a 0

add audio / soundtrack to movie

ffmpeg -i IMG_7966.MOV -i sound.mp3 -vcodec copy -acodec copy 

wellicht interessant

rawvideo / uncompressed avi

ffmpeg -i air_traffic_2048.mp4 -sameq -r 15 -vcodec rawvideo -y new.avi

more uncompressed info

ffmpeg -i one-hand-with-sleeve.mpg -sameq -g 1 -f mov -vcodec qtrle -pix_fmt rgb24
ffmpeg -i -vcodec rawvideo -pix_fmt uyvy422 -vtag 2vuy 

combine jpg's with existing mjpeg movie (on Windows)

@echo off
cd /d %0\..
if exist clouds-queue\*.jpg (
  cat clouds-queue/*.jpg | ffmpeg -f image2pipe -vcodec mjpeg -i - -sameq -s 2048x1024 -f mjpeg -vcodec mjpeg -y
  ffmpeg -f mjpeg -i concat:"|" -c copy -y
if exist (
  move clouds-queue\*.jpg clouds-done\

in case of segmentation faults you might need to add -vcoded

ffmpeg -i -sameq -s 512x256 -vcodec mpeg4

combine multiple movies with ffmpeg

ffmpeg -f mjpeg -i <\
(  ffmpeg -v 0 -i -f image2pipe -vcodec copy -y /dev/stdout;
  ffmpeg -v 0 -i -f image2pipe -vcodec copy -y /dev/stdout;
  ffmpeg -v 0 -i -f image2pipe -vcodec copy -y /dev/stdout;
) -vcodec copy -an -y
stty echo

add non-sequence images to movie with cat and ffmpeg

cat 2012050412*.jpg | ffmpeg -v 0 -f image2pipe -vcodec mjpeg -i  - -sameq -vcodec mjpeg -y

add new frames / image files to an existing mjpeg movie with ffmpeg

ffmpeg -f mjpeg -i <\
(  ffmpeg -v 0 -i -f image2pipe -vcodec copy -y /dev/stdout;
  cat clouds-queue/*.jpg | ffmpeg -v 0 -f image2pipe -vcodec mjpeg -i  - -sameq -vcodec mjpeg -f mjpeg -y -s 1024x512 /dev/stdout;
) -vcodec copy -an -y
mv clouds-queue/*.jpg clouds-done/

losse plaatjes omzetten naar filmpje met framerate en veel keyframes

ffmpeg -f image2 -r 1 -i frame-%04d.png -r 5 -g 1 -y -sameq -s 1024x512

output framerate 10, keyframe on everyframe

ffmpeg -i -r 10 -g 1 -sameq -y

-r 1 sets input framerate to 1

ffmpeg -r 1 -i image-%d.PNG -sameq -g 1 -y

convert movie to iPad

ffmpeg -i -acodec libfaac -ac 2 -ab 160k -s 1024x768 -vcodec libx264 -vpre slow -vpre ipod640 -b 1200k -f mp4 -threads 10 output.mp4

convert image sequence to movie

ffmpeg -f image2 -i frame%03d.png -s 1024x512

convert movie from canon ixus to mpeg

ffmpeg -i MVI_0131.AVI -r 25 -sameq

rotate movie (with memcoder)

mencoder -vf rotate=1 -o OUTPUT.AVI -oac copy -ovc lavc MVI_7590.AVI 

Remove audio from a movie

ffmpeg -i -an

Combine jpg and mp3 audio to mpg

(in this case portrait). Be sure to use RGB jpg's instead of CMYK.

ffmpeg -y -i vogels.jpg -loop_input -i vogels.mp3 -s 320x480 vogels320x480.mpg
ffmpeg -y -b 2500k -r 30 -i yellow-brick-road.jpg -i brand-new-day.mp3 -map 0:0 -map 1:0 -vsync 1 -sameq  -vcodec mpeg4 -s 320x480 result2.mp4

crop away black side bars

ffmpeg -i -sameq -cropleft 104 -cropright 104

set start / offset time of input movie

-itsoffset needs to go before -i filename

ffmpeg -itsoffset 10 -i IMG_4699.MOV -s 640x360 -an -sameq

timelapse with ffmpeg / gstreamer

ffmpeg.txt · Last modified: 2017/06/28 12:14 by rick