Monday, August 26, 2013

Video streaming - little 'bit'

I want to show a video on my website?

There are two ways:

1. Upload it on a video hosting site and use the embed URL
2. Use your own js player and source it from a streaming server

So what is a streaming server?

There are various protocols for streaming. RTSP kind of proprietary from Adobe has ruled the world with flash players. But now we are moving back to HTTP.

In streaming what is required is, data is sent in chunks and not the whole file.

There are two ways to it:

1. The server does all the job (chunking the files and sending it)
2. There are video containers which help us doing this job. Say MP4

So if you are using a proper file format, say mp4, lot of the work is done by the file itself. And then there is encoding on the top to compress the video.

The player would seek for chunks and the server would answer the same. That is how we can jump to positions.

A 5 minute video can be compressed at different bit rates that would determine the amount of bits received in the same time and thus the quality of video.

Here is sample to use a known js video player http://www.videojs.com/

Where I am streaming from?

1. AWS S3 bucket (make it public and take the name. You can cname it)
2. Google drive. The trick is to use this URL format http://drive.google.com/uc?export=download&id=<FILE_ID>. You can easily see the file id once you open it. Of course you have to give necessary permissions to the object.

<html>
<head>
<link href="http://vjs.zencdn.net/4.1/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.1/video.js"></script>
</head>
<body>
<video id="example_video_1" class="video-js vjs-default-skin"
  controls preload="auto" width="640" height="264"
  poster="http://video-js.zencoder.com/oceans-clip.png"
  data-setup='{"example_option":true}'>
 <!--source src="http://www.w3schools.com/html/mov_bbb.mp4" type='video/mp4' /-->
 <!--source src="https://s3-ap-southeast-1.amazonaws.com/brox.in/mov_bbb.mp4" type='video/mp4' /-->
 <source src="http://drive.google.com/uc?export=download&id=0B8BBWYGTqGNhRFplVGxZbHNTX00" type='video/mp4' />
 </video>
<iframe src="https://docs.google.com/file/d/0B8BBWYGTqGNhRFplVGxZbHNTX00/preview" width="640" height="385"></iframe>
</body>
</html>

I have put the embed url for the context. You have very less, or say none, skinning control with embed url. With custom player you can rock and roll.

I have played with RED5 andn Wowza media servers. But I don't think you would need any of those unless you are upto live streaming.

If you have something to add do add a comment, as I am learning !!

Sunday, August 11, 2013

blackday for yatra.com

I opened yatra.com and it was not the one I was looking for !! What the hell happened??

The message was to renew domain. Even more surprising!! I looked on whois and found yatra.com has expired on 9th Aug! How can a big company like yatra could do such a mistake?? I know Monday it will be alarming for so many companies.

$ dig ns yatra.com

; <<>> DiG 9.8.3-P1 <<>> ns yatra.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 2529
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yatra.com. IN NS

;; Query time: 498 msec
;; SERVER: 202.83.21.12#53(202.83.21.12)
;; WHEN: Sun Aug 11 22:48:07 2013
;; MSG SIZE  rcvd: 27

$ dig +nocmd yatra.com any +multiline +noall +answer
yatra.com. 5421 IN A 208.91.197.132
yatra.com. 141388 IN NS ns2.pendingrenewaldeletion.com.
yatra.com. 141388 IN NS ns1.pendingrenewaldeletion.com.

So from the story so far it appears that as yatra.com was not renewed they pointed it to some random IP from ns2.pendingrenewaldeletion.com pool.

Even though the TTL for yatra.com was low 5 minutes and very zone cache as 3 hours the site it not back from the NS (202.83.21.12 - ACT broadband) I was using. I got it working when I changed to google open DNS.

Does it have something to do with pendingrenewaldeletion.com TTL?

Data from fixed DNS.

$ dig +norec ns yatra.com

; <<>> DiG 9.8.3-P1 <<>> +norec ns yatra.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9540
;; flags: qr ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;yatra.com. IN NS

;; Query time: 9 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Aug 11 23:16:22 2013
;; MSG SIZE  rcvd: 27

$ dig +nocmd yatra.com any +multiline +noall     +answer
yatra.com. 79 IN SOA ns4.netmagicians.com. postmaster.netmagicians.com. (
2013081102 ; serial
10800      ; refresh (3 hours)
3600       ; retry (1 hour)
604800     ; expire (1 week)
300        ; minimum (5 minutes)
)
yatra.com. 79 IN TXT "MS=ms49031691"
yatra.com. 79 IN TXT "v=spf1 a mx ptr a:202.87.58.131 a:202.87.58.132 mx:pps-mx.netmagicians.com ip4:202.87.58.131 ip4:202.87.58.132 -all"
yatra.com. 79 IN MX 10 pps-mx.netmagicians.com.
yatra.com. 79 IN A 202.87.58.26
yatra.com. 79 IN NS ns4.netmagicians.com.
yatra.com. 79 IN NS ns1.netmagicians.com.
yatra.com. 79 IN NS ns2.netmagicians.com.

$ dig +nocmd yatra.com +noall +answer
yatra.com. 197 IN A 202.87.58.26

Any clue?