Use RAII for ffmpeg pointers
To avoid in-place code paths to release underlying resources in case of failures, exceptions etc. unique_ptr
destructor will do the job.
Also add missing error handling for av_frame_alloc
and avcodec_alloc_context3
.