FFmpeg refactoring to meet the FFmpeg API recommendations to be

compatible with plugins.