Score:2

What is the right parameter for ffmpeg to record audio+video simultaneously?

in flag

I have been searching the internet on how to record a streaming playback with video and audio. I found this recipe:

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 -f pulse -ac 2 -i default recording.mkv

Probably one of the -i parameters was wrong: The shown command gives me only a recording of the video channel, the sound is missing.

Earlier, searching for a recipe fro a pure audio recording, I was told to look at the output of

pactl list short sources

which is

0   alsa_output.pci-0000_00_1b.0.analog-stereo.monitor  module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
1   alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.analog-stereo.monitor   module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED
2   alsa_input.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.multichannel-input   module-alsa-card.c  s16le 1ch 48000Hz   SUSPENDED

and substitute the finding for the ALSA output device. Therefore I substituted alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.analog-stereo.monitor into the command

ffmpeg -f pulse -i alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.analog-stereo.monitor -ac 2 recording.mp3

and I was able to make a recording of a pure audio playback with it.

I applied a similar modification to my first trial command:

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 \
-f pulse -ac 2 \
-i alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.analog-stereo.monitor \
recording.mkv

But again this gave me only a silent recording. My command was definitely not the right one, although I heard the sound on the headset during the recording, but not after it on playback.

What would be the right command to make an audio+video recording?

maxwatt avatar
id flag
Try to take a look at the following ffmpeg mailing-list answer: [http://ffmpeg.org/pipermail/ffmpeg-user/2020-January/046447.html](http://ffmpeg.org/pipermail/ffmpeg-user/2020-January/046447.html) Also, take a look here: [https://superuser.com/questions/731575/record-audio-and-video-by-using-ffmpeg](https://superuser.com/questions/731575/record-audio-and-video-by-using-ffmpeg)
Score:0
iq flag

Your problem is that you are putting the -i flag for the audio source directly, put it after the input format -f pulse

Here would be your command ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 -f pulse -ac 2 -i default -c:v libx264 -c:a aac -strict experimental recording.mkv

If you want to use specific audio replace default with the source you want.

Also this command would records video from the screen with the specified size and framerate, records audio from the specified audio source, and saves the output in an MKV file with H.264 video codec and AAC audio codec:

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0 -f pulse -ac 2 -i alsa_output.usb-Sennheiser_Communications_Sennheiser_USB_headset-00.analog-stereo.monitor -c:v libx264 -c:a aac -strict experimental recording.mkv
in flag
Thank you for your answer. The second example gives me a silent recording. Fortunately the first one works, but the sound level is very low and there is quit a bit of noise, if I increase the playback volume to the max. Is there some parameter to increase the audio volume during recording?
in flag
Thank you for explaining why my original attempt did not work and for the choices you made in your example. They were very instructive. - I just made a second attempt by setting the playback volume in `pavucontrol` to maximum (153%, which is way too much for my headphones, even with the potentiometer in the connecting cable at minimum). So I could make a recording with reasonable volume. But the audio quality is much lower than when playing the original. I assume there is a way to somehow adjust the recording volume and record with even better audio quality and hope for a hint about it.
Score:0
eg flag

ffmpeg -s 1920x1080 -framerate 25 -f x11grab -i :0.0 -f pulse -i 0 file.mp4

If you want to record mic's audio use -f pulse -i 1 instead of 0 in the above command

in flag
I tried your command. I got the video, but no audio in it. I also tried the other version with `-f pulse -i 1`, but it also did not record the sound from my microphone.
daGo avatar
eg flag
after invoking the command open another terminal and type `pavucontrol` (Pulse Audio) navigate to Recording where should be toggleable option to chose between audio sources. If none of these options don't produce audio in captured with ffmpeg video idk what to say.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.