我正在尝试使用gdigrab捕获屏幕并将int与声音结合,然后将其发送到我的decklink sdi设备上。
这是我要捕获的代码:
ffmpeg -framerate 25 -thread_queue_size 512 -f gdigrab -i title="Play" -f dshow -i audio="CABLE Output (VB-Audio Virtual Cable)" -af aresample=resampler=soxr -ar 48000 -acodec pcm_s16le -ac 2 -c:v libx264 -qp 0 -preset ultrafast "output.avi"
这是输出到ffmpeg的代码:
ffmpeg -i output.avi -f decklink -pix_fmt uyvy422 "DeckLink SDI (2)"
这种方式可行,但是当我将这两个参数组合在一起将输出发送到decklink卡时,ffmpeg就会停止工作。这是组合代码:
ffmpeg -framerate 25 -thread_queue_size 512 -f gdigrab -i title="Play" -f dshow -i audio="CABLE Output (VB-Audio Virtual Cable)" -af aresample=resampler=soxr -ar 48000 -acodec pcm_s16le -ac 2 -f decklink -pix_fmt uyvy422 "DeckLink SDI (2)"
我尝试了很多不同的组合,但没有运气。它只有在我将它存储在文件上然后使用该文件作为输入时才有效。有没有办法告诉ffmpeg使用第一个命令的结果作为第二个命令的输入?
由于
更新: 这是日志报告:
ffmpeg started on 2017-08-08 at 12:26:36
Report written to "ffmpeg-20170808-122636.log"
Command line:
ffmpeg -framerate 25 -thread_queue_size 512 -f gdigrab -i "title=Play" -c:v rawvideo -f dshow -i "audio=CABLE Output (VB-Audio Virtual Cable)" -af "aresample=resampler=soxr" -ar 48000 -acodec pcm_s16le -ac 2 -map 0:v:0 -map 1:a:0 -f decklink -pix_fmt uyvy422 "DeckLink SDI (2)" -report
ffmpeg version N-71608-ga924b83 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Splitting the commandline.
Reading option '-framerate' ... matched as AVOption 'framerate' with argument '25'.
Reading option '-thread_queue_size' ... matched as option 'thread_queue_size' (set the maximum number of queued packets from the demuxer) with argument '512'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'gdigrab'.
Reading option '-i' ... matched as input file with argument 'title=Play'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'rawvideo'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'dshow'.
Reading option '-i' ... matched as input file with argument 'audio=CABLE Output (VB-Audio Virtual Cable)'.
Reading option '-af' ... matched as option 'af' (set audio filters) with argument 'aresample=resampler=soxr'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'pcm_s16le'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '2'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:v:0'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '1:a:0'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'decklink'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'uyvy422'.
Reading option 'DeckLink SDI (2)' ... matched as output file.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file title=Play.
Applying option thread_queue_size (set the maximum number of queued packets from the demuxer) with argument 512.
Applying option f (force format) with argument gdigrab.
Successfully parsed a group of options.
Opening an input file: title=Play.
[gdigrab @ 0000000002d3f2a0] Found window Play, capturing 720x576x32 at (0,0)
[gdigrab @ 0000000002d3f2a0] Cursor pos (588,602) -> (-271,597)
[gdigrab @ 0000000002d3f2a0] All info found
Input #0, gdigrab, from 'title=Play':
Duration: N/A, start: 1502178996.958615, bitrate: 331786 kb/s
Stream #0:0, 1, 1/1000000: Video: bmp, bgra, 720x576, 331786 kb/s, 25 tbr, 1000k tbn, 25 tbc
Successfully opened the file.
Parsing a group of options: input file audio=CABLE Output (VB-Audio Virtual Cable).
Applying option c:v (codec name) with argument rawvideo.
Applying option f (force format) with argument dshow.
Successfully parsed a group of options.
Opening an input file: audio=CABLE Output (VB-Audio Virtual Cable).
[dshow @ 0000000002d3c340] Selecting pin Capture on audio only
dshow passing through packet of type audio size 88200 timestamp 111632750000 orig timestamp 111632750000
[dshow @ 0000000002d3c340] All info found
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, dshow, from 'audio=CABLE Output (VB-Audio Virtual Cable)':
Duration: N/A, start: 11163.275000, bitrate: 1411 kb/s
Stream #1:0, 1, 1/10000000: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Successfully opened the file.
Parsing a group of options: output file DeckLink SDI (2).
Applying option af (set audio filters) with argument aresample=resampler=soxr.
Applying option ar (set audio sampling rate (in Hz)) with argument 48000.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument pcm_s16le.
Applying option ac (set number of audio channels) with argument 2.
Applying option map (set input stream mapping) with argument 0:v:0.
Applying option map (set input stream mapping) with argument 1:a:0.
Applying option f (force format) with argument decklink.
Applying option pix_fmt (set pixel format) with argument uyvy422.
Successfully parsed a group of options.
Opening an output file: DeckLink SDI (2).
Successfully opened the file.
detected 2 logical cores
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'video_size' to value '720x576'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'pix_fmt' to value '30'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'time_base' to value '1/1000000'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'pixel_aspect' to value '0/1'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0000000002dd7ea0] w:720 h:576 pixfmt:bgra tb:1/1000000 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 0000000002d3df00] compat: called with args=[uyvy422]
[format @ 0000000002d3df00] Setting 'pix_fmts' to value 'uyvy422'
[auto-inserted scaler 0 @ 0000000002d44ca0] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 0000000002d44ca0] w:iw h:ih flags:'0x4' interl:0
[format @ 0000000002d3df00] auto-inserting filter 'auto-inserted scaler 0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0000000002e586c0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto-inserted scaler 0 @ 0000000002d44ca0] w:720 h:576 fmt:bgra sar:0/1 -> w:720 h:576 fmt:uyvy422 sar:0/1 flags:0x4
[Parsed_aresample_0 @ 0000000002d513a0] Setting 'resampler' to value 'soxr'
[graph 1 input from stream 1:0 @ 0000000002d51460] Setting 'time_base' to value '1/44100'
[graph 1 input from stream 1:0 @ 0000000002d51460] Setting 'sample_rate' to value '44100'
[graph 1 input from stream 1:0 @ 0000000002d51460] Setting 'sample_fmt' to value 's16'
[graph 1 input from stream 1:0 @ 0000000002d51460] Setting 'channel_layout' to value '0x3'
[graph 1 input from stream 1:0 @ 0000000002d51460] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[audio format for output stream 0:1 @ 0000000002d51520] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:1 @ 0000000002d51520] Setting 'sample_rates' to value '48000'
[audio format for output stream 0:1 @ 0000000002d51520] Setting 'channel_layouts' to value '0x3'
[AVFilterGraph @ 0000000002d4d0c0] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
[Parsed_aresample_0 @ 0000000002d513a0] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2 chl:stereo fmt:s16 r:48000Hz
dshow passing through packet of type audio size 88200 timestamp 111637810000 orig timestamp 111637810000
[decklink @ 0000000002dd6a00] Found Decklink mode 720 x 576 with rate 25.00(i)
Output #0, decklink, to 'DeckLink SDI (2)':
Metadata:
encoder : Lavf56.30.100
Stream #0:0, 0, 1/25: Video: rawvideo (UYVY / 0x59565955), uyvy422, 720x576, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 rawvideo
Stream #0:1, 0, 1/48000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
encoder : Lavc56.35.101 pcm_s16le
Stream mapping:
Stream #0:0 -> #0:0 (bmp (native) -> rawvideo (native))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
Cliping frame in rate conversion by 0.000008
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Encoder did not produce proper pts, making some up.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
*** 40 dup!
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 1.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 2.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 3.
[decklink @ 0000000002dd6a00] Buffered video frames: 4.
[decklink @ 0000000002dd6a00] Buffered video frames: 5.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 6.
[decklink @ 0000000002dd6a00] Buffered video frames: 7.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 8.
[decklink @ 0000000002dd6a00] Buffered video frames: 9.
[decklink @ 0000000002dd6a00] Buffered video frames: 10.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 11.
[decklink @ 0000000002dd6a00] Buffered video frames: 12.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 13.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
dshow passing through packet of type audio size 88200 timestamp 111642810000 orig timestamp 111642810000
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 14.
[decklink @ 0000000002dd6a00] Ending audio preroll.
[decklink @ 0000000002dd6a00] Starting scheduled playback.
[decklink @ 0000000002dd6a00] Buffered video frames: 15.
[decklink @ 0000000002dd6a00] Buffered video frames: 16.
[decklink @ 0000000002dd6a00] Buffered video frames: 17.
[decklink @ 0000000002dd6a00] Buffered video frames: 18.
[decklink @ 0000000002dd6a00] Buffered video frames: 19.
[decklink @ 0000000002dd6a00] Buffered video frames: 20.
[decklink @ 0000000002dd6a00] Buffered video frames: 21.
[decklink @ 0000000002dd6a00] Buffered video frames: 22.
[decklink @ 0000000002dd6a00] Buffered video frames: 23.
[decklink @ 0000000002dd6a00] Buffered video frames: 24.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[decklink @ 0000000002dd6a00] Buffered video frames: 24.
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
frame= 42 fps=0.0 q=0.0 size=N/A time=00:00:01.68 bitrate=N/A dup=40 drop=0
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
dshow passing through packet of type audio size 88200 timestamp 111647710000 orig timestamp 111647710000
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (689,472) -> (-170,467)
[gdigrab @ 0000000002d3f2a0] Cursor pos (814,496) -> (-45,491)
[gdigrab @ 0000000002d3f2a0] Cursor pos (814,496) -> (-45,491)
[gdigrab @ 0000000002d3f2a0] Cursor pos (811,497) -> (-48,492)
[gdigrab @ 0000000002d3f2a0] Cursor pos (811,497) -> (-48,492)
[gdigrab @ 0000000002d3f2a0] Cursor pos (811,497) -> (-48,492)
[gdigrab @ 0000000002d3f2a0] Cursor pos (806,497) -> (-53,492)
答案 0 :(得分:1)
您可以将ffmpeg输出传递给另一个ffmpeg。但是,您需要知道视频分辨率,因为您需要告诉第二个ffmpeg正确的分辨率。我在下面的示例中将输入调整为1080p,您可以更改为您想要的内容。但是,请确保DeckLink卡支持分辨率和帧速率。
ffmpeg -framerate 25 -thread_queue_size 512 -f gdigrab -i title="Play" -f rawvideo -s 1920x1080 -pix_fmt uyvy422 - | ffmpeg -f rawvideo -video_size 1920x1080 -framerate 25 -pixel_format uyvy422 -i - -f dshow -i audio="CABLE Output (VB-Audio Virtual Cable)" -af aresample=resampler=soxr -ar 48000 -acodec pcm_s16le -ac 2 -f decklink "DeckLink SDI (2)"