我正在尝试制作带有MPEG4视频编解码器和AC3音频编解码器的MKV视频,可以使用Mozilla或Chrome在线播放。我尝试了多种方法,包括原生HTML5,它播放视频但没有音频,而且我读过的内容AC3是专有的编解码器,所以它不包含在支持的编解码器中。代码如下:
<video width='1024' height='768' controls autoplay>
<source src="path_to_src" type='video/x-matroska'</video>
然后我尝试使用VLC Web插件(因为我知道VLC可以正确播放文件)但还没有使用它来播放任何文件,在使用此方法的示例中似乎没有很多一致性。以下是我到目前为止使用VLC插件尝试的内容:
<embed type="application/x-vlc-plugin" version="VideoLAN.VLCPlugin.2"
width="1024" height="768" id="vlc" autoplay="yes" target="path_to_file"></embed>
VLC页面here说要添加这个:
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab">
但是代码库似乎不再存在,并且将classid添加到上面的代码中对文件的播放没有影响。这两种方法都会导致制作VLC播放器盒,但没有播放任何内容,开发者控制台也没有显示任何错误。
所以我的问题是,是否有人知道在本机HTML5播放器中播放AC3音频的解决方法或VLC Web插件的正确语法是什么?或者他们会推荐一个完全不同的玩家吗?任何和所有帮助表示赞赏!
您可以使用以下代码。只在Chrome浏览器上工作。
function failed(e) {
// video playback failed - show a message saying why
switch (e.target.error.code) {
case e.target.error.MEDIA_ERR_ABORTED:
alert('You aborted the video playback.');
break;
case e.target.error.MEDIA_ERR_NETWORK:
alert('A network error caused the video download to fail part-way.');
break;
case e.target.error.MEDIA_ERR_DECODE:
alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
break;
case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
break;
default:
alert('An unknown error occurred.');
break;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Amin Developer!" />
<title>Untitled 1</title>
</head>
<body>
<p><video src="http://jell.yfish.us/media/Jellyfish-3-Mbps.mkv" type='video/x-matroska; codecs="theora, vorbis"' autoplay controls onerror="failed(event)" ></video></p>
<p><a href="YOU mkv FILE LINK GOES HERE TO DOWNLOAD">Download the video file</a>.</p>
</body>
</html>
HTML5不支持.mkv / Matroska文件,但您可以使用此代码...
<video>
<source src="video.mkv" type="video/mp4">
</video>
但这取决于浏览器是否会播放。已知此方法可与Chrome配合使用。
HTML5和VLC网页插件对我来说不行,但我能够使用以下设置来完成这项工作:
这是HTML:
<embed id="divxplayer" type="video/divx" width="1024" height="768"
src ="path_to_file" autoPlay=\"true\"
pluginspage=\"http://go.divx.com/plugin/download/\"></embed>
DivX播放器似乎允许比原生HTML5更广泛的视频和音频选项,到目前为止我对它印象非常深刻。
<video controls width=800 autoplay>
<source src="file path here">
</video>
这将仅使用Google Chrome浏览器显示视频(.mkv)。