Yours is a PPA version, which is most probably similar to the official version. See below, from Precise (Ubuntu 12.04):
$ dpkg --list ffmpeg
ii ffmpeg 4:0.8.1-0ubuntu1
Multimedia player, server, encoder and transcoder (transitional package)
$ apt-cache policy ffmpeg
ffmpeg:
Installed: 4:0.8.1-0ubuntu1
Candidate: 4:0.8.1-0ubuntu1
$ ffmpeg
ffmpeg version 0.8.1-4:0.8.1-0ubuntu1, Copyright (c) 2000-2011 the Libav developers
built on Mar 22 2012 05:09:06 with gcc 4.6.3
.....
To reinstall the official version over the PPA version, you can either use the ppa-purge
script (install that first!), or if you have already deleted the PPA, use
sudo apt-get install ffmpeg=4:0.8.1-0ubuntu1
You may have to throw a --reinstall
switch in there if it fails.
You can do this with v4l2loopback. First you need to install it:
Install v4l2loopback
Method 1: Install v4l2loopback from the repository
sudo apt install v4l2loopback-dkms
sudo modprobe v4l2loopback
This is easy but older versions of v4l2loopback have some known bugs, so consider compiling it instead if you encounter any issues.
Method 2: Compile v4l2loopback
If it's not in the repository for your Ubuntu version, or you want the latest version, you can compile it:
sudo apt-get install build-essential checkinstall
wget https://github.com/umlaeute/v4l2loopback/archive/main.zip
unzip main.zip
cd v4l2loopback-main
make
sudo checkinstall --pkgname=v4l2loopback --pkgversion="$(date +%Y%m%d%H%M)-git" --default
sudo modprobe v4l2loopback
Uninstalling
If you want to remove the package you compiled:
sudo apt-get remove v4l2loopback
Examples
Note that the actual video
number may vary depending if an existing device is already using /dev/video0
. Check output of ls /dev/video*
or v4l2-ctl --list-devices
.
Desktop to virtual camera
Now run ffmpeg
. Example for desktop using x11grab:
ffmpeg -f x11grab -framerate 15 -video_size 1280x720 -i :0.0 -f v4l2 /dev/video0
Video file (MP4) to virtual camera
ffmpeg -re -i input.mp4 -map 0:v -f v4l2 /dev/video0
Image to virtual camera
ffmpeg -re -loop 1 -i input.jpg -vf format=yuv420p -f v4l2 /dev/video0
Webcam → ffmpeg → Virtual webcam
Add text
With drawtext filter:
ffmpeg -f v4l2 -i /dev/video0 -vf "drawtext=text='Hello World':fontsize=12:fontcolor=white:font=Arial:x=w-tw-10:y=h-th-10,format=yuv420p" -f v4l2 /dev/video1
See How to position drawtext text?
Greenscreen / chroma key / replace background
Using chromakey, overlay, and format filters:
ffmpeg -re -i background.jpg -f v4l2 -i /dev/video0 -filter_complex "[1]chromakey=color=#326964:similarity=0.07:blend=0.02[fg];[0][fg]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:format=auto,format=yuv420p" -f v4l2 /dev/video1
See How to position overlay?
Preview with ffplay
ffplay /dev/video0
Common errors
- Unable to open V4L2 device '/dev/video0'
- Failed to open /dev/video0: No such file or directory
- Unknown V4L2 pixel format equivalent for yuvj422p
See this answer for solutions.
Best Answer
Looks like Audacity will actually build against ffmpeg-0.10.12. I have written it all up here:
Audacity under Trusty Tahr: Building it with FFmpeg http://ubuntuforums.org/showthread.php?t=2219907
Test it out and let me know if it all works out...