Reputation: 21
I have a task to use ffmpeg sdk avdevice to make a function to record screen and audio into one video file. So far, I have made it support record screen and the audio from the default microphone.
However, now I have to change the code to support two microphone not just the default microphone.
Upvotes: 3
Views: 3455
Reputation: 41
I have used this for ShareX screen recording software insufficient options - You can choose one (microphone) or another (virtual audio that grabs conversation for example from Teams) and mix them together - better something like nothing - the "custom" code looks like this:
-rtbufsize 150M -f dshow -framerate 30 -i video="screen-capture-recorder" -f dshow -i audio="virtual-audio-capturer" -f dshow -i audio="Microphone (Realtek High Definition Audio)" -filter_complex "[1:0][2:0]amix=inputs=2:duration=shortest" -c:v libx265 -r 30 -preset ultrafast -tune zerolatency -crf 28 -pix_fmt yuv420p -movflags +faststart -c:a aac -ac 2 -b:a 128k -y "output.mp4"
All what I have done is, that I have removed audio from input video:audio mixed input what is generated by ShareX and added it as separate 2 filters more like in answer above.
Upvotes: 1
Reputation: 694
Other than using the ffmpeg libraries in your code. You can call ffmpeg.exe to do this. On windows this will record your screen and mix the audio from two sources to an mp4 file. I didn't get good results. The audio is off synch and or the volume is low. I believe there is an issue with mixing audio in ffmpeg.
ffmpeg.exe -y
-f dshow -i video="screen-capture-recorder"
-f dshow -i audio="virtual-audio-capturer"
-f dshow -i audio="Microphone (Realtek High Defini"
-filter_complex "[1:0][2:0]amix=inputs=2:duration=shortest"
-vcodec libx264 -preset veryfast -pix_fmt yuv420p -s 640x480 -r 15
-acodec libvo_aacenc -ab 64k -ac 2 -ar 16000 -f mp4 outputfile.mp4
Upvotes: 2