Skip to content

Instantly share code, notes, and snippets.

@ritiek

ritiek/capture.sh

Forked from kefir-/capture.sh
Last active Apr 10, 2020
Embed
What would you like to do?
Screen capture with audio and webcam overlay with microphone using ffmpeg
# $ pacmd list-sources|awk '/index:/ {print $0}; /name:/ {print $0}; /device\.description/ {print $0}'
# index: 0
# name: <alsa_output.pci-0000_00_02.0-platform-hdmi-lpe-audio.stereo-fallback.monitor>
# device.description = "Monitor of Atom Processor Z36xxx/Z37xxx Series Graphics & Display Stereo"
# index: 1
# name: <alsa_output.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__sink.monitor>
# device.description = "Monitor of Built-in Audio MonoSpeaker playback + Speaker playback + Headphones playback"
# * index: 2
# name: <alsa_input.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__source>
# device.description = "Built-in Audio Internal IN3 analog Mic capture + Internal IN1 analog Mic capture + Headset Mic capture + DigitalMics capture"
# Single merged output stream for both Pulseaudio and Mic.
ffmpeg -f x11grab -thread_queue_size 64 -video_size 1366x768 -framerate 30 -i :0 \
-f v4l2 -thread_queue_size 64 -video_size 320x180 -framerate 30 -i /dev/video0 \
-f pulse -i alsa_output.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__sink.monitor \
-f pulse -i alsa_input.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__source \
-acodec aac -strict experimental \
-filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' \
-filter_complex amerge \
-vcodec libx265 -preset ultrafast -qp 0 -pix_fmt yuv444p \
video.mkv
# Two audio streams - one for Pulseaudio and one for Mic.
ffmpeg -f x11grab -thread_queue_size 64 -video_size 1366x768 -framerate 30 -i :0 \
-f v4l2 -thread_queue_size 64 -video_size 320x180 -framerate 30 -i /dev/video0 \
-f pulse -i alsa_output.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__sink.monitor \
-f pulse -i alsa_input.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__source \
-map 2:0 -map 3:0 -acodec aac -strict experimental \
-metadata:s:a:0 title="Pulseaudio" \
-metadata:s:a:1 title="Mic" \
-filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' \
-vcodec libx265 -preset ultrafast -qp 0 -pix_fmt yuv444p \
video.mkv
# Three audio streams - one for Pulseaudio and one for Mic, and third with previous two merged.
ffmpeg -f x11grab -thread_queue_size 64 -video_size 1366x768 -framerate 30 -i :0 \
-f v4l2 -thread_queue_size 64 -video_size 320x180 -framerate 30 -i /dev/video0 \
-f pulse -i alsa_output.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__sink.monitor \
-f pulse -i alsa_input.platform-bytcr_rt5640.HiFi__hw_bytcrrt5640__source \
-acodec aac -strict experimental \
-map 2:0 -map 3:0 -map '[a]' \
-filter_complex 'overlay=main_w-overlay_w:main_h-overlay_h:format=yuv444' \
-filter_complex 'amerge=inputs=2[a]' \
-metadata:s:a:0 title="Pulseaudio" \
-metadata:s:a:1 title="Mic" \
-metadata:s:a:2 title="Pulseaudio & Mic" \
-vcodec libx265 -preset ultrafast -qp 0 -pix_fmt yuv444p \
video.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.