First Try on Erlyvideo

Erlyvideo is another free/commercial Flash Media Server alternative, I notice it because it claimed it can streaming video to iPhone. I am looking for a solution directly streaming flv to iPhone for a long time, but still cannot find any.

Movie file location setting
Edit erlyvideo/priv/erlyvideo.conf, parameter: file_dir

iPhone streaming path
http://www.<domain>.com:8082/iphone/playlists/<folder>/<folder>/<filename.ext>.m3u8

Testing result: mp4, mp3 can stream in iPhone successfully, but mp3 playing is not smooth. flv can produce segment file, but cannot play in iPhone.

Flash Player 10.1, Client-side Microphone Recording Demo

Thanks Flash Player 10.1, now we can record the sound through microphone directly in browser without the use of Flash Media Server, you can download the wav file converted from ByteArray immediately, you can download mp3 which I send wav file to server and using LAME to encode as mp3. Hope AS3 mp3encoder can come out in one day, then a pure client side microphone recording dream will come true since Flash Player 6!

[Demo]

To learn how to use microphone to record sound, you can check this devnet article.

Some installation notes on Flash Media Server 3/3.5

Port 80 Issue
FMS 3.5 comes with Apache, since server installed Apache, so do not install it. I want HTTP Tunneling, so chose Port 1935,80 during installation. When FMS started, Apache cannot run, because port 80 is listened by FMS now. Therfore if you get one server only, running web server and FMS, cannot use HTTP Tunneling. You can edit conf\fms.ini
ADAPTOR.HOSTPORT = :1935

Becareful 19350
When study conf\_defaultRoot_\Adaptor.xml, found one line:
<HostPort name="edge1" ctl_channel="localhost:19350">
Why it is 19350, I thought that it was my careless to modify it before, so I changed to 1935, and then even FMS is running, but cannot connect to any applications

Convenient VOD and Virtual Directory
FMS 3.0 comes with a very convenient applications “vod”, it is for streaming video, you can just put FLV under applications\vod\media\, connect to rtmp:/vod, then it can stream video. vod support virtual directory, you can edit applications\vod\Application.xml, under <VirtualDirectory> add new node:
<Streams>/test;C:\Video</Streams>
Suppose a FLV at C:\Video\folder1\video_1.flv, you can code like that:
var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp:/vod");
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("test/folder1/video_1");

Change the FlashCom Recorded FLV File Permission in Linux

In Linux server, the FLV recorded by FlashCom, file permission by default is 0660 (rw-rw—-). Tonight, I did some jpg screen capture from the video frame using FFmpeg through exec in PHP. It is so strange the conversion never success. Firstly, I thought it is PHP permission problem, I found I can run exec on FFmpeg -version without problem. Next, I thought it was the jpg saved folder forgot to set a write permission, I checked that I have done. Thirdly, I wondered is it FlashCom locks the just created FLV, but after restart FlashCom, it was still not work.

So, I try to use php exec FFmpeg on some FLV encoded in video encoder. Oh, the conversion is work without any problem. Therefore, I sure it was the problem on the FlashCom recorded FLV, I thought may be the file ownership problem but finally find out it is the file permission problem, “Other” has no right to read the file.

My immediate reaction was using chmod in php to change it to 664 (rw-rw-r–), but it come out php error said it does not have such right to chmod on the file. I think FlashCom should not such stubborn cannot change file permission. I scan through all the XML configuration files. I find Server.xml: <Mask>017</Mask> for setting the file permission. It is octal format, by 666 – x = wanted permission. I want 664, so 666-664, x=2, I change that line to:
<Mask>002</Mask>

Save and restart FlashCom, all the problems solved 🙂

FFmpeg usage command

2007-8-6 Update: Based on the my own FLV conversion knowledge, I have started a Web 2.0 service call – VCASMO. It is a video + PowerPoint online presentation platform.

Convert other video to FLV
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv
-i input file name
-ar audio sampling rate in Hz
-ab audio bit rate in kbit/s
-f output format
-s output dimension

Convert other video to FLV with metadata
You have to install flvtool2, too, see my previous post
ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 - | flvtool2 -U stdin video.flv

Convert FLV to jpg sequence
ffmpeg -i video.flv -an -r 1 -y -s 320x240 video%d.jpg
-i Input file name
-an disable audio
-r fps
-y overwrite file
-s output dimension

Convert particular frame to jpg
ffmpeg -i video.flv -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 320x240 video%d.jpg
-ss record start time
-t record end time last for
So if you want to save frame 4 (00:00:04) -ss 00:00:03 -t 00:00:01. Note: it is count from 00:00:00. Even you want to save one jpg, you still need to use %d for naming, it is strange that I grab one frame for one second, it will return two identical jpg files for me

Related Article

Other Reference

One-stop Installation Guide for Create a Linux Server-side FLV conversion environment

2007-8-6 Update: Based on the my own FLV conversion knowledge, I have started a Web 2.0 service call – VCASMO. It is a video + PowerPoint online presentation platform.

If you want to convert other video format to FLV (sorenson codec), everybody will suggest using FFmpeg. In fact, only FFmpeg is not enough for successfully create a server-side command line conversion environment to create FLV with video and audio, plus the FLV 1.1 metadata information. I have stroked for a whole day to setup my Linux server (Fedora Core 3), so I wrote down my note here for other people and myself as a reference.

Purely install FFmpeg is not enough, the FLV converted has no audio, because FLV audio codec is mp3, so you need LAME support. Moreover, the FLV converted has no metadata, you cannot know the dimension, duration such important information for a FLV player swf. Therefore, you need another free tool: FLVTool2, which is written in Ruby, so I have to install Ruby in my server, too.

Overall installation order: LAME->FFmpeg->Ruby->FLVTool2, if you want to access video info through FFmpeg in php, you can install ffmpeg-php, too.

Please login as root first:

Install LAME
Download from LAME site, type the following command to compile and install it:
./configure --enable-shared --prefix=/usr
make
make install

enable-shared to make sure FFmpeg can use LAME later. Type lame in command line to see help after install succeed.

Note: you can also use yum to install FFmpeg, it will install dependency LAME, too, so you can skip this step.
yum install ffmpeg

Install FFmpeg
Download from FFmpeg site through CVS, type the following command to get the latest copies from CVS and save to your $home (currenly path after login into consule) with folder name “ffmpeg”:cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
To compile and install it, type the following command:
./configure --enable-gpl --enable-mp3lame --enable-shared --prefix=/usr
make clean && make
make install

enable-shared to make sure ffmpeg-php can use FFmpeg later (if you do not use ffmpeg-php, you do not need –enable-shared –prefix=/usr). Type ffmpeg in command line to see help after install succeed.

Note: you can also use yum to install FFmpeg:
yum install ffmpeg

Install Ruby
Download from Ruby site, type the following command to compile and install it:
./configure
make
make install

Install FLVTool2
Download from FLVTool2 site, type the following command to compile and install it:
ruby setup.rb config
ruby setup.rb setup
sudo ruby setup.rb install

Type flvtool2 in command line to see help after install succeed.


Installation is completed here. If you want to access video infomation easily in php, there is a ffmpeg-php you can try. You can follow the instruction inside the package to install it. I installed it as a Shared Extension and did not edit php.ini to add extension=ffmpeg.so When I try its test_ffmpeg.php to verfiy the installation. I saw an error:Unable to load dynamic library './ffmpeg.so' - ./ffmpeg.so: cannot open shared object file: No such file or directoryYou have to copy ffmpeg.so to your php extension folder, or like me, I just copy the file to the same folder of the php script is located.

Follow up

Other Reference

Using ffmpeg Convert FLV to Other Video Format Has No Audio Problem

At this moment, recording sound in FlashCom, then use ffmpeg convert to MP3 for Podcasting is impossible. Because FlashCom FLV audio codec – NellyMoser is a closed format.

Other Reference

Solution

Server-side delete FLV

If use other Server-side Program to delete the just recorded FLV, FlashCom may lock the file and cannot successfully delete. The correct way to do it is using SSAS:
[code lang=”actionscript”]var s = Stream.get(”flvName”);
if (s) {
s.onStatus = function(info) {
if (info.code == “NetStream.Clear.Success”) {
trace(”Stream cleared successfully.”);
}
if (info.code == “NetStream.Clear.Failed”) {
trace(”Failed to clear stream.”);
}
};
s.clear();
}[/code]
Caution: flvName does not need extension(.flv).

Install FlashCom in Fedora Core3

Macromedia documentation states FlashCom support Red Hat Linux 7.3/8, there are also provided Install script for Red Hat Linux 9 or Red Hat Enterprise version 3 WS, my server is Fedora Core3, it can successfully install FlashCom, too. The installation step follows the thread in this forum.

Other Reference Articles