Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to append one jpeg frame (or a small number of frames) to a video while retaining good image quality and compression? I have a script that downloads a jpeg image from a webcam every 30 seconds. I can build a video out of these frames using ffmpeg or mencoder, e.g.:

ffmpeg -f image2 -i %d.jpg out.swf

I'd like to keep this video up to date as new frames come in, but don't want to keep the computer busy re-encoding the entire video so frequently. I also worry about ffmpeg/mencoder doing something intelligent with only a single frame of new data - e.g. will it try to make each new frame a keyframe (making the video unnecessarily large)?

Any insight on how to do this sensibly would be greatly appreciated.

share|improve this question

2 Answers 2

Why do you want to build it one frame at a time? How does that help you? Why not have your script rebuild the video every 15 minutes (30 frames) or something more reasonable like that?

SWF is an unusual file format for video output. In general, no, you can't add a single frame to the end of SWF (or FLV) movies because it requires a stateful compressor--the compressor would have to remain in RAM and remember the state of the last keyframe and all interframe compression done since then in order to encode the next frame.

If for some reason you absolutely need to add one frame to the end of your in-progress video, use MPEG 1. MPEG 1 video is just a sequence of single frames with no interframe compression, so you can have FFMPEG compress each JPEG and just cat it onto the end of the work in progress. Of course the result will be a huge poorly-compressed file by modern standards.

share|improve this answer
1  
I wanted to build the video one frame (or a few frames) at a time as a way to keep the video up to date without constantly swamping the CPU. This project may expand to include several video feeds, so I wanted to keep efficiency in mind. The video is being used for cloud monitoring at an astronomical observatory, which is why I wanted to keep it as up to date as possible. Most likely, I'll compromise by making two videos - a frequently updated one with just the last 30 minutes of data, and a less frequently updated one with the last 24 hours. I was just curious if frame-at-a-time was possible. –  Kevin Ivarsen Dec 28 '09 at 17:44
    
You can run a script to combine the last 300 JPEG images into a 30 second FLV video (at 10 frames per second) every 15 minutes. You can also write a Flash SWF file that will play all the movies from a given hour or day, in sequence, so that to the viewer it looks like a single movie. No swamping. If you want to be fancy, write a script that combines all the movies from a given day into a single longer movie once very 24 hours at a low-traffic time like 2:00 am. –  CarlF Dec 29 '09 at 6:59

If it's that few frames, convert them into an animated gif instead of a movie (with ImageMagick, for example).

That's how www.weather.gov animates radar imagery.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.