janusw / Camera.Maui

A CameraView Control for .NET Maui
MIT License
17 stars 3 forks source link

Is it possible to record video without audio? #14

Open tpgalan opened 4 months ago

tpgalan commented 4 months ago

I'm just wondering if this is possible.

I've tried to comment out the lines:

if (cameraView.NumMicrophonesDetected > 0)
                    cameraView.Microphone = cameraView.Microphones.First();

but still recording audio...

Any thoughts?

Thanks

janusw commented 4 months ago

Should be possible, I guess.

The relevant line is probably this one for Android: https://github.com/janusw/Camera.Maui/blob/b6b36830b8456a2d034a14b2e209c0303da565a5/Camera.MAUI/Platforms/Android/MauiCameraView.cs#L177

And this one for iOS: https://github.com/janusw/Camera.Maui/blob/b6b36830b8456a2d034a14b2e209c0303da565a5/Camera.MAUI/Apple/MauiCameraView.cs#L143

TFreudi1 commented 2 months ago

I m also interested in taking a video without audio, maybe as optional Parameter in StartRecordingAsync.

janusw commented 2 months ago

PR #24 should allow recording without audio. @tpgalan @TFreudi1 Can you please test this and tell me if it works for you (and on which platform you tested)?

TFreudi1 commented 2 months ago

It works great on iOS and Android. I will check it on Windows on Monday in my Office.

janusw commented 2 months ago

It works great on iOS and Android. I will check it on Windows on Monday in my Office.

Awesome, thanks! I will merge it as soon as you confirm that Windows works as well.

TFreudi1 commented 2 months ago

Sorry but it did'nt work in Windows with a USB WEB Cam, it still recorded the sound. Same code like ios/Android, I only changed the target. Also I only have a Mac-Mini but will get a Mac Book for testig this under Mac Catalyst end of the week.

TFreudi1 commented 2 months ago

But I found something that works! I'm not so experienced in pull request stuff. What works under windows is adding 2 lines arround row 197 in platforms/windows/MauiCameraView.cs save_video_with_no_audio_win

if (withAudio && cameraView.Microphone != null) mcis.AudioDeviceId = cameraView.Microphone.DeviceId; else { mcis.AudioDeviceId = null; mcis.StreamingCaptureMode = StreamingCaptureMode.Video; }

TFreudi1 commented 2 months ago

save_video_with_no_audio_win Just tested further , only the one line that sets the streaming mode to video-only is enough: ` mcis.StreamingCaptureMode = StreamingCaptureMode.Video;

janusw commented 2 months ago

Sorry but it did'nt work in Windows with a USB WEB Cam, it still recorded the sound. [..] But I found something that works!

Nice, thanks for looking into that. I'll add it to the PR ...