private function executeFFmpegForMedia($cmd, $format, $resolution, $media) {
        $ffmpeg_start = microtime(true);
        $this->getContainer()->get('oktolab_media_ffmpeg')
            ->executeFFmpegForMedia(
                $resolution['encoder'],
                $cmd,
                $media
            )
        ;
        $ffmpeg_stop = microtime(true);

        $media->setStatus(Media::OKTOLAB_MEDIA_STATUS_MEDIA_FINISHED);
        $media->setPublic($resolution['public']);
        $this->em->persist($media);
        $this->em->flush();

        $this->logbook->info(
            'oktolab_media.episode_end_saving_media',
            [
                '%format%' => $format,
                '%seconds%' => round($ffmpeg_stop - $ffmpeg_start)
            ],
            $this->args['uniqID']
        );

        // move encoded media from "cache" to config adapter or adapter of the original file
        $this->getContainer()->get('bprs.asset')->moveAsset(
            $media->getAsset(),
            $resolution['adapter'] ? $resolution['adapter'] : $media->getEpisode()->getVideo()->getAdapter()
        );

        // add finalize episode job, set new episode status
        if (!$this->added_finalize) {
            $this->finalizeEpisode($media->getEpisode());
            $this->added_finalize = true;
        }
    }