Play Any Video in Adobe Air With FFMPEG
I have to say, I've been having a lot of fun playing with Air 2. Among the many new features included are the new NativeProcess and the update to NetStream that lets you append bytes to the incoming data stream. As a result I've create an example application that can dynamically transcoding any video FFMPEG can decode and play it in Air.
However this is very CPU intensive since the video has to be transcoded into a flv format. However I'm planning on adding support in the future. So if it detects that the original stream is compatible it'll just send it to Air without any transcoding taking place.
You can download the sample application below or check out the source code. Enjoy!
FFMPEG 0.6 + Erlyvideo
Previously I posted about compiling FFMPEG with RTMP support. Now I'm going to describe what you have to do to view that content with Erlyvideo running on OSX of course.
Assuming you have MacPorts installed. Run the following command:
sudo port install erlang
Once that is done you are ready to install Erlyvideo. Go here for up to date install instructions (you will also need git installed).
Finally on to the fun stuff. go to http://localhost:8082/
Assuming everything worked alright you should see the flash content loaded. Go ahead open up terminal and run the following command replacing INPUT_FILE with the file of your choice.
ffmpeg -i INPUT_FILE -re -ac 2 -acodec libfaac -vcodec libx264 -vpre default -s 480x320 -f flv rtmp://localhost:1935/rtmp/test
Now switch back to your browser where you have the erlyvideo page loaded. replace the url at the top of the page with.
rtmp://localhost:1935/rtmp/test
Click on the Connect button.
Then towards the bottom of the page click the Play button.
Congratulations you are now streaming video to erlyvideo!!!
Compiling FFMPEG 0.6 with RTMP Support for OSX
The other day FFMPEG released version 0.6 nick named "Works with HTML5". Today I'm going to try to describe the steps on how to compile this new release in OSX with RTMP support. This wont be for the faint of heart.
First you will need to download and install Xcode and then MacPorts. Please go here for MacPort download and install instructions.
Once when MacPorts is done being installed you will need to install a few packages. They include yasm, pkgconfig and openssl. So lets begin getting those installed first. Type the following command into terminal and then press enter.
sudo port install yasm pkgconfig openssl
Once when this is complete you will need to download a few extra files. We are going to compile these manually so we make sure we have the latest and greatest.
FAAC v1.28
FAAD2 v2.7
Lame
LIBRTMP
x264 (download the latest build)
FFMPEG 0.6
First you will want to extract each archive. In OSX you can double-click on the archive to extract or else in terminal use the following command.
tar xzf FILE_NAME.tar.gz
Now it's time to compile each library. Don't worry its very easy. For the rest of the steps we will only be working in terminal. So open it up and navigate to where you downloaded your files. Mine are located in my Downloads folder.
cd ~/Downloads
Enter the following commands to navigate to your faac folder, configure, compile and install.
cd faac-1.28/
./configure
make
make install
Now to compile Faad
cd ../faad2-2.7/
./configure
make
make install
Lames turn
cd ../lame-3.98.4/
./configure
make
make install
RTMP is a little different.
cd ../rtmpdump-2.2e/
make SYS=MacOSX
make install
Your path to h264 will most likely be different from mine.
cd ../x264-snapshot-20100629-2245/
./configure
make
make install
Finally FFMPEG 0.6. This also requires a few more steps.
cd ../ffmpeg-0.6/
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264 --enable-libvpx --enable-librtmp
make
make install
Done! now you are ready to encode your file and send it to an RTMP server. I've been using the following command to test this.
ffmpeg -i INPUT_FILE -re -ac 2 -acodec libfaac -vcodec libx264 -vpre default -s 480x320 -f flv rtmp://localhost:1935/rtmp/test
Just replace INPUTE_FILE with the video you want to transcode and rtmp://localhost:1935/rtmp/test with the RTMP server you want to publish to. This could be a Flash Media Server, Wowza Server, Red5, Erlyvideo or any other server that supports this functionality.
Introducing Xuggler 3.4
I have to say I'm rather pleased to find this bit of information cross my way. It appears Xuggler has released a new version 3.4. Xuggler is a java based projected that uses FFMPEG to encode content into flash friendly content. One of the great new features that I'm excited about is the new ability to stream while only using Xuggler. That means if you are just serving video you can do it with out using Red5, FMS or Wowza.
Grab the goods here
