DirectShow Capture support

Announcements made by users.
zamar24
Posts: 9
Joined: Sun Apr 19, 2015 6:20 am

Re: DirectShow Capture support

Post by zamar24 » Sun Apr 19, 2015 9:19 pm

Looking at this thread, various FFMPeg Wiki pages, bug reports, rogerdpack's own blog, and other resources, it looks like he's the main contributor to Dshow webcam support project. That wouldn't be possible without playing with own webcam(s). I don't have an advanced webcam now, but can borrow a regular one. Truly appreciate Roger's contribution to this public project!

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DirectShow Capture support

Post by rogerdpack » Mon Apr 20, 2015 2:49 pm

zamar24 wrote:I own several Logi webcams, and also feel that Dshow support is incomplete now, for example:

- no command to print only default webcam video, audio, and still image formats data

- no or unknown command to print list of supported still image formats

- the command to print available audio formats gives incomplete list of supported audio sampling rates, and no list of audio stream container formats

Is it possible to add such support to FFMpeg Dshow?
you can find the default by just "running it" like
ffmpeg -f dshow -i video=XXX

(it will fail out, after printing defaults).

Supported image formats is basically https://github.com/FFmpeg/FFmpeg/blob/d ... /raw.c#L31

I'm not sure what you mean by audio container format, it appears that it only recognizes "raw" audio, like


static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt)
{
switch (sample_fmt) {
case AV_SAMPLE_FMT_U8: return AV_CODEC_ID_PCM_U8;
case AV_SAMPLE_FMT_S16: return AV_CODEC_ID_PCM_S16LE;
case AV_SAMPLE_FMT_S32: return AV_CODEC_ID_PCM_S32LE;
default: return AV_CODEC_ID_NONE; /* Should never happen. */
}
}

static enum AVSampleFormat sample_fmt_bits_per_sample(int bits)
{
switch (bits) {
case 8: return AV_SAMPLE_FMT_U8;
case 16: return AV_SAMPLE_FMT_S16;
case 32: return AV_SAMPLE_FMT_S32;
default: return AV_SAMPLE_FMT_NONE; /* Should never happen. */
}
}

I would be quite interested in testing with other devices that do anything like mp3 or aac encoding for us.
In terms of "does it advertise the right values" I'm not sure,

Could you tell me what those audio pins "advertise" by adding that filter to a graph and right clicking on the audio pins? https://code.google.com/p/graph-studio-next/

also https://obsproject.com/forum/threads/if ... ad-here.59 "dshowpinsandcaps2"

Cheers!

zamar24
Posts: 9
Joined: Sun Apr 19, 2015 6:20 am

Re: DirectShow Capture support

Post by zamar24 » Tue Apr 21, 2015 5:40 am

Could you tell me what those audio pins "advertise" by adding that filter to a graph and right clicking on the audio pins? https://code.google.com/p/graph-studio-next/
Attachments
C920 DirectShow Graph.jpeg
C920 Video Graph
C910_Graphs.zip
(7.53 KiB) Downloaded 151 times

zamar24
Posts: 9
Joined: Sun Apr 19, 2015 6:20 am

Re: DirectShow Capture support

Post by zamar24 » Tue Apr 21, 2015 1:35 pm

Another issue is multiple webcams support. Many people want to stream over web or record footage of multiple same model webcams simultaneously. There are many threads on Logitech, OBS and other relevant forums about it. Sport educators, artists, hobbyists love multiple webcams, and some use open source packages like Kinovea based on FFMpeg that fully depend and rely on FFMpeg Dshow support.

What such CML would look like, given the fact that all such webcam sources are named the same in OS? If Dshow can't do it now, this feature is highly desirable to add - like an option to enter webcam video & audio & still picture pin GUIDs instead of its filter names or such.

It would give tremendous benefit if native compressed formats from all webcams can be captured and recorded simultaneously, since transcoding several streams at once is very hard work for a typical PC. Especially important since 1080P H264 streaming C920 webcam can now be purchased used for $45-50 on Ebay, so many folks do that.

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DirectShow Capture support

Post by rogerdpack » Thu Apr 30, 2015 3:48 pm

zamar24 wrote:I own several Logi webcams, and also feel that Dshow support is incomplete now, for example:

- no command to print only default webcam video, audio, and still image formats data

- no or unknown command to print list of supported still image formats

- the command to print available audio formats gives incomplete list of supported audio sampling rates, and no list of audio stream container formats

Is it possible to add such support to FFMpeg Dshow?
Maybe if there were remote access to these somehow?

dttlgotv
Posts: 11
Joined: Wed May 06, 2015 7:03 am

Re: DirectShow Capture support

Post by dttlgotv » Wed May 06, 2015 7:07 am

These days I am using virtual-audio-capture. And I finn an issue.

I used ffmpeg command line to record the speaker audio well.
command like:
    >ffmpeg -f dshow -i audio="virtual-audio-capturer" gxh.wav

But after I write ffmpeg codes to record the speaker sound, it listen very very badly.  avformat_open_input and av_read_frame can be called well. But the capture buffer listen very badly.

So can you give me some hint?

thanks a lot.

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DirectShow Capture support

Post by rogerdpack » Wed May 06, 2015 10:46 am

dttlgotv wrote:These days I am using virtual-audio-capture. And I finn an issue.

I used ffmpeg command line to record the speaker audio well.
command like:
    >ffmpeg -f dshow -i audio="virtual-audio-capturer" gxh.wav

But after I write ffmpeg codes to record the speaker sound, it listen very very badly.  avformat_open_input and av_read_frame can be called well. But the capture buffer listen very badly.

So can you give me some hint?

thanks a lot.
Could you open a new thread for this? Thanks!

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DirectShow Capture support

Post by rogerdpack » Wed May 06, 2015 11:08 am

sambul92 wrote: As to capturing video and still images for preview, I couldn't make C910 output them simultaneously, but still frames can be captured from video stream with T-splitter or parallel processing. And what's the command to list available formats for Still Image Capture pin?

Also, what's the proper command to list default webcam output formats for all pins? The command

Code: Select all

ffmpeg -f dshow -list_options true -i video="Logitech HD Pro Webcam C910"
lists ALL output options available, while in Linux the following command prints only defaults

Code: Select all

v4l2-ctl --get-fmt-video
Another thing that looks like Dshow bug is audio formats listing. Here is console output:

Code: Select all

ffmpeg -f dshow -list_options true -i audio="Microphone (HD Pro Webcam C910)"
[dshow @ 02ccc200] DirectShow audio only device options (from audio devices)
[dshow @ 02ccc200] Pin "Capture" (alternative pin name "Capture")
[dshow @ 02ccc200] min ch=1 bits=8 rate= 11025 max ch=2 bits=16 rate= 44100
Last message repeated 22 times
audio=Microphone (HD Pro Webcam C910): Immediate exit requested
It shows max 44.1khz sampling rate, and no output format. But VirtualDub gives a lot more detail audio output, maxes out at 96kHz, gives PCM audio format. AMCap maxes out at 48kHz audio. VirtualDub and Dshow video resolution lists for C910 match, of course Dshow names formats in Linux way. When I try to set -sample_rate 48000 for audio capture, the error pops up, but with -sample_rate 41100 it works OK.

Code: Select all

[dshow @ 02b381c0] Could not find audio only device with name [Microphone (HD Pro Webcam C910)] among source devices of type video.
video=Logitech HD Pro Webcam C910:audio=Microphone (HD Pro Webcam C910): Input/output error
It's not immediately clear (read: I don't think possible) to capture from a still pin simultaneously to the normal pin, so you might be stuck there. Do you have a use case for using the still pin at all?

Could you show me the graphstudionext pin media properties for that audio pin please? It might be that dshow just doesn't have all the advertised specs, so cannot display them (does virtualdub only use directshow input? It might be pulling input from some other type of audio input that is more granular [?]). Are there more than one audio pin possibly? It does seem odd that it repeats the same format type 22 times.
Cheers!

rogerdpack
Posts: 1876
Joined: Fri Aug 05, 2011 9:56 pm

Re: DirectShow Capture support

Post by rogerdpack » Wed May 06, 2015 11:14 am

zamar24 wrote:I own several Logi webcams, and also feel that Dshow support is incomplete now, for example:

- no command to print only default webcam video, audio, and still image formats data

- no or unknown command to print list of supported still image formats

- the command to print available audio formats gives incomplete list of supported audio sampling rates, and no list of audio stream container formats

Is it possible to add such support to FFMpeg Dshow?
Do you have a use case for the still pin? It seems from https://msdn.microsoft.com/en-us/librar ... 85%29.aspx that it must be started by "triggers" do you want it to just take a single picture then exit, for instance, or try and trigger over and over again? (just wondering).
Cheers!

zamar24
Posts: 9
Joined: Sun Apr 19, 2015 6:20 am

Re: DirectShow Capture support

Post by zamar24 » Fri May 08, 2015 1:58 am

Hi rogerdpack,

I apologize for not checking on this thread progress more often, and will definitely answer all your questions a bit later.

Could you suggest, if its possible to overlay two C920 H264 dshow video sources into one MP4 file or MKV stream without transcoding? I know you have several overlay articles in your blog and also on using avisynth as dshow capture source to combine multiple sources, but the question of preserving original encoding to lower CPU usage AFAIK was never addressed. Is it possible in principle to overlay two H264 sources of any nature - like 2 webcams - with the same codec and stream parameters into one overlay H264 video file without transcoding, and how? Note that the webcams can vary framerate over time independently based on their firmware, unless a fixed framerate output is chosen in FFMpeg.

I'd assume it may be easier to capture raw streams from both webcams instead of H264, and then encode synced into one overlay MP4 file? But in practice USB2.0 bandwidth limits and C920 firmware don't allow to output [email protected] raw, only H264 encoded. Not sure if decoding 2 streams on the fly and then encoding to overlay is achievable based on high resulting CPU load. Of course its possible to record two H264 streams, and then decode and re-encode them offline into overlay, but it doesn't look like an elegant solution, and audio & video sync problems may occur, as both webcam streams must be synced. ;)

Post Reply