使用TCL和FFMPEG,在for循环中运行2个exec命令,时间间隔为30秒

我想使用TCL和FFMPEG以30秒的时间间隔在for循环中运行2 exec命令

我的图像执行命令是:

exec ffmpeg -f dshow -benchmark -i video="Integrated Webcam" -s 1280x720 c:/test/sample_image%d.jpg 

我对video的执行命令是:

 exec ffmpeg -f dshow -benchmark -i video="Integrated Webcam" -s 1280x720 c:/test/sample_video%d.avi 

我想我的代码是这样的:

 proc a {} { set a 1 while {$a < 10} { after 3000 exec ffmpeg -f dshow -benchmark -i "video=Integrated Webcam" -s 1280x720 c:/test/sample_image.avi after 3000 exec ffmpeg -f dshow -t 00:00:30 -benchmark -i "video=Integrated Webcam" -s 1280x720 c:/test/sample_video.avi incr a } } a 

这里的问题是,完成第一个exec命令后,它停止执行。 那就是捕捉图像并停止执行。

我也希望这个捕捉图像和video的过程应该循环(while或foreach)。

我有我目前的工作代码只执行一个执行命令,只有一个。 所以我想要这两个执行命令在循环之后运行。

以上程序错误报告:

 % source c:/other/a/d.tcl ffmpeg version N-89212-ga60b2425c3 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx libavutil 56. 2.100 / 56. 2.100 libavcodec 58. 3.105 / 58. 3.105 libavformat 58. 2.102 / 58. 2.102 libavdevice 58. 0.100 / 58. 0.100 libavfilter 7. 2.102 / 7. 2.102 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc 55. 0.100 / 55. 0.100 Input #0, dshow, from 'video=Logitech HD Webcam C525': Duration: N/A, start: 90055.057000, bitrate: N/A Stream #0:0: Video: rawvideo, bgr24, 1280x720, 30 fps, 30 tbr, 10000k tbn, 10000k tbc File 'c:/test/sample_20171128_111245.jpg' already exists. Overwrite ? [y/N] [dshow @ 052d4ac0] real-time buffer [Logitech HD Webcam C525]  too full or near too full (181% of size: 3041280 [rtbufsize parameter])! frame dropped! Last message repeated 886 times Not overwriting - exiting bench: maxrss=50856kB [dshow @ 052d4ac0] real-time buffer [Logitech HD Webcam C525]  too full or near too full (181% of size: 3041280 [rtbufsize parameter])! frame dropped! Last message repeated 1 times % 

请提供我的代码作为答案,将为上述问题的工作。

这是工作代码与for循环与2个不同的执行命令:

 proc a {} { for {set i 0} {$i < 5} {incr i} { puts " $i " set time [clock format [clock seconds] -format %Y%m%d_%H%M%S] exec ffmpeg -f dshow -i "video=Integrated Webcam" -s 1280x720 -benchmark c:/test/Image_$time.jpg >& c:/test/image_$time.txt & after 30000 exec ffmpeg -f dshow -t 00:00:20 -i "video=Logitech HD Webcam C525" -s 1280x720 -benchmark c:/test/video_$time.avi >& c:/test/video_$time.txt & after 30000 } } a