FFmpeg refactoring to meet the FFmpeg API recommendations to be

compatible with plugins.

@SubJunk and @SharkHunter I would like to know your oppinion on that commit before it can be merged