Ffmpeg recording with camera overlay on OSX

I would like to use ffmpeg to record my desktop as well as my camera as an overlay on top of the desktop.

So basically I will have two input sources that need to be written

$ ffmpeg -f avfoundation -list_devices true -i '' [AVFoundation input device @ 0x7fded1c223e0] AVFoundation video devices: [AVFoundation input device @ 0x7fded1c223e0] [0] FaceTime HD Camera [AVFoundation input device @ 0x7fded1c223e0] [1] Capture screen 0 [AVFoundation input device @ 0x7fded1c223e0] AVFoundation audio devices: [AVFoundation input device @ 0x7fded1c223e0] [0] Built-in Microphone 

From the above, I need [0] FaceTime HD Camera as an overlay and [1] Capture screen 0 as the main video.

Is it possible?

UPDATE (2015-10-06):

I found the following command from ffscreencast :

 ffmpeg \ -f avfoundation -i "1" \ -f avfoundation -r 30 -video_size 640x480 -i "0" \ -c:v libx264 -crf 0 -preset ultrafast \ -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' "out.mkv" 

Unfortunately, the output has a rather slow frame rate (i7 Macbook Pro 2014)

 Output #0, matroska, to 'out.mkv': Metadata: encoder : Lavf56.40.101 Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 3840x2400, q=-1--1, 1000k fps, 1k tbn, 1000k tbc (default) Metadata: encoder : Lavc56.60.100 libx264 Stream mapping: Stream #0:0 (rawvideo) -> overlay:main Stream #1:0 (rawvideo) -> overlay:overlay overlay -> Stream #0:0 (libx264) frame= 756 fps=9.1 q=-1.0 Lsize= 193660kB time=00:01:21.86 bitrate=19378.5kbits/s Press [q] to stop, [?] for help 

Does anyone know how to get a higher frame rate? My camera can only record at 30 frames per second, but the output, it seems, is only about 9 frames. Why is the difference?

+7
ffmpeg avfoundation screen-capture macos camera-overlay
source share
1 answer

This works for me, ffmpeg version 2.8:

 ffmpeg -thread_queue_size 50 \ -f avfoundation -framerate 30 -i "1" \ -thread_queue_size 50 -f avfoundation -framerate 30 -video_size 640x480 -i "0" \ -c:v libx264 -crf 18 -preset ultrafast \ -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' -r 30 ~/Desktop/out.mkv 

NOTE: I read in the documentation that the -r option is for output, so you are in the wrong place on your command. The "-crf" value that you give seems exaggerated if the documentation states that the value 18 is lossless video. You will also probably have to play with the value "-thread_queue_size" for your particular system.

+9
source share

All Articles