record desktop save every 30 minutes

2019-07-16 07:15发布

问题:

here is my question that related to the same problem:

better way to record desktop via ffmpeg

I have this command : ffmpeg -f dshow -i video="screen-capture-recorder" -r 30 -t 10 E:\test01.flv

And i am happy with it, but i wonder if i can make it save every 30 minutes so if the power went off i only loses the last 30 minutes.

I use C# to launch and hide ffmpeg cmd, so i wonder how to make it save to the same test01.flv every 30 minutes?

回答1:

ffmpeg -f dshow -framerate 30 -i video="screen-capture-recorder" -t 1800 output

or

ffmpeg -f dshow -framerate 30 -i video="screen-capture-recorder" -t 00:30:00 output

In C# check if the process is still running, if it doesn't then start it again so it starts recording for the next 30 minutes. This depends on how you are starting the child process so I cannot provide any code.



回答2:

One method is to use the segment muxer:

ffmpeg -f dshow -framerate 30 -i video="screen-capture-recorder" -f segment \
-segment_time 1800 out%03d.flv
  • From the docs:

    Note that if you want accurate splitting for a video file, you need to make the input key frames correspond to the exact splitting times expected by the segmenter, or the segment muxer will start the new segment with the key frame found next after the specified start time.

  • This will result in output files named: out001.flv, out002.flv, out003.flv, etc.

  • One problem is that if the command is re-invoked it will attempt to use the same output file names.

  • I removed -r 30 from your command and changed it to -framerate 30 as a dshow input device option. Otherwise, since the default input frame rate is 25, ffmpeg will duplicate frames to reach your desired output frame rate of 30. If you only provide an input frame rate, then the output will use the same frame rate and avoid dropping or duplicating frames to compensate.



标签: c# video ffmpeg