Video file created with FFmpeg too big

2

1

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?

Maged E William

Posted 2014-03-26T11:10:36.057

Reputation: 125

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? – Matthew Williams – 2014-03-26T11:19:31.807

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? – Maged E William – 2014-03-26T11:22:50.010

Change your format would probably be a good idea. mkv is a nice container, but can be large. Try mp4 or something like that. – Matthew Williams – 2014-03-26T11:24:02.923

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 – 2014-03-26T12:34:42.893

yes 1366x768 i did use the code in the answer but i wish to make it less quality – Maged E William – 2014-03-26T12:36:23.007

You should always include your actual, unscripted ffmpeg command and the complete ffmpeg console output. – llogan – 2014-03-26T17:37:52.637

Answers

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.

Rabin

Posted 2014-03-26T11:10:36.057

Reputation: 467

nice, but what if i want it less quality? – Maged E William – 2014-03-26T11:34:24.307

1use -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 – 2014-03-26T12:37:01.767

thnks for that @stib – Maged E William – 2014-03-26T14:03:32.913