我尝试了几种方法,但没有人使用
html5播放file2.m4v看屏幕截图.
但是,如果我使用VLC / Mplayer使用相同的文件,它可以很好地播放电影(没问题).请参阅以下代码和文件详细信息以查找其使用的代码:
video.PHP:
<html> <head> </head> <body> <video preload="auto" autoplay="autoplay" controls> <source src="/var/www/html/video/file2.m4v" type='video/mp4; codecs="avc1.42E01E,mp4a.40.2"'> </video> </body> </html>
找到文件音频/视频编解码器:
$mplayer -vo null -ao null -frames 0 -identify file2.m4v MPlayer SVN-r33251-4.6.0 (C) 2000-2011 MPlayer Team mplayer: could not connect to socket mplayer: No such file or directory @R_403_159@ to open LIRC support. You will not be able to use your remote control. Playing file2.m4v. TS file format detected. PROGRAM_ID=1 (0x01),PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01),PMT_PID: 66(0x42) TS_PARSE: COULDN'T SYNC VIDEO MPEG4(pid=69) AUdio AAC(pid=68) NO SUBS (yet)! PROGRAM N. 1 ID_VIDEO_ID=69 ID_AUdio_ID=68 FPS not specified in the header or invalid,use the -fps option. Load subtitles in ./ ID_FILENAME=file2.m4v ID_DEMUXER=mpegts ID_VIDEO_FORMAT=0x10000004 ID_VIDEO_BITRATE=0 ID_VIDEO_WIDTH=352 ID_VIDEO_HEIGHT=288 ID_VIDEO_FPS=0.000 ID_VIDEO_ASPECT=0.0000 PROGRAM_ID=1 (0x01),PMT_PID: 66(0x42) ID_AUdio_FORMAT=MP4A ID_AUdio_BITRATE=0 ID_AUdio_RATE=0 ID_AUdio_NCH=0 PROGRAM_ID=1 (0x01),PMT_PID: 66(0x42) ID_START_TIME=28315.35 ID_LENGTH=0.00 ID_SEEKABLE=1 ID_CHAPTERS=0 ========================================================================== opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Unsupported PixelFormat 61 Unsupported PixelFormat 53 Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4) ========================================================================== ID_VIDEO_CODEC=ffodivx ========================================================================== opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUdio: 8000 Hz,1 ch,s16le,0.0 kbit/0.00% (ratio: 0->16000) ID_AUdio_BITRATE=0 ID_AUdio_RATE=8000 ID_AUdio_NCH=1 Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== AO: [null] 8000Hz 1ch s16le (2 bytes per sample) ID_AUdio_CODEC=ffaac Starting playback... Exiting... (End of file) ID_EXIT=EOF
还有什么我可以用来在浏览器中播放这个文件?是否有任何javascript播放器也可用html5无法播放它?
HTML5视频只是一种使用新元素播放某些视频格式的惯例,浏览器将为其实现自己的播放器. HTML5不会提供播放器或类似的东西.
您必须查找大多数浏览器支持的编解码器,如果我记得很清楚,那么在OGG容器中,主要是Theora for Video和Vorbis for audio.
然后我记得Webkit浏览器将支持使用V8作为视频编解码器的Matroska(MKV)容器和用于音频的Vorbis.
我的建议:分别将Theora和Vorbis的OGG文件作为视频和音频编解码器提供.内部使用带有V8和Vorbis的MKV文件提供后备,然后,如果可以的话,使用Mpeg2和MP2(无法想象更好的东西)作为视频和音频编解码器的内部MPG视频文件,后备.
然后作为最后一个后备,Flash播放器播放FLV视频文件.
HTML示例的示例:
<video src="thevideo.ogg"> <video src="firstFallback.mkv"> <object type="video/mpeg" src="secondFallback.mpeg"> <object type="application/x-shockwave-flash" src="player.swf?etc..."> <p>Download <a href="videourl">the video etc...</a><br /> or use a more modern browser to watch online,etc...</p> </object> </object> </video> </video>
等……