" I hope my example project on github can help others on that matter...."
It certainly does, thank you. Your README contains helpful info' too.
This entire thread is useful.
Incidentally, only one example,
It builds without errors, but runs thus:
fourcc: I420, variant; width: 1280, height: 720, (0,0,1280,720)
so generates an empty out.h264
All the others build & run fine using -O3
$ gcc -v
Using built-in specs.
gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1)