6
ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv

I use this command and I have two questions:

  1. My screen allows full-hd, but seems like output.mkv in bad (not full-hd) quality. How to record screen in the best quality?

  2. My command doesn't record audio. How to record audio too?

2 Answers 2

8
+50

If you want your computer's audio to be recorded along with your screen at full resolution, rather than your microphone, (the question was unclear as to which one you wanted) follow these instructions:

The device 'Stereo Mix (Realtek Audio)' probably needs to be enabled, in my case, it wasn't.

Stereo mix is what allows you to record your computer's audio in Windows.

  1. Go to control panel --> hardware and sound --> sound

  2. Then click the 'recording' tab.

  3. Now right click inside the device list and make sure that 'show disabled devices' is ticked. Stereo Mix should then show up.

  4. Now right click it and select 'enable'.

Note that Stereo Mix's full name is 'Stereo Mix (Realtek Audio)'

Now, to record your audio and pc screen at full resolution, you would type:

ffmpeg -f gdigrab -framerate 30 -i desktop -c:v libx264 output.mkv -f dshow -i audio="Stereo Mix (Realtek Audio)" output.mkv

Also note that if you have multiple sound devices (i.e I use a laptop with a monitor - my 2 devices are system speakers and monitor speakers) make sure you have set the sound device to be your default in the volume tab (e.g. I would set my sound output to be the laptop speakers because they are my default). If you don't have multiple sound devices, then just ignore this.

You should now be able to record your screen and pc audio, if that's what you were looking for, otherwise, if you wanted your microphone to be recorded instead, see It Wasn't Me's answer.

Hope this helps

14
  • It's that's what i actually was looking. Thanks
    – Nikto
    Sep 4, 2020 at 11:51
  • I can't play output.mkv. Final output file doesn't play. There is ffmpeg log: pastebin.com/29wUD1Vy Early, stereo mix was disabled, but now i have turned on Stereo Mix.
    – Nikto
    Sep 4, 2020 at 14:40
  • thanks, but i still have some issues. 1)When i say any phrase, i don't heard it in the final output file. 2)Sound from my computer successfully records, but i made test: I had runed my command and after that i was starting watch movie. And my movie in final output file freezes If you haven't understood me, i can give you a link on example of my final output file. How to fix it? And seems like resolution of final output file is better. Thanks again.
    – Nikto
    Sep 5, 2020 at 18:43
  • And messages from ffmpeg here: Thread message queue blocking; consider raising the thread_queue_size option (current value: 8) Stream #0: not enough frames to estimate rate; consider increasing probesize Guessed Channel Layout for Input Stream #1.0 : stereo
    – Nikto
    Sep 5, 2020 at 18:47
  • To fix the thread_queue_size issue see this post: stackoverflow.com/questions/61723571/… Sep 5, 2020 at 23:37
1

1. Get microphone device name using @Leo Chapiro/answer

2>&1 ffmpeg -list_devices true -f dshow -i dummy -hide_banner|find "Micro"

rem :: outputs is your microphone device :: 
[dshow @ 000001f8ff8d8c40]  "Microphone (Realtek High Definition Audio)"

2. Add your device input with -f dshow -i audio="Microphone (Realtek High Definition Audio)" ...

ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="Microphone (Realtek High Definition Audio)" output.mkv

3. For full hd, try:

ffmpeg -f gdigrab -framerate 30 -i desktop -c:v libx264 -qp 0 output.mkv  -f dshow -i audio="Microphone (Realtek High Definition Audio)" output.mkv

Save audio="String" in variable in loop:

  • In command line:
for /f tokens^=2delims^=^" %i in ('"2>&1 ffmpeg -list_devices true -f dshow -i dummy -hide_banner|find "Micro""')do set "_mic="%~i""
  • In Bat/Cmd file:
for /f tokens^=2delims^=^" %%i in ('"2>&1 ffmpeg -list_devices true -f dshow -i dummy -hide_banner|find "Micro""')do set "_mic="%%~i""

To direct use in loop audio="String" in loop:

  • In command line:
for /f tokens^=2delims^=^" %i in ('"2>&1 ffmpeg -list_devices true -f dshow -i dummy -hide_banner|find "Micro""')do 
ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="%~i" output.mkv
  • In Bat/Cmd file:
for /f tokens^=2delims^=^" %%i in ('"2>&1 ffmpeg -list_devices true -f dshow -i dummy -hide_banner|find "Micro""')do 
ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="%%~i" output.mkv
1
  • Why are you saying to read from the microphone device? The only sounds coming in the microphone are noises in the room. I want the sounds being played by the computer.
    – Michael
    Nov 7, 2022 at 23:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .