ffmpeg command line for capturing (and recording) audio and video in 720p from decklink card using Windows 7 -
i trying capture audio , video blackmagic decklink capture card using windows 7 @ 720p, cant seem ffmpeg command line settings right.
ffmpeg -list_devices true -f dshow -i dummy
[dshow @ 02457a60] directshow video devices [dshow @ 02457a60] "blackmagic wdm capture" [dshow @ 02457a60] "decklink video capture" [dshow @ 02457a60] directshow audio devices [dshow @ 02457a60] "decklink audio capture"
ffmpeg -list_options true -f dshow -i video="decklink video capture"
[dshow @ 03c2ea20] directshow video device options [dshow @ 03c2ea20] pin "capture" [dshow @ 03c2ea20] pixel_format=uyvy422 min s=720x486 fps=29.97 max s=720x486 fps=29.97 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=720x486 fps=23.976 max s=720x486 fps=23.976 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=720x576 fps=25 max s=720x576 fps=25 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=720x486 fps=59.9402 max s=720x486 fps=59.9402 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=720x576 fps=50 max s=720x576 fps=50 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1920x1080 fps=23.976 max s=1920x1080 fps=23.976 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1920x1080 fps=24 max s=1920x1080 fps=24 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1920x1080 fps=25 max s=1920x1080 fps=25 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1920x1080 fps=29.97 max s=1920x1080 fps=29.97 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1920x1080 fps=30 max s=1920x1080 fps=30 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1280x720 fps=50 max s=1280x720fps=50 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1280x720 fps=59.9402 max s=1280x720 fps=59.9402 [dshow @ 03c2ea20] pixel_format=uyvy422 min s=1280x720 fps=60.0002 max s=1280x720 fps=60.0002
ffmpeg -list_options true -f dshow -i audio="decklink audio capture"
[dshow @ 047fea20] directshow audio device options [dshow @ 047fea20] pin "capture" [dshow @ 047fea20] min ch=1 bits=16 rate= 48000 max ch=1 bits=16 rate= 48000 [dshow @ 047fea20] min ch=2 bits=16 rate= 48000 max ch=2 bits=16 rate= 48000 [dshow @ 047fea20] min ch=4 bits=16 rate= 48000 max ch=4 bits=16 rate= 48000 [dshow @ 047fea20] min ch=6 bits=16 rate= 48000 max ch=6 bits=16 rate= 48000 [dshow @ 047fea20] min ch=8 bits=16 rate= 48000 max ch=8 bits=16 rate= 48000 [dshow @ 047fea20] min ch=10 bits=16 rate= 48000 max ch=10 bits=16 rate= 48000 [dshow @ 047fea20] min ch=12 bits=16 rate= 48000 max ch=12 bits=16 rate= 48000 [dshow @ 047fea20] min ch=16 bits=16 rate= 48000 max ch=16 bits=16 rate= 48000
this stream information current video/audio source, connected decklink card's hdmi port
stream #0:0: video: rawvideo (uyvy / 0x59565955), uyvy422(tv), 1280x720, 59.94 tbr, 10000k tbn, 59.94 tbc stream #0:1: audio: pcm_s16le, 48000 hz, stereo, s16, 1536 kb/s
ultimately need display video on screen. , simultaneously able start , stop recording, while preview keeps playing.
my idea use ffmpeg capture video , audio signal , transmit network stream (eg 127.0.0.1:6666). use vlc player display stream (the preview). , start and/or stop ffmpeg save same stream disk.
in mind works, no audio/video expert if more experience out, appreciate it.
update:
i have been able display video using ffplay, following command :
ffplay -f dshow -video_size 1280x720 -rtbufsize 702000k -framerate 60 -i video="decklink video capture":audio="decklink audio capture" -threads 2
next step streaming can view stream (preview) vlc.
tried use command :
ffmpeg -f dshow -video_size 1280x720 -rtbufsize 702000k -framerate 60 -i video="decklink video capture":audio="decklink audio capture" -threads 2 -f mpegts rtp://127.0.0.1:6666?pkt_size=188?buffer_size=65535
which not give errors, appears work. when try open stream in vlc following error :
sdp required: description in sdp format required receive rtp stream. note rtp:// uris cannot work dynamic rtp payload format (65).
after bit of reading seems should not streaming rtp:// rather udp://
command became :
ffmpeg -f dshow -video_size 1280x720 -rtbufsize 702000k -framerate 60 -i video="decklink video capture":audio="decklink audio capture" -threads 2 -f mpegts udp://127.0.0.1:6666?pkt_size=188?buffer_size=65535
and when try open in vlc no error, no warning, no video.
time more reading.
finally got working. setup has running on single machine.
for taking video , serving via udp use following command :
ffmpeg -f dshow -video_size 1280x720 -rtbufsize 702000k -framerate 60 -i video="decklink video capture":audio="decklink audio capture" -r 30 -threads 4 -vcodec libx264 -crf 0 -preset ultrafast -f mpegts "udp://239.255.12.42:6666"
- the "-f dshow" tells ffmpeg need use direct show.
- "-video_size 1280x720" sets source size, since using 720p60 source, it.
- "rtbufsize 702000k" important since without realtime buffer full in matter of seconds.
- "-framerate 60" tells ffmpeg source using 60fps.
- the option: video="decklink video capture":audio="decklink audio capture" tells ffmpeg use device input, specifying them in fashion, lag between audio , video substantially less (and/or gone).
- "-r 30" forces output 30fps instead of 60fps in source.
- "-threads 4" think, use 4 threads.
- "-vcodec libx264" encodes source stream h264 while broadcasting.
- "-crf 0" sets "constant rate factor" (quantizer scale) 0, meaning lossless.
- "-preset ultrafast" means dont have patience, use little compression possible. causes high bitrate, that's fine purpose.
- "-f mpegts" option tells ffmpeg use mpeg-ts packets, "force" ffmpeg use constant bitrate mpeg format, since mpeg variable bitrate.
- finally option "udp://239.255.12.42:6666" specifies want broadcast stream multicast address 239.255.12.42 using port 6666 on udp. reason chose use multicast address here because need display stream (preview) , record @ same time, least processing possible. prevents me having copy audio , video stream 2 different network addresses.
for capturing video using vlc player, open following network streaming address :
udp://@239.255.12.42:6666
finally recording stream spawn new process , issue following command :
ffmpeg -y -threads 4 -i udp://239.255.12.42:6666 -map 0 -acodec copy -vcodec copy output.mkv
- the "-y" option overwriting file if exists without questions.
- the "-threads 4" option think, uses 4 threads.
- the "-i udp://239.255.12.42:6666" connects stream broadcasting.
- the "-map 0" tells ffmpeg need streams (both video , audio).
- the "-acodec copy" , "-vcodec copy" there ensure streams taken is, instead of doing compression/transcoding.
the thing left (which work in progress atm) creating c# gui this. basic workflow spawn stream process when form loads. use vlc com+ control display video in application.
then when record button pushed, spawn process record , stop process end recording.
i stop stream when start record, makes recording/detection go more smoothly. if stream stays on , start recording take time before recording process can "tune in" stream. stopping stream, starting recording (which nothing until stream on) , starting stream again, recording pickup first frame without problems.
this small delay/flicker totally acceptable purposes.
Comments
Post a Comment