2

In my C# project I capture the screen at regular intervals (with a timer). I then have to convert the images into one video with FFmpeg, so I use this command:

"-f image2 -framerate 9 -i E:\\REC\\Temp\\%06d.jpeg -r 30 E:\\REC\\Video\\" + s + ".mkv"

It works, but the size of the output video is large, about 8 MB for only 1 minute of video. How can I make the video smaller in size without sacrificing quality?

6
  • Is 8MB really that big for a video in .mkv format? I don't think it is. How small would you want it considering you will likely loose quality? Mar 26, 2014 at 11:19
  • ok i will capture the screen 10 hour a day every day so i need it small as possible and "good" quality, about 2 - 4 mb for 1min? Mar 26, 2014 at 11:22
  • Change your format would probably be a good idea. mkv is a nice container, but can be large. Try mp4 or something like that. Mar 26, 2014 at 11:24
  • The size doesn't depend on the container, but on the codec. Also, what resolution are the screenshots? Do you need them to be full resolution?
    – stib
    Mar 26, 2014 at 12:34
  • yes 1366x768 i did use the code in the answer but i wish to make it less quality Mar 26, 2014 at 12:36

1 Answer 1

2

From what I know MKV is a container, you need to use compression for the video stream, like this:

ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

In this example each image will have a duration of 5 seconds (the inverse of 1/5 frames per second). The video stream will have a framerate of 30 fps by duplicating the frames accordingly.

For more information see this article at the FFmpeg wiki.

3
  • nice, but what if i want it less quality? Mar 26, 2014 at 11:34
  • 1
    use -crf n where n is a number starting at 1 for highest possible quality 20 is about DVD quality and 30 is starting to look a bit yucky. The size will vary inversely to the quality.
    – stib
    Mar 26, 2014 at 12:37
  • thnks for that @stib Mar 26, 2014 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .