1

A client wants me to write some software, perhaps ffmpeg wrapped in scripting, which will monitor a streaming video feed, and copy clips from it in near real-time, delivering them as self-contained video files. It is not acceptable for me to wait for the feed to finish, and the video to be completely stored as a local file, before I copy the clips. On the other hand, I can take say tens of seconds after the end time of the clip before delivering it. Can I do this without building a video processing suite from scratch? Do I need to require that the streaming video feed be a certain format?

So say the video feed is of a 1-hour live event. At some point, maybe 5 minutes in, my software may get the command, "clip from 4 minutes 30 seconds to 6 minutes 0 seconds, save as file X.mpg". I have to tap into the video feed, copy 90 seconds of video, and store it as file X.mpg, by about 7 minutes in. The actual times are more flexible, I just want to emphasise that I must be able to tap into the streaming feed in progress, I can't wait for a static video file.

I don't even know if streaming video formats permit this kind of operation. If a receiver writes the feed to disc, will the beginning of the file be legal syntax which a normal tool like ffmpeg can parse?

I don't know details of encoding formats, but I understand that they store key frames every so often, and intermediate video frames are stored as differences from the key frame and/or preceding frames. Is it important to know when the key frames are added? Can normal tools parse video past the most recent key frame to the frame just being written, or would the data in the stored file be still be in some temporary state, and thus not yet parseable?

Or, is copying video clips from streaming video a difficult task which requires more sophisticated software than ffmpeg or the like, wrapped with scripts?

Advice on specific formats, and tool chains which make this possible are welcome.

1

This is fairly straightforward if you save to a streaming format like Flash Video (FLV) or MPEG-Transport Stream (MPEG-TS).

Let's say this is your full feed capture command

ffmpeg -i source {-transcoding options} localfile.flv

You can then run

ffmpeg -ss 6:12 -i localfile.flv -t 1:05 -c copy extract.mp4

Ideally, the stream should be past 7:17 or close to it when you run the latter command. Note that since the 2nd command doesn't transcode, inpoint seek isn't precise. The extract will start from the nearest keyframe earlier to the specified inpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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