Capture script run on video.

Asked by sdraganov on 2018-05-13

I would like to capture my sikulix script run on video - would be very helpful when something failed.

I managed to run a video recording with ffmpeg:

and the following .bat command launched from sikulix:
D:\ffmpeg.exe -y -rtbufsize 100M -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 1920x1200 -draw_mouse 1 -i desktop -c:v libx264 -r 30 -preset ultrafast -tune zerolatency -crf 28 -pix_fmt yuv420p -movflags +faststart "D:\1.mp4"

The problem is that sikulix App.close() and CMD taskkill commands cannot stop the recorder.
I need to execute CTRL+C command before or after App.close() or taskkill commands - otherwise ffmpeg continues to record.
I know it's possible ti run CTRL+C from sikuli but since my script opens and closes lots of windows I'm afraid that .CMD windows could be out of focus when it's executed. Sikuli App.focus() method also doesn't work with CMD.exe being started by the .bat file.

The other problem that I see in the future is that if something fails and the script doesn't get to the commands that would stop the recorder, the recording will not stop. Is there a way to run a command that would stop the recording if script failed?

I would be happy to hear if someone already get through this and let me know how to do it.
I'm not tied to ffmpeg-software, it's just the first thing I tried, if there is a better solution I would love to try it.

Thanks in advance.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

interesting solution ;-)

I guess, the only way, that makes sense, is to use the video creation as main process and run the scripts, that you want to observe, as subprocesses from within this main process.

# workflow
- start video
- detach scriptrun to subprocess
- track the scriptrun somehow (e.g. with the piped stdout)
- stop the video capture when the subprocess ends (however this might happen)

Can you help with this problem?

Provide an answer of your own, or ask sdraganov for more information if necessary.

To post a message you must log in.