Flash/SWF generation to view events

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
teddy
Posts: 15
Joined: Sat Mar 26, 2005 6:05 pm

Flash/SWF generation to view events

Post by teddy »

Viewing content in flash is great b/c it is such a universally installed plugin and it plays smooth video. I think that YouTube.com is an example of the success of a flash-powered movie viewing website.

I setup a zoneminder system a few years ago and I tried to use the Ming software to generate SWF files which are viewable in a flash-enabled web-browser. You can see my old post here:
http://www.zoneminder.com/forums/viewtopic.php?t=4371

I haven't used zoneminder in a while, so I might be out-of-date by even posting this thread...

Recently, I have played around with Ming and Ffmpeg and came up with a better way to do things...

My old method did not compress things much. It just took frame-by-frame jpeg images and made a flash movie out of it. I think that Ming does some compression by adding the second argument of "9" in the $movie->save(); function, but I don't think the compression is as good as it could be.

Anyway, I think it would be better to have flash read an .FLV file movie. The .FLV file can be compressed better, apparently. Using ffmpeg to generate FLV files, I think, does some additional compression on the frame-by-frame changes (or lack thereof) b/t JPEG images.

This is how to generate a .FLV file (called movie.flv) from a series of .JPEG images (named image0001.jpg - image9999.jpg):

Code: Select all

ffmpeg -i image%4d.jpg -f flv movie.flv
NOTE: There is a very important rule to generating a movie from a series of images. The numbering of the images really matters. In my example, the number is 4 digits, ranging from image0001.jpg - image9999.jpg. In turn, I use this code to tell ffmpeg that my input images are numbered using four digits:

Code: Select all

%4d
If you want to output the .FLV to standard output instead of creating a file, just do this instead:

Code: Select all

ffmpeg -i image%4d.jpg -f flv - 
NOTE: ffmpeg has a lot more useful options that you can use (like defining frames per second, resolution, etc.). They are omitted here for the sake of simplicity, but you should use them.

I made a PHP script that runs such a command that outputs the FLV to standard output.

Code: Select all

<?php
$exec_string = "ffmpeg -i image%4d.jpg -f flv - ";
header('Content-type: application/flv');
passthru($exec_string);
?>
NOTE: The header(); command above might not be accurate. I couldn't really find any conclusive documentation on what the header for a FLV file should be. I sort of made this up based on the header for a PDF file, but I changed PDF to FLV. Someone might want to correct this if I am wrong.

At this point, you can do two things:
1. You can try to add the .FLV to a PHP script that generates SWF files using the Ming library.
2. You can create a .SWF file which uses ActionScript to load a .FLV file from a URL.

Option 2 is nice b/c most webservers do not have the Ming extension installed. You can create a SWF file on your own system and upload it.

Both of these options are well documented. Here is one page, for example, that documents this...
http://klaus.geekserver.net/ming-video/examples.html
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Yeah I'm afraid your a bit behind :shock:
If you go to the images tab in options:
ZM_MPEG_LIVE_FORMAT swf or flv
ZM_MPEG_REPLAY_FORMAT swf or flv

and your set to go :wink:
I think we've been doing it for just over a year :?

Cheers, and thank you for an alternative though :D
danmilward
Posts: 35
Joined: Thu Nov 09, 2006 12:02 am
Location: New Zealand

Post by danmilward »

That is really really awesome!!!!!

But really really not obvious - I use the internet EVERY day and nothing leaped out at me.

I think that either the question mark for those options really really needs a list of possible streaming options.

Or possibly even better those two options should be dropdown menus. Where you can simply choose.

I'm just thinking usability here folks, no bad karma meant :)
danmilward
Posts: 35
Joined: Thu Nov 09, 2006 12:02 am
Location: New Zealand

Post by danmilward »

Actually the only other thing I would add to this discussion would be....

How about adding play and pause buttons to the event history flash files - err like youtibe. A progress bar / slider bar that you can use to skip to the desired place would amazing.

d
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

What it is that's available depends on ffmpeg and what projects you compile it with. So it's not really a feature of zm but extended by ffmpeg. ZM streams mjpeg natively.
How about adding play and pause buttons to the event history flash files
We would welcome the development of this but it's not a core feature and I don't thin any of us have the experience to create it. If you know any one, they can contact us here.
danmilward
Posts: 35
Joined: Thu Nov 09, 2006 12:02 am
Location: New Zealand

Post by danmilward »

If you can tell me how the SWF is generated and provide us with the original fla file then we could take a look and have a crack at adding these features for you.
danmilward
Posts: 35
Joined: Thu Nov 09, 2006 12:02 am
Location: New Zealand

Post by danmilward »

If you can tell me how the SWF is generated and provide us with the original fla file then we could take a look and have a crack at adding these features for you.
If this info is provided we might be able to do it :)
jameswilson
Posts: 5111
Joined: Wed Jun 08, 2005 8:07 pm
Location: Midlands UK

Post by jameswilson »

swf files are genersted by ffmpeg on the fly from the jpgs
James Wilson

Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Post Reply