Cover banner image for fixing FFmpeg 'could not find device with name' dshow Error on Windows

FFmpeg is an open-source utility that is widely regarded as the swiss-army knife of audio and video manipulation. While many tend to use software such as OBS Studio or other desktop capture programs to record the desktop and system audio, I have always preferred using FFmpeg as it is more lightweight. Additionally, FFmpeg gives me full control on what I want to do, and I can use FFmpeg itself to edit the recording instead of relying on other applications.

Backstory

On Tuesday, I had to record some audio from the microphone and I happened to be on Windows instead of Linux. I opened the Command Prompt and launched FFmpeg to start capturing the microphone audio. Previously, I had never tried recording the microphone audio using FFmpeg on Windows.

First, I used the command below to get the device name of the microphone:

ffmpeg -list_devices true -f dshow -i dummy

This displayed all the devices with recording capabilities. I needed the integrated microphone which was Microphone Array (Intel® Smart Sound Technology for Digital Micophones) in my case.

List DirectShow (dshow) devices in FFmpeg

Now that I got the device name of the microphone, I ran the following command in the Windows Command Prompt to start the recording process:

ffmpeg -hide_banner ^
-thread_queue_size 4096 -f dshow ^
-i audio="Microphone Array (Intel® Smart Sound Technology for Digital Micophones)" ^
-c:a aac -b:a 128k -ac 2 ^
-movflags frag_keyframe recording.m4a

I expected FFmpeg to start recording audio from the microphone, but instead FFmpeg complained that the device name is invalid: could not find audio only device with name [Microphone Array (Intel® Smart Sound Technology for Digital Micophones)] among source devices of type audio.

Error when listing DirectShow (dshow) devices in FFmpeg

I was puzzled as the microphone’s device name in the error message was exactly the same as in the list of DirectShow (dshow) devices obtained above, except for one character. It caught my attention that the characer ‘®’ was substituted by another one, even though this was not the case in the command that I launched in the Command Prompt.

Solution

My first hunch was that Unicode characters are not supported by FFmpeg. This hypothesis turned out to be wrong when a web search revealed that FFmpeg does have support for Unicode characters. The culprit was actually Windows Command Prompt which lacks support for Unicode characters, resulting in the special character ‘®’ to be substituted by another one when the command is executed.

I thought to myself that I should probably try it in Windows PowerShell instead. Unfortunately, I had the same experience. Just when I was about to give up and boot on Linux, I came across an interesting find :

chcp <code_page>: Changes the active console code page

Turns out, there’s a Windows command chcp that enables us to change the code page of the current console! I looked for UTF-8 in the table and the corresponding code was 65001.

I immediately tried it by creating a batch file called record.bat with the following contents:

@echo off

chcp 65001

ffmpeg -hide_banner ^
-thread_queue_size 4096 -f dshow ^
-i audio="Microphone Array (Intel® Smart Sound Technology for Digital Micophones)" ^
-c:a aac -b:a 128k -ac 2 ^
-movflags frag_keyframe recording.m4a

Then, I executed the record.bat batch file by double clicking it. This time FFmpeg launched normally and I could see the status of the recording process 🎉.

This little experiment turned out to be very rewarding. I got to learn a new command on Windows, chcp, which I never knew existed. The amount of unexpected things that one learns when doing things differently is incredible.

# Footnotes

https://trac.ffmpeg.org/wiki/DirectShow

https://ss64.com/nt/chcp.html