脚本宝典收集整理的这篇文章主要介绍了php – ffmpeg修复视频方向,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
要解决此问题,必须旋转视频,并且需要正确设置元信息.
ffmPEg是否为此提供了修复,或者我必须采取哪些措施(Read rotation,旋转,设置元数据)
$ffmpeg == "path/to/ffmpeg"; $output_file_full = "file/after/normal/conversion"; // get rotation of the video ob_start(); passthru($ffmpeg . " -i " . $output_file_full . " 2>&1"); $duration_output = ob_get_contents(); ob_end_clean(); // rotate? if (PReg_match('/rotate *: (.*?)\n/',$duration_output,$matches)) { $rotation = $matches[1]; if ($rotation == "90") { echo shell_exec($ffmpeg . ' -i ' . $output_file_full . ' -Metadata:s:v:0 rotate=0 -vf "transpose=1" ' . $output_file_full . ".rot.mp4 2>&1") . "\n"; echo shell_exec("mv $output_file_full.rot.mp4 $output_file_full") . "\n"; } else if ($rotation == "180") { echo shell_exec($ffmpeg . ' -i ' . $output_file_full . ' -Metadata:s:v:0 rotate=0 -vf "transpose=1" ' . $output_file_full . ".rot2.mp4 2>&1") . "\n"; echo shell_exec($ffmpeg . ' -i ' . $output_file_full . '.rot2.mp4 -Metadata:s:v:0 rotate=0 -vf "transpose=1" ' . $output_file_full . ".rot.mp4 2>&1") . "\n"; echo shell_exec("mv $output_file_full.rot.mp4 $output_file_full") . "\n"; } else if ($rotation == "270") { echo shell_exec($ffmpeg . ' -i ' . $output_file_full . ' -Metadata:s:v:0 rotate=0 -vf "transpose=2" ' . $output_file_full . ".rot.mp4 2>&1") . "\n"; echo shell_exec("mv $output_file_full.rot.mp4 $output_file_full") . "\n"; } }
我使用了一些丑陋的临时文件.对于那个很抱歉.
以上是脚本宝典为你收集整理的php – ffmpeg修复视频方向全部内容,希望文章能够帮你解决php – ffmpeg修复视频方向所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。