Видео и аудио кодирование: различия между версиями

Материал из Artem Aleksashkin's Wiki
Перейти к навигации Перейти к поиску
Строка 3: Строка 3:
=== H.264 ===
=== H.264 ===
<pre>
<pre>
function transform_video_x264_aac_mp4($file_src,$file_dst,$width,$height,$vb,$ab,$tmp_dir="./")
function transform_video_x264_aac_mp4($file_src,$file_dst,$width,$height,$vb,$ab,$tmp_dir="./")
{
if (!file_exists($file_src)) return false;
$X264_SUBQ="1";
$X264_FRAMEREF="1";
$X264_KEYINT="125";
$X264_THREADS="auto";
$X264_ME="hex";
$X264_BFRAMES="1";
$session_id=time();
$files_prefix = $tmp_dir."".$session_id;
$mediainfo = $this->exec_program("mediainfo ".$file_src);
preg_match("/General[\s\S]*?Format\s+\:\s+(.*)\s+/",$mediainfo,$m);
$format = $m[1];
$format_profile = "";
if (preg_match("/General[\s\S]*?Format profile\s+\:\s+(.*)\s+/",$mediainfo,$m))
{
{
if (!file_exists($file_src)) return false;
$format_profile = $m[1];
$X264_SUBQ="1";
}
$X264_FRAMEREF="1";
$format_info = "";
$X264_KEYINT="125";
if (preg_match("/General[\s\S]*?Format\/Info\s+\:\s+(.*)\s+/",$mediainfo,$m))
$X264_THREADS="auto";
{
$X264_ME="hex";
$format_info = $m[1];
$X264_BFRAMES="1";
}
$session_id=time();
preg_match("/Video[\s\S]*?Frame rate\s+\:\s+(.*?)\s+fps/",$mediainfo,$m);
$files_prefix = $tmp_dir."".$session_id;
//echo $format."\n";
$mediainfo = $this->exec_program("mediainfo ".$file_src);
$fps = $m[1];
preg_match("/General[\s\S]*?Format\s+\:\s+(.*)\s+/",$mediainfo,$m);
if ($format_info == "Apple")
$format = $m[1];
{
$format_profile = "";
// dump audio
if (preg_match("/General[\s\S]*?Format profile\s+\:\s+(.*)\s+/",$mediainfo,$m))
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// encode video from src
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode audio
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
if ($format_profile == "QuickTime")
{
// dump audio
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// encode video from src
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode audio
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
if ($format == "MPEG-4")
{
$mpeg4tracks = $this->exec_program("MP4Box -info ".$file_src);
$tracks = preg_split("/\n\n/",$mpeg4tracks);
$videotrack = false;
foreach($tracks as $track)
{
{
$format_profile = $m[1];
if (preg_match("/Track # (\d+)[\s\S]*?Visual Stream/",$track,$m))
}
{
$format_info = "";
$videotrack = $m[1];
if (preg_match("/General[\s\S]*?Format\/Info\s+\:\s+(.*)\s+/",$mediainfo,$m))
}
{
$format_info = $m[1];
}
preg_match("/Video[\s\S]*?Frame rate\s+\:\s+(.*?)\s+fps/",$mediainfo,$m);
//echo $format."\n";
$fps = $m[1];
if ($format_info == "Apple")
{
// dump audio
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// encode video from src
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode audio
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
if ($format_profile == "QuickTime")
{
// dump audio
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// encode video from src
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode audio
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
}
if ($format == "MPEG-4")
$audiotrack = false;
foreach($tracks as $track)
{
{
$mpeg4tracks = $this->exec_program("MP4Box -info ".$file_src);
if (preg_match("/Track # (\d+)[\s\S]*?Audio (Stream|Track)/",$track,$m))
$tracks = preg_split("/\n\n/",$mpeg4tracks);
$videotrack = false;
foreach($tracks as $track)
{
if (preg_match("/Track # (\d+)[\s\S]*?Visual Stream/",$track,$m))
{
$videotrack = $m[1];
}
}
$audiotrack = false;
foreach($tracks as $track)
{
{
if (preg_match("/Track # (\d+)[\s\S]*?Audio (Stream|Track)/",$track,$m))
$audiotrack = $m[1];
{
$audiotrack = $m[1];
}
}
}
if ($videotrack === false) return false;
$this->exec_program("MP4Box -raw ".$videotrack." ".$file_src." -out ".$files_prefix."_videostream");
if ($audiotrack !== false) $this->exec_program("MP4Box -raw ".$audiotrack." ".$file_src." -out ".$files_prefix."_audiostream");
$this->exec_program("mencoder ".$files_prefix."_videostream -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
if ($audiotrack !== false) $this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
if ($audiotrack !== false) $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
else $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
}
if ($format == "AVI")//Format Audio Video Interleave
if ($videotrack === false) return false;
{
$this->exec_program("MP4Box -raw ".$videotrack." ".$file_src." -out ".$files_prefix."_videostream");
// dump audio
if ($audiotrack !== false) $this->exec_program("MP4Box -raw ".$audiotrack." ".$file_src." -out ".$files_prefix."_audiostream");
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
$this->exec_program("mencoder ".$files_prefix."_videostream -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode video from src
if ($audiotrack !== false) $this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
if ($audiotrack !== false) $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
// encode audio
else $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." ".$file_dst."");
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("rm -f ".$files_prefix."_*");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
return true;
$this->exec_program("rm -f ".$files_prefix."_*");
}
return true;
if ($format == "AVI")//Format Audio Video Interleave
}
{
if ($format == "Windows Media")//WMV
// dump audio
{
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// dump audio
// encode video from src
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode video from src
// encode audio
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
// encode audio
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("rm -f ".$files_prefix."_*");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
return true;
$this->exec_program("rm -f ".$files_prefix."_*");
}
return true;
if ($format == "Windows Media")//WMV
}
{
if ($format == "Flash Video")//FLV
// dump audio
{
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// dump audio
// encode video from src
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode video from src
// encode audio
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
// encode audio
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("rm -f ".$files_prefix."_*");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
return true;
$this->exec_program("rm -f ".$files_prefix."_*");
}
return true;
if ($format == "Flash Video")//FLV
}
{
return false;
// dump audio
$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
// encode video from src
$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
// encode audio
$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
$this->exec_program("rm -f ".$files_prefix."_*");
return true;
}
}
return false;
}
</pre>
</pre>
=== VP9 ===
=== VP9 ===
* https://trac.ffmpeg.org/wiki/Encode/VP9
* https://trac.ffmpeg.org/wiki/Encode/VP9

Версия от 01:40, 27 декабря 2019

Видео

Кодеки

H.264

function transform_video_x264_aac_mp4($file_src,$file_dst,$width,$height,$vb,$ab,$tmp_dir="./")
{
	if (!file_exists($file_src)) return false;
	$X264_SUBQ="1";
	$X264_FRAMEREF="1";
	$X264_KEYINT="125";
	$X264_THREADS="auto";
	$X264_ME="hex";
	$X264_BFRAMES="1";
	$session_id=time();
	$files_prefix = $tmp_dir."".$session_id;
	$mediainfo = $this->exec_program("mediainfo ".$file_src);
	preg_match("/General[\s\S]*?Format\s+\:\s+(.*)\s+/",$mediainfo,$m);
	$format = $m[1];
	$format_profile = "";
	if (preg_match("/General[\s\S]*?Format profile\s+\:\s+(.*)\s+/",$mediainfo,$m))
	{
		$format_profile = $m[1];
	}
	$format_info = "";
	if (preg_match("/General[\s\S]*?Format\/Info\s+\:\s+(.*)\s+/",$mediainfo,$m))
	{
		$format_info = $m[1];
	}
	preg_match("/Video[\s\S]*?Frame rate\s+\:\s+(.*?)\s+fps/",$mediainfo,$m);
	//echo $format."\n";
	$fps = $m[1];
	if ($format_info == "Apple")
	{
		// dump audio
		$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
		// encode video from src
		$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		// encode audio
		$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	if ($format_profile == "QuickTime")
	{
		// dump audio
		$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
		// encode video from src
		$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		// encode audio
		$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	if ($format == "MPEG-4")
	{
		$mpeg4tracks = $this->exec_program("MP4Box -info ".$file_src);
		$tracks = preg_split("/\n\n/",$mpeg4tracks);
		$videotrack = false;
		foreach($tracks as $track)
		{
			if (preg_match("/Track # (\d+)[\s\S]*?Visual Stream/",$track,$m))
			{
				$videotrack = $m[1];
			}
		}
		$audiotrack = false;
		foreach($tracks as $track)
		{
			if (preg_match("/Track # (\d+)[\s\S]*?Audio (Stream|Track)/",$track,$m))
			{
				$audiotrack = $m[1];
			}
		}
		if ($videotrack === false) return false;
		$this->exec_program("MP4Box -raw ".$videotrack." ".$file_src." -out ".$files_prefix."_videostream");
		if ($audiotrack !== false) $this->exec_program("MP4Box -raw ".$audiotrack." ".$file_src." -out ".$files_prefix."_audiostream");
		$this->exec_program("mencoder ".$files_prefix."_videostream -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		if ($audiotrack !== false) $this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		if ($audiotrack !== false) $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		else $this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	if ($format == "AVI")//Format Audio Video Interleave
	{
		// dump audio
		$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
		// encode video from src
		$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		// encode audio
		$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	if ($format == "Windows Media")//WMV
	{
		// dump audio
		$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
		// encode video from src
		$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		// encode audio
		$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	if ($format == "Flash Video")//FLV
	{
		// dump audio
		$this->exec_program("mplayer -quiet ".$file_src." -ao pcm:fast:file=".$files_prefix."_audiostream -vc dummy -vo null -channels 2");
		// encode video from src
		$this->exec_program("mencoder ".$file_src." -ovc x264 -x264encopts bitrate=".$vb.":subq=".$X264_SUBQ.":frameref=".$X264_FRAMEREF.":me=".$X264_ME.":bframes=".$X264_BFRAMES.":threads=".$X264_THREADS.":keyint=".$X264_KEYINT." -of rawvideo -vf scale=".$width.":".$height." -ofps ".$fps." -nosound -o ".$files_prefix."_videostream.x264");
		// encode audio
		$this->exec_program("ffmpeg -i ".$files_prefix."_audiostream -strict experimental -acodec aac -ab ".$ab." -ac 2 ".$files_prefix."_audiostream.aac");
		$this->exec_program("MP4Box -new -add ".$files_prefix."_videostream.x264 -fps ".$fps." -add ".$files_prefix."_audiostream.aac ".$file_dst."");
		$this->exec_program("rm -f ".$files_prefix."_*");
		return true;
	}
	return false;
}

VP9

Контейнеры