安卓手機(jī)在播放視頻的時(shí)候,會(huì)出現(xiàn)彈出默認(rèn)播放器,交互十分差惶室,可用ffmepg 將mp4視頻轉(zhuǎn)成ts格式,用canvas播放玄货。
ffmepg
命令行:
默認(rèn)尺寸
ffmpeg -i g:\final.mp4 -f mpegts -codec:v mpeg1video -b:v 120000k -r 1200 -bf 0 -codec:a mp2 -b:v 120000k g:\111221.ts
特定尺寸
ffmpeg -i g:\yinzi.mp4 -f mpegts -codec:v mpeg1video -s 640x1137 -b:v 120000k -r 1200 -bf 0 -codec:a mp2 -b:v 120000k g:\yinzi3.ts
-s 尺寸
-bv 視頻比特率
-r 幀速率
var canvasvideo1 = document.getElementById('myCanvas');
canvasvideo1.width = cw;
canvasvideo1.height = ch;
url = 'v3.ts';
var videocccc = new JSMpeg.Player(url, { canvas: canvasvideo1, loop: false });
videocccc.play();
videocccc.pause();
videocccc.currentTime