views:

2810

answers:

5

I work with a Panasonic hcm280a camera that can be controlled by my software, It generates a stream of jpeg files that are huge and I want to convert this stream to a FLV stream preferably with a good compressional ration

Does FFMpeg do that? I am basically looking for an off the shelve open source software (or commercial software) that can generate that streaming media for me. Again my input is a stream of jpg files that come from the camera server.

Any insight or comment would be greatly appreciated Thanks

+2  A: 

Answers to this question confirm that FFmpeg is able to build a video from a sequence of images. However, no detail is given there.

In FFmpeg FAQ you can find:

3.2 How do I encode single pictures into movies?

First, rename your pictures to follow a numerical sequence. For example, img1.jpg, img2.jpg, img3.jpg,... Then you may run:

ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg

Notice that %d is replaced by the image number.

img%03d.jpg means the sequence img001.jpg, img002.jpg, etc...

The same logic is used for any image format that ffmpeg reads.

mouviciel
But I have streams of images, I don't have a bunch of picture and pictures come as I run my webcam, I want something that continuously runs on the server and encode pictures into the stream as they arrive
Mark
Sorry, I was confused by the "jpeg files" expression.
mouviciel
Then you'll need to compile a program that uses the ffmpeg libraries (libavcodec/libavformat) directly. The command-line tools can't really stream, though you could fake it by chunking a certain quantity of JPEGs as files into short streams played end-to-end.
bobince
+1  A: 

This isn't specifically an answer to your question, but www.doom9.org is an excellent source of information video related, worth checking out the downloads and guides

Andrew Bullock
Thanks a lot seems very interesting
Mark
+1  A: 

To do it with ffmpeg. I assume your frame are names as frame0000.jpg, frame0001.jpg, ...

ffmpeg -f image2 -r 1 -i frame%04d.jpg  -s 320x240 -y -an -r 24 out.flv

-r 1 tells that input stream is one frame per second (one image per second), choose the one you like -s 320x240 scales all frames -y -an to overwrite output file and to disable audio recording -r 24 to have 24 fps in the output stream

You can also consider putting -sameq in the middle to preserve quality as much as possible.

To rename all your frames properly, you can use this bash one liner:

i=0 ; for f in *.jpg ; do mv "$f" $(printf "frame%04d.jpg" $i) ; i=$((i+1)) ; done
jetxee
Not sure if we are on a same page, I guess your method generates FLV from a bunch of jpgs already stored on hard drive is that right? My jpeg s arrive as my webcam is running so I cannot assume they all exist already
Mark
Yes. Does it mean you camera generates a MJPEG stream? http://en.wikipedia.org/wiki/Motion_JPEG. If so, you can convert that stream as well. Probably something like -f mjpeg i streamfile will do. Or is it a V4L/V4L2 device? Then you can grab the stream too, smth like, -f mjpeg -vd /dev/video0
jetxee
Or does your cam write an additional JPEG once in a while? In this case I don't know a solution.
jetxee
A: 

Is there a free program that can do this for me, preferably for linux?

John
+1  A: 

Motion outputs flv files using ffmpeg: http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome you can disable the motion detection and make it output continuously (see 'output_all on' 'ffmpeg_video_codec flv').

Dave