Video Sharing Website Part 2 : Converting the uploaded video to FLV
Posted on | June 30, 2009 | 2 Comments
This series of blog post will talk about how to setup a Video Sharing Website.
Converting the uploaded video to FLV
This is a ‘on the fly’ conversion example, using Cakephp Framework. I am using the ffmpeg library for the transcoding in my example. The ffmpeg converter supports FLV, MP4 and many more.
ffmpeg supported formats: http://ffmpeg.org/general.html#SEC8
For the most basic video sharing, the user will upload a video, enter a title and a description. The VideoConvertorComponent will take the uploaded video, extract a thumbnail and convert it to FLV. Other users can view the FLV in the flash player.
VideoConvertorComponent:: flv_import() is called in the controller. FLV and thumbnail image is created.
Video Sharing Website Part 1 : Introduction to Video Streaming
Posted on | June 30, 2009 | 1 Comment
This series of blog post will talk about how to setup a Video Sharing Website.
Definition to various methods of video downloads and video format
- Streaming
- HTTP Download
- HTTP Streaming – A combination of Streaming and HTTP Download
Streaming
Use of Video Stream Application servers. Examples of Video Stream Application servers include: Video Desk, Adobe Flash Media Server. To use a Streaming Application Server, you need to have a dedicated server with dedicated bandwidth. Such setups are expensive and can run up to a few thousand dollars per month. This is not for the average user. But more suited for the needs of content delivery network. Like news streaming, on demand TV or Movies. Requires a lot of specialized server setup and maintenance knowledge.
HTTP Download
The usual way files are downloaded completely before you can view them. Longer waiting time. This method would require user to have the plugin that supports the playback installed.
HTTP Streaming
A flash player will play part of the video when it is downloaded. With this method, you can fast forward to any segment you want to watch before the video is downloaded fully. The player will send a request to the server for the seeked segment of the video and the start playing from there. This is call pseudo streaming.
This streaming setup uses three components:
- A Flash Player
- A server side script for the transcoding of uploaded video to different formats, and the pseudo streaming of the video
- An FLV video
The server side script needs to take care of bandwidth throttling, securing the video to prevent leeching, detection of bandwidth to if variable bandwidth video is supported. This will be covered in further posts.
Video Formats Suitable for Online Stream
- FLV (H.263/MP3) – 320px in width
- MP4 (H.264/AAC) – 320px in width ~500kbps
- A TV conversion (720px wide, H.264/AAC, ~1000kbps)
- An HD conversion (1280px wide, H.264/AAC, ~2000kbps)
Higher bitrates or bigger file size will result in longer transcoding time. Since this is the case, the transcoding process has to be ‘behind the scenes’ to avoid letting users wait for a long time. The FLV version is the most commonly used format.
Network Architecture

Max no of characters, max no of words
Posted on | June 9, 2009 | No Comments
Remember if you still remember those school days, when you have to write compositions, you need to mark out exactly 350 words. The purpose is for the marker to know where he or she can stop reading.
PHP functions that does word count
str_word_count()
And on the str_word_count() manual page, these is this helpful function for UTF8 word count
define("WORD_COUNT_MASK", "/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]*/u");
function str_word_count_utf8($string, $format = 0)
{
switch ($format) {
case 1:
preg_match_all(WORD_COUNT_MASK, $string, $matches);
return $matches[0];
case 2:
preg_match_all(WORD_COUNT_MASK, $string, $matches, PREG_OFFSET_CAPTURE);
$result = array();
foreach ($matches[0] as $match) {
$result[$match[1]] = $match[0];
}
return $result;
}
return preg_match_all(WORD_COUNT_MASK, $string, $matches);
}
Do rememebr to strip off all html tags first before you do the word count.




















