我正在使用ffmpeg将wmv转换为mp4文件,但它没有';t在html5视频标签上播放


I am converting wmv to mp4 file using ffmpeg but it doesn't play on html5 video tag

我在php中使用的是ffmpeg 1.2.3版本。它成功地将视频转换为mp4,我可以使用flv播放器播放,但当我将此视频添加到html5视频标签时,它无法正常工作。

命令是

shell_exec("/usr/bin/ffmpeg -i /var/www/html/vid/upload/inputfile.wmv -s 500x400 -strict -2  /var/www/html/vid/mp4videos/outputfile.mp4 2>&1");

HTML代码

<video width="100%" height="100%" controls><source src="mp4videos/outputfile.mp4" type="video/mp4"></video>

您必须在命令行中使用-vcodec libx264(使用H264视频格式)。

ffmpeg -i /var/www/html/vid/upload/inputfile.wmv -s 500x400 -vcodec libx264 -strict -2  /var/www/html/vid/mp4videos/outputfile.mp4

HTML5视频并不能读取所有的视频格式。

维基百科链接。

shell_exec("/usr/bin/ffmpeg -i /var/www/html/vid/upload/inputfile.wmv -f mp4 -s 500x400 -strict -2  /var/www/html/vid/mp4videos/outputfile.mp4 2>&1");

这适用于我的

 exec("ffmpeg -y -i /var/www/html/vid/upload/inputfile.wmv -c:v libx264 -c:a aac -pix_fmt yuv420p -movflags faststart -hide_banner /var/www/html/vid/mp4videos/outputfile.mp4");

faststart选项非常重要。