简体   繁体   中英

Play video using HTML5 video tag

Hi i need to display video in all the browsers using html5.

I am uploading the file and creating html structure and it plays only mp4 format video, but not other uploaded formats, and i use command line to convert files but the converted files doesn't play in video tag.

For conversion I use ffmpeg video conversion from one to webm format. Conversion works, but viedos don't play.

Please find me ffmpeg code, which converts all videos to webm , so i can play the converted video using html5.

Best choice i think, use 2 types of video. Ogg and mp4

So in all browsers it will work

Example:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

you can look at the link

Well, http://caniuse.com/webm has some clear information about which browsers can use webm. I disagree with mp4 & ogv -> should be mp4 and webm.

<video width="320" height="240" controls>
 <source src="movie.webm" type="video/webm">
</video>

Here is the command line.

ffmpeg -i movie.mov -c:v libvpx -g 52 -b:v 4000k \ 
-maxrate 4000k -bufsize 8000k -force_key_frames 00:00:00.000 \
-f webm -c:a libvorbis -b:a 128k movie.webm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM