1
votes

I am uploading the mp4 videos on server and playing them on the front end embeded with HTML video tag. Below is the code which is used.

<video width="480" height="294" controls="controls">
    <source src="http://server.com/user_data/machine/133/videos/1_2.mp4" type="video/mp4">
    <source src="http://server.com/user_data/machine/133/videos/1_2.mp4" type="video/webm">
    <source src="http://server.com/user_data/machine/133/videos/1_2.mp4" type="video/ogg">      
</video>

Problem is, it plays some of the videos and some not. Both are mp4 but it plays some of the videos and others not. And for some, they does not video but only the audio.

Can you help me out on what to check and how to resolve this.

thanks,

3
Check the source type - Afsar
As zan says, your source file extensions (.mp4) of the second two videos do not match the type (web and ogg). - Mick
@Mick, then do i need to also find a way to convert them to another two extensions in order to play them , like using ffmpeg library. Or is there any other solution. - Purushottam zende
@Purushottamzende - if you really want the video to be available on as many browsers and devices as possible then, unfortunately, yes. There are cloud based conversion services such as cloudconvert.com/mp4-to-ogg as alternatives to using ffmpeg yourself. If you don't need to get everybody then mp4 is probably the best bet for most coverage with a single format. - Mick

3 Answers

1
votes

For different source you should have different types of video

File    Type
MP4     video/mp4
WebM    video/webm
Ogg     video/ogg
0
votes

Zende if you want to embed .webm or .ogg format of video in website then you have to convert the video in .webm or .ogg format

0
votes

Also make sure your website serves the right MIME-type for the file. If you are using nginx you need to install the http_mp4_module.