How to play html5 video? When is file.m4v file?

I tried several methods, but nobody plays file2.m4v using html5, see screenshot.

But if I use the same file using VLC / Mplayer, it plays the movie perfectly (no problem). Please review the code and details of the file to find the code that it uses:

enter image description here

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> 

Find audio / video codec files:

 $ 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 Failed 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) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) PROGRAM_ID=1 (0x01), PMT_PID: 66(0x42) 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 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 

What else can I use to play this file in a browser? Is there any javascript player available if html5 cannot play it?

+6
source share
4 answers

HTML5 Video is simply an agreement to play certain video formats with a new element for which browsers will implement their own player. HTML5 does not provide players or anything like that.

You should look for codecs and be supported by most browsers, which, if I remember well, are mostly Theora for Video and Vorbis for audio in an OGG container.

Then I remember that Webkit browsers will support Matroska (MKV) containers, using V8 as a video codec and Vorbis for audio.

My recommendation: provide an OGG file with Theora and Vorbis as video and audio codecs, respectively. Inside there is a backup using the MKV file with V8 and Vorbis, and then, if possible, inside the MPG video file using Mpeg2 and MP2 (could not think of something better) as video and audio codecs. Then, as a last resort, the Flash player plays the FLV video file.

An example of what your HTML looks like:

 <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> 

Etc ...; -)

In this configuration, most (if not all) browsers should be able to play your video, preferring the most supported (and most modern) format. "Fallbacking" until they find Flash Player.

For tips on which formats to support: see part of the HTML5 video on Wikipedia . p>

Important: In the code, you refer to the path of the absolute file system, which is completely not accessible to the visitor. Perhaps in src you meant /video/file2.m4v .

+8
source

Try:

 <video id="myVideo" width="300" height="200" preload="auto" src="/var/www/html/video/file2.m4v" type="video/mp4" autoplay controls></video> 

Also try renaming the file to file2.mp4

+6
source

HTML5 is a web standard (in other words, a specification), not a technology, so the phrase "html5 can not play it" implies some misunderstanding on your part. The file is decoded by the browser in accordance with the settings specified in the <video> . It is worth noting that not all browsers and / or operating systems have the same codecs, so first make sure that you can play the video natively.

Firefox, for example, cannot decode anything encoded by the H.264 codec, which, it seems to me, is used in .m4v files (who knows better, please correct me).

Finally, as someone else remarked, your path is most likely wrong. Delete the fragments of the path "var" and "www".

0
source

Your html is correct, therefore either the path is incorrect, the file is invalid, or the browser does not support m4v.

  • / var / www / is very suspicious, but as you say, it works with the avi file, so it’s not him

  • Try using the file: http://ade.apple.com/movies/institute2011/hotel.m4v in src. If it plays, your m4v is probably incorrectly encoded.

  • If you use Firefox or Opera, then the movie will never play because they do not support anything other than WebM and OGG

0
source

Source: https://habr.com/ru/post/898894/


All Articles