机器:192.168.1.233
影片转码:
ffmpeg -y -i oceans.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb out.ts
function getVideoTime($time){
$hour = floor($time/3600);
$time = ($time-$hour*3600);
$min = floor($time/60);
$sec = $time - $min*60;
return sprintf('%2d:%2d:%2d',$hour,$min,$sec);
}
影片分段:
1.获取影片的时长: ffmpeg -i youku.mp4 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,// 00:00:50.33
$time = explode(':',$timeLength);list($hour,$min,$sec) = $time;
$totalSec = $hour*3600+$min*60+$sec;
$sliceTime = 20min;
$hours = $sliceTime%60;
$sliceStep = ceil($totalSec/($sliceTime*60));
for($i=0;$i<$sliceStep;$i++){
$time = getVideoTime($i*$sliceTime*60);
}
2.影片切段: ffmpeg -ss 00:00:00 -t 01:30:00 -i input.mp4 -acodec copy -vcodec copy output1.mp4
影片切片:
[jason@vm-video-convert html]$ mkdir avkey
[jason@vm-video-convert html]$ m3u8-segmenter -i out.ts -n 10 -p avkey/segmenter_test -m test.m3u8 -u http://apjasonphalcon.jav101.com/avkey/
影片转成MP4文件:
ffmpeg -i youku.flv -vcodec libx264 -r 25 -threads 0 -acodec copy -y youku_3.mp4