I have the latest version of ffmpeg installed in Ubuntu 16.04, and I can output video to a virtual device using different commands.

For example:

ffmpeg -f x11grab -framerate 15 -video_size 1280x720 -i :0.0 -f v4l2 /dev/video0 -> with this one I can capture the entire screen and output it to /dev/video0 (my virtual camera)
ffmpeg -re -i input.mp4 -map 0:v -f v4l2 /dev/video0 -> I can also use this one with a video file
ffmpeg -re -i /dev/video1 -map 0:v -f v4l2 /dev/video0 -> I've also been able to use this one where I can capture from /dev/video1(which is a real web camera) and output it to the virtual camera.
ffmpeg -f x11grab -r 12 -s 1920x1080 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 -vf 'scale=800:600' /dev/video22

FFmpeg Cheat Sheet for 360º video

Brought to you by HeadjackFFmpeg is one of the most powerful tools for video transcoding and manipulation, but it’s fairly complex and confusing to use. That’s why I decided to create this cheat sheet which shows some of the most often used commands.
Let’s start with some basics:

ffmpeg calls the FFmpeg application in the command line window, could also be the full path to the FFmpeg binary or .exe file

-i is follwed by the path to the input video

-c:v sets the video codec you want to use
Options include libx264 for H.264, libx265 for H.265/HEVC, libvpx-vp9 for VP9, and copy if you want to preserve the video codec of the input video

-b:v sets the video bitrate, use a number followed by M to set value in Mbit/s, or K to set value in Kbit/s

-c:a sets the audio codec you want to use Options include aac for use in combination with H.264 and H.265/HEVC, libvorbis for VP9, and copy if you want to preserve the audio codec of the input video

-b:a sets the audio bitrate of the output video

-vf sets so called video filters, which allow you to apply transformations on a video like scale for changing the resolution and setdar for setting an aspect ratio

-r sets the frame rate of the output video

-pix_fmt sets the pixel format of the output video, required for some input files and so recommended to always use and set to yuv420p for playback

-map allows you to specify streams inside a file

-ss seeks to the given timestamp in the format HH:MM:SS

-t sets the time or duration of the output

Get video info

ffmpeg -i input.mp4

Transcode video

The simplest example to transcode an input video to H.264:

ffmpeg -i input.mp4 -c:v libx264 output.mp4

However, a more reasonable example, which includes setting an audio codec, setting the pixel format and both a video and audio bitrate, would be:

iOS 11 and OSX 11 now support HEVC playback, but you have to make sure you use FFmpeg 3.4 or higher, and then add -tag:v hvc1 to your encode, or else you won’t be able to play the video on your Apple device.

For VP9 we have to change both the video and the audio codec, as well as the file extension of the ouput video. We also added -threads 16 to make sure FFmpeg uses multi-threaded rendering to speed things up significantly:

You may have noticed we also halved the video bitrate from 30M for H.264 to 15M for H.265/HEVC and VP9. This is because the latter ones are advanced codecs which output the same visual quality video at about half the bitrate of H.264. Sweet huh! They do take way longer to encode though and are not as widely supported as H.264 yet.Hardware accelerated encoding

We just saw how to encode to H.264 using the libx264 codec, but the latest Zeranoe FFmpeg builds for Windows now support hardware accelerated encoding on machines with Nvidia GPUs (even older ones), which significantly speeds up the encoding process. You use this powerful feature by changing the libx264 codec to h264_nvenc:

ffmpeg -i input.mp4 -c:v h264_nvenc output.mp4

To use hardware acceleration for H.265/HEVC, use hevc_nvenc instead:

ffmpeg -i input.mp4 -c:v hevc_nvenc output.mp4

If you get any error messages, either your FFmpeg version or your GPU does not support hardware acceleration, or you are using an unsupported -pix_fmt. There is unfortunately no hardware acceleration support in FFmpeg for the VP9 codec.

We noticed one strange artefact when using h264_nvenc and hevc_nvenc in combination with scaling. For example, when we scaled a 4096×4096 video down to 3840×2160 pixels, the height of the output video showed correctly as 2160 pixels, but the stored_height was 2176 pixels for some reason, which causes issues when trying to play it back on Android 360º video players.Resize video to UHD@30fps

At the moment, the most common playback resolution for 360º video is the UHD resolution of 3840x2160 at 30 frames per second. The commands we have to add for this are:

You could add the -shortest command to force the output video to take the length of the shortest input file if the input audio file and the input video file are not exactly the same lengthSequence to video

Many high-end video pipelines work with DPX, EXR or TIFF sequences. To transform these sequences into video files, the easiest way is to specify the first file in the sequence as the input and then use -framerate to set the input frame rate and -r to set the output frame rate:

The above command seeks to 1.32 minutes in the video, and then outputs the next 10 seconds. As you can see, -ss is placed before the -i command, which results in way faster (but slightly less accurate) seeking.Concatenate two videos

Concatenation is not possible with all video formats, but it works fine for MP4 files for example. There are a couple of ways to concatenate video files, but I will only describe the way that worked for me here, which requires you to create a txt file with the paths to the files you want to concatenate.

Only if the files you want to concatenate have the exact same encoding settings can you concatenate without re-encoding:

ffmpeg -f concat -i files.txt -c copy output.mp4

In the files.txt file, place urls to the files you want to concatenate:

You can add -safe 0 if you are using absolute paths. If you miss some frames after concatenation, keep in mind that the concatenation happens on I-frames, so if you don’t cut at exactly the right frame, FFmpeg will discard all frames up to the nearest I-frame before concatenating.