0

1.we need to record screenshots into video with 2-3 fps. Quality - the minimum possible to make text on the screen readable, 256 colors. It is important to reduce the output video file size as much as possible.

2.we've made a lot of tests, and currently the most suitable way is to make screenshots every 300-500msec, save them in PNG, then run ffmpeg to encode to H.267 with these params:

ffmpeg -f image2 -i "C:\png5min\image%04d.png" -y -an -vcodec libx264 -preset veryfast -crf 30 "C:\output.mp4"

3.is it the best way to get minimum output size with 2-3fps screencast?

4.the output file plays very quickly, codec by default concerns that images represent 25fps. But they are 2fps actually. Ok, but if we try to decrease the output frame rate, output file size increases for about twice!! (from 3mb to 6mb for a 3m:26s video). And if we set the output frame rate as 2 - video does not play frames at all or plays just 2 frames for 3mins...:

-r 2 -f image2 -i "C:\png5min\image%04d.png" -y -an -vcodec libx264 -preset veryfast -crf 30 -r 2 "C:\image5min_2fps_crf30_test__R2-2.mp4"

so, how can we just add some latency after each frame without increasing the output file size???

Alexander M.
  • 761
  • 1
  • 7
  • 14
  • btw, if we try to record screen directly with ffmpeg, we get a much bigger output file: ffmpeg -f dshow -r 2 -i video="screen-capture-recorder" -vcodec libx264 -crf 30 -preset ultrafast c:\output3.mkv so, looks like the codec works much better compressing predefined set of images, yes? – Alexander M. Sep 02 '16 at 12:14
  • http://stackoverflow.com/a/43464269/6180077 visit this link for working FFMPEG c++ mp4 format screen recorder application. – Abdullah Farweez May 09 '17 at 04:31

1 Answers1

1

Try with a low input rate and a higher output rate.

Direct capture:

ffmpeg -f dshow -framerate 2 -i video="screen-capture-recorder" -c:v libx264 -r 12 -crf 30 -preset fast c:\output3.mkv

Image conversion:

-framerate 2 -i "C:\png5min\image%04d.png" -y -c:v libx264 -preset medium -crf 30 -r 6 -x264opts ref=5:min-keyint=300:keyint=600:rc-lookahead=150 "C:\image5min_2fps_crf30_test__R2-2.mp4"

The ultrafast preset is useful mainly for full framerate realtime captures. For an input rate of 2, you can downgrade, which will give you better compression. In the image conversion command, you can skip it altogether, so it will default to medium, which will compress better.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • your direct capture command is better than our direct capture, but still not so good as our image conversion with 2 fps -> 25fps... . And image conversion that you offer makes similar things that we've tried with 10fps output... 6-7Mb file instead of 3Mb... – Alexander M. Sep 02 '16 at 14:00
  • so, are we right, that if the file size and conversion load\speed is critical for us, it's better to make it as we do with 2 -> 25fps (very quick video, 16sec instead of 3min) and than just make a slow playback in the player? (we will be using our html5 player, no need to play these screencasts in another 3rd party players) – Alexander M. Sep 02 '16 at 14:03
  • will that be an issue to play H.264 mp4 video in all popular browsers with a 12 time slow playback (25fps->2fps)? – Alexander M. Sep 02 '16 at 14:15
  • Can't answer on how browsers handle playback. For image conversion, try edited command. – Gyan Sep 02 '16 at 14:22
  • Unrecognized option 'keyint'. Error splitting the argument list: Option not found – Alexander M. Sep 02 '16 at 14:33
  • Ah, sorry, that's a x264 private option, use `-g 600` instead. – Gyan Sep 02 '16 at 14:35
  • implemented 6fps with keyint_min 300 but w\o keyint 600 - got 6+Mbytes (vs 3Mb in a quick 16sec 25fps video) – Alexander M. Sep 02 '16 at 14:36
  • Run the following command on your 25 fps and my 6 fps videos: `ffprobe -show_entries frame=coded_picture_number,pkt_size,key_frame,pkt_pts_time -of compact -select_streams v vid.mp4 > vid.txt`. Output to different log files and link them here. – Gyan Sep 02 '16 at 14:47
  • yours (big one): https://ru.scribd.com/document/322849716/Vid-Big-6fps my(smaller): https://ru.scribd.com/document/322849715/Vid-Small-25fps – Alexander M. Sep 02 '16 at 16:59
  • Try final edit, else you are better slowing down the 25 fps video. – Gyan Sep 02 '16 at 17:38
  • done - 6Mbytes. looks like it's a limit for full fps timelined video, even it's a 2fps inside... – Alexander M. Sep 07 '16 at 16:37