ffmpeg is bloated and messy, and has complicated licensing situation - depending on what components you enable, you may be able to use it without paying, but for example you would need to get a license for MPEG encoding; and you need to make sure you disable all GPL licensed parts if you want to ever consider commercial use.
If you want to do things legally and clearly, then I would recommend to use an open, cross-platform container, such as mkv, and a royalty-free codec, such as Google’s VP9. We have implemented all this and made it available in a small, freely usable library, IGSIO - see some more details here: How do I write animation video files in VP9 (libvpx) codec format using vtk ?