ffmpeg FFmpeg

Overview

FFmpeg is a free and open-source software project consisting of a large suite of libraries and programs for handling video, audio, and other multimedia files and streams.

Samples

  • Multi size encoding

> ffmpeg -i Arromanches.mp4 \
  -threads 0 -preset ultrafast -s 800x480 -c:v libx264 -c:a mp3 Arromanches_480p.mp4 \
  -threads 0 -preset ultrafast -s 640x360 -c:v libx264 -c:a mp3 Arromanches_360p.mp4 \
  -threads 0 -preset ultrafast -s 320x240 -c:v libx264  -c:a mp3 Arromanches_240p.mp4

Videos
├── [ 407M]  Arromanches_240p.mp4
├── [1008M]  Arromanches_360p.mp4
├── [ 1.5G]  Arromanches_480p.mp4
└── [ 8.7G]  Arromanches.mp4
  • create audio/video samples

> ffmpeg -i RocknSoul_Mix.mp3 -ss 00:03:00 -t 10 -acodec copy copy_sample_10s.mp3
> ffmpeg -i RocknSoul_Mix.mp3 -ss 00:03:00 -t 10 copy_sample_10s.ogg
> ffmpeg -i Arromanches_240p.mp4 -ss 00:02:20 -t 10 -acodec copy -vcodec copy copy_arromanches_10s.mp4
> ffmpeg -i Arromanches_240p.mp4 -ss 00:02:20 -t 10 -acodec libvorbis -vcodec libx264 copy_arromanches_10s.mp4
  • burnt in Timecode

> ffmpeg -i ../Videos/Arromanches.mp4 -vf \
  "drawtext=fontfile=/usr/share/fonts/truetype/DroidSans.ttf: timecode='00\:00\:00\:00': \
  r=59.94006: x=(w-tw)/2: y=h-(2*lh): fontcolor=yellow: box=1: boxcolor=0x00000000@1" \
  -acodec libvorbis -vcodec libx264 Arromanches_h264_240p_tc.mp4

> ffmpeg -i Arromanches.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/DroidSans.ttf: \
  timecode='00\:00\:00\:00': r=59.94006: x=(w-tw)/2: y=h-(2*lh): fontcolor=yellow: box=1: \
  boxcolor=0x00000000@1" -ss 00:02:20 -t 10 -acodec libvorbis -vcodec libx264 -an -y copy_arromanches_10s.mp4

> ffmpeg -i ../Videos/Arromanches.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/DroidSans.ttf: \
  fontsize=56: timecode='00\:00\:00\:00': r=59.94006: x=(w-tw)/2: y=h-(2*lh): fontcolor=yellow: box=1: \
  boxcolor=0x00000000@1" -s 320x240 -acodec libvorbis -vcodec libx264 Arromanches_h264_240p_tc.mp4

Stream Webcam

> v4l2-ctl --list-devices
> v4l2-ctl -d /dev/video0 --list-formats-ext
> v4l2-ctl --all

> ffmpeg -f v4l2 -i /dev/video0 -vcodec libx264 -r 5 \
  -b:v 1024k -s 320x240 -f mpegts -preset ultrafast \
  "udp://192.168.0.16:5555?pkt_size=1316"