Container
mp4 and the h264 codec is the only pair supported by all browsers.
h265 and VP9 provide better compression, but are still partially supported, and probably without hardware acceleration on most platforms.
As with h264, you will get better double encoding compression. The first pass creates statistics about the motion of the videos that are used in the second pass. Consult the ffmpeg documentation.
Also, encoding with a lower output resolution provides better quality than lowering the quality parameters. That is, if you have the original video with a resolution of 1080x720, encoding to the final (1080/3) x (720x3) output will save about 9 (3x3) bandwidth. Price quality is much better than 1080x720 streaming at 1/9 of the original bit rate. This is due to the way the brain works.
A good approach might be to offer high and medium low images, and through JS, the best video for the client. It makes no sense to broadcast fullHD to a 3G client or 1080p video for a client with a 800x400 screen.
source share