Open Hemesh-S opened 1 year ago
Does the ffmpeg
command access your webcam successfully?
Some helpful commands:
# List devices provided using AVFoundation in MacOS
ffmpeg -f avfoundation -list_devices true -i ""
# And then try to capture some video
ffmpeg -f avfoundation -i "0:" output.mp4
Hi thank you for your feedback, I have tried the suggested commands, and it does list the webcam under the video devices
However, when I try to run the capture video command I get the following error
It does request access to the camera though and I allow it.
I have then set the framerate in the command and it worked like below
ffmpeg -f avfoundation -framerate 30 -i "0:" output.mp4
When I tried to do the same in code in FFmpegCameraSource.cs it did not work
Can you advise further?
Hmm, can you enable the FFmpeg logger on AV_LOG_TRACE
?
Some helpful code:
// Use Microsoft.Extensions.Logging package
ILoggerFactory logfactory = LoggerFactory.Create(config => {
// Use Microsoft.Extensions.Logging.Console package
config.AddSimpleConsole().SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
});
// Initialise FFmpeg librairies
FFmpegInit.Initialise(
logLevel: FfmpegLogLevelEnum.AV_LOG_TRACE,
appLogger: logfactory.CreateLogger("FFMPEG Log"));
Thank you for the suggestions, I have done so and this is how the log looks just after crashing once it hits if (ffmpeg.avformat_open_input(&pFormatContext, _sourceUrl, _inputFormat, &options) < 0)
in FFmpegVideoDecoder
It only seems to be with a camera source though, screen and file do not have this issue.
Okay, it seems because of the default behavior of FFMPEG, seems it fails to get the correct supported mode.
If you can find a way to retrieve the "Supported Modes" of the device and then use the first one as the option "framerate", then it should be able to open the decoder context.
I don't have a MacOS ready, I can't test the suggested solution.
Also to you give authorization to your app to have access to video devices ? On Mac you have often trouble about security to access devices (audio and video)
Hi, a great library for use within MacOS and WebRTC.
I am trying to run the example project FFmpegFileAndDevicesTest.
It works fine when pointing to the external video source file, however, when I switch the source to use my Mac camera, it cannot get the path. It does get the list of cameras and selects the correct one with the correct name, but the path is returned as "0:"
Is there a way to resolve this?
I have installed all the relevant FFMPEG libraries and dependencies on my Mac, via homebrew.
After which the application crashes when trying hitting the InitialiseDecoder() method in the FFmpegCameraSource class, specifically on the if (ffmpeg.avformat_open_input(&pFormatContext, _sourceUrl, _inputFormat, &options) < 0) in the FFmpegVideoDecoder class.