Difference between revisions of "Courses/Design & Technique-Essential Web Design/Q2/06"

From Publication Station
Line 84: Line 84:
Conversion will start. When it is done the new file will be saved.
Conversion will start. When it is done the new file will be saved.


== tags ==
== video tag ==
<source lang="html4strict">
<video controls>
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.mp4"  type="video/mp4">
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.ogv"  type="video/ogg">
</video>
</source>
 
This is the simplest a web video player you can get.
 
A <code><video></code> tag encapsulating 2 <code><source></code> tags, each containing the same video in the different formats <code>mp4 and ogv</code>.
 
The argument <code>controls</code> make sure the video players has controls.
 
 
== video tag attributes ==
Besides <code>controls</code> the <code><video></code> has a number of other attributes.
 
* controls - if present, show  player's controls
* autoplay - if present, automatically start player as page loads.
* loop - if present,
* poster - presents a poster image while the video is stopped  as
* height
* width


<source lang="html4strict">
<source lang="html4strict">
<video width="320" height="240" controls>
<video controls loop width=800 poster="http://static.ddmcdn.com/gif/tour-de-france-top-ways-the-race-has-changed-picnic-130619.jpg">                                                          
   <source src="pr6.mp4"  type="video/mp4; codecs=avc1.42E01E,mp4a.40.2">
   <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.mp4"  type="video/mp4">
   <source src="pr6.webm" type="video/webm; codecs=vp8,vorbis">
   <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.ogv"  type="video/ogg">
  <source src="pr6.ogv"  type="video/ogg; codecs=theora,vorbis">
</video>
</video>
</source>
</source>
==events==


== event listeners==
== event listeners==

Revision as of 16:59, 2 January 2016

audio and video in HTML5

HMTL5 includes a standard way to embed audio and video tags, without the use of flash. It playing audio and video quite easy and opens up a lot of possibilities audio-visual interaction and manipulation.

Let's see how.


preparing your video files

To be certain that your videos will play in all current browsers, you'll need to have videos in both .mp4 and .ogv container formats. [1]


Royalty Free Patented
Codec & containers Theora(video) + Vorbis(audio) > .ogv H.264 (video) + AAC or MP3 (audio) > .mp4
Browsers Firefox, Chrome, Opera Internet Explorer, Chrome, Safari

video codecs and containers explained

Video files such as .avi .mp4 .ogv .mkv are container formats. Like a .zip file which contains other files within it, video container formats define how to store video and audio streams within them. [2]

Each video container allow specific audio and video codecs.

A codec defines the way (the algorithm) by which a audio or video stream is encoded and decoded. [3]


video codes

H264

  • can be embedded in mp4 container
  • is patent-encumbered

Theora

  • can be embedded in any codec, but is most common in .ogv container
  • royalty-free

audio codecs

MP3

  • number of channels: 1 or 2 [4]
  • possible bitrates: 64 kbps, 128 kbps, 192 kbps
  • is patent-encumbered
  • Also known as MPEG-1 Audio Layer 3.

AAC

  • is patent-encumbered
  • number of channels: up to 48
  • Also known as Advanced Audio Coding

Vorbis

  • can be embedded in .ogg (also .mp4, .webm, .mkv) containers
  • royalty-free
  • number of channels: any


prepare your files

As said previously: To be certain that your videos will play in all current browsers, you'll need to have videos in both .mp4 and .ogv container formats. In other words you need to encode your videos into these 2 formats.

There are several solutions to do this, but Miro video converter seems to the best, converting both to .mp3 and .ogg.

Download Miro from http://www.mirovideoconverter.com/

in Miro

  • Select the file you want to convert to .ogv and .mp4
  • Choose the Format menu: ver

For a .mp4 video - with h264 and mp3 codes.

    • Audio MP3
    • Video MP4

For a .ogv video

    • Audio Ogg Vorbis
    • Video Ogg Theora
  • Press the large button: "Convert to ..."

Conversion will start. When it is done the new file will be saved.

video tag

<video controls>
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.mp4"  type="video/mp4">
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.ogv"  type="video/ogg">
</video>

This is the simplest a web video player you can get.

A <video> tag encapsulating 2

</code> tags, each containing the same video in the different formats <code>mp4 and ogv</code>. 

The argument <code>controls</code> make sure the video players has controls.


== video tag attributes ==
Besides <code>controls</code> the <code><video></code> has a number of other attributes.

* controls - if present, show  player's controls
* autoplay - if present, automatically start player as page loads.
* loop - if present, 
* poster - presents a poster image while the video is stopped  as 
* height
* width

<source lang="html4strict">
<video controls loop width=800 poster="http://static.ddmcdn.com/gif/tour-de-france-top-ways-the-race-has-changed-picnic-130619.jpg">                                                           
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.mp4"  type="video/mp4">
  <source src="http://publicationstation.wdka.hro.nl/go-student/Andre-Castro/videos/tour.ogv"  type="video/ogg">
</video>


events

event listeners

[5]


video sources

https://archive.org/details/movies


references

Blog on containers and codecs

AV Codes supported by video containers

notes

  1. Read more on browsers' supported formats in https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
  2. http://diveintohtml5.info/video.html
  3. Note: a lossy audio and video compression codecs try to store the max amount of information in the smallest amount of space. One technique use to achieve this goal in video is the use of key frames instead of sequence of frames. In a second there only two or three key frames are used to create the illusion of movement, the remaining frames are filled with inbetweens, changes og pixel color. When a drastic change to the image occurs a key frame must be created.
  4. Unlike video, audio typically is in stereo, which means that it has 2 channels or streams
  5. All info on av codecs and containers in http://wiki.multimedia.cx/