ffmpeg DirectShow capture 2 pins

2019-08-04 17:02发布

问题:

Here is ffmpeg DirectShow options

 DirectShow video device options
  Pin "Capture"
   pixel_format=yuyv422  min s=720x480 fps=59.9402 max s=720x480 fps=59.9402
   pixel_format=yuyv422  min s=720x480 fps=29.97 max s=720x480 fps=29.97
   pixel_format=yuyv422  min s=720x576 fps=50 max s=720x576 fps=50
   pixel_format=yuyv422  min s=720x576 fps=25 max s=720x576 fps=25
   pixel_format=yuyv422  min s=640x480 fps=59.9402 max s=640x480 fps=59.9402
   pixel_format=yuyv422  min s=1920x1080 fps=29.97 max s=1920x1080 fps=29.97
   pixel_format=yuyv422  min s=1920x1080 fps=25 max s=1920x1080 fps=25
   pixel_format=yuyv422  min s=1920x1080 fps=24 max s=1920x1080 fps=24
   pixel_format=yuyv422  min s=1280x720 fps=59.9402 max s=1280x720 fps=59.9402
   pixel_format=yuyv422  min s=1280x720 fps=50 max s=1280x720 fps=50
  Pin "Audio"

What ffmpeg command will capture both Pins?

Update

My device name is 7160 HD Capture ffmpeg -f dshow -i video="7160 HD Capture" out.mp4

Following command works fine:-

ffmpeg -f dshow -s 1280x720 -i video="7160 HD Capture" -rtbufsize 2000M out19.mp4

I tried

ffmpeg -f dshow -s 1280x720 -i "video=7160 HD Capture:audio=7160 HD Capture" -rtbufsize 2000M out20.mp4

it does not work and returns error:-

[dshow @ 000000000250b540] Could not enumerate audio devices. video=7160 HD Capture:audio=7160 HD Capture: Input/output error

I seen that audio Pin has different names on different cards. May be I should explicitly name it.

Update 2

I do not have Audio capture devices but Video Capture definitely has Audio.

I am able to play that audio pin on default audio device

回答1:

OK support for this was (hopefully) added recently in FFmpeg dshow, you can specify ffmpeg -f dshow -i video="AJA Capture Source":audio="AJA Capture Source" now and it work.

There are even new parameters for selecting which pin you want to use, if you need them. https://www.ffmpeg.org/ffmpeg-devices.html#dshow

If it doesn't work for somebody/anybody please let me know rogerdpack@gmail.com or comment here.



回答2:

ffmpeg.exe -f dshow -s 1920x1080 -i "video=Timeleak HD Capture (YPbPr):audio=Timeleak HD Capture (YPbPr)" -c:v libx264 -preset ultrafast -c:a ac3 -f mpegts udp://127.0.0.1:1234


回答3:

There is no command that will map both pins from the same instance of the filter. For example, take this command:

ffmpeg.exe -f dshow -i "video=<src_filter_name>:audio=<src_filter_name>"

graphically speaking, it will create two instances of the "src_filter_name" (that beign the name I made up since you didn't provide it in your question). If your filter is nice, and plays with multiple instances of itself, then you'll be OK.

in graph edit try it your self. drop in the source filter twice, and render the audio pin from the first, and the video pin from the second. if that works then the above ffmpeg command should work.

Update

Since your "7160 HD Capture" is not listed under "Audio Capture Sources", ffmpeg will not see it. ffmpeg is written in such a way that it will only read video from the first video pin of a video capture source, and audio from the first audio pin of an audio capture source.

So your options here are

  1. change the way ffmpeg wires up the dshow devices by modifying its source code
  2. create a dshow sink filter into which you send audio and video from the 7160 HD Capture device, and then create a source filter that can act as both an audio and video source for ffmpeg. this would require a process or thread pushing data into the sink and some how making it available to the source.

unfortunately I have no source code to share, just the basic idea. both solutions would be in C++. the directshow way is probably more work, the ffmpeg way is probably easier, if you know and understand ffmpeg source code :-)



回答4:

Use last driver from timeleak.

ffmpeg.exe -f dshow -s 1920x1080 -i "video=Timeleak HD Capture (YPbPr):audio=Timeleak HD Capture (YPbPr)" -f mpegts udp://127.0.0.1:1234

Open udp://@1234 in VLC.

Audio works for me with hd72a via HDMI and I stream in HTTP without a problem.



回答5:

You can multiplex the 2 capture pins in DirectShow and send the multiplexed stream to ffmpeg.exe with this sink filter.