JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
125 stars 53 forks source link

Encoding from live camera #299

Open yakir12 opened 3 years ago

yakir12 commented 3 years ago

This already works if and only if the loop in https://juliaio.github.io/VideoIO.jl/stable/writing/#Iterative-Encoding is quicker than the FPS of the camera. But there are two main cases where this does not hold:

  1. The camera can support really fast FPS, resulting in dropped frames.
  2. The user wants to: a. save an augmented frame (instead of the original one, e.g. filtered, transformed, etc.), resulting in dropped frames and uneven time-stamps per frame (because the processing of each frame might not be even). b. split the stream, one stream gets encoded as is, and one stream feeds some other processing line (object detection etc) that has its own product (stats being saved to another file etc). Note that the speeds with which each stream is consumed is not equal.

It would be good to deal with these different scenarios, either as a MWE of how it's done, or some novel implementations.

yakir12 commented 3 years ago

I just wanted to add one additional note:

With opencamera and open_video_out we could have a new (convenience) function, say record_camera, that records from the camera. The user's requirements on the saved video (e.g. framerate) will have to somehow fit the specifications of what the camera can achieve and what the encoder can do.

This however will open the opportunity to either/both specify a user-defined function that will augment the encoded frame (e.g. add overlays) before it is written, OR/AND output a container of the current frame (e.g. Ref) for some side-effects (e.g. calculating statistics, auto tracking movements, etc).

The possibilities are endless :smile:

galenlynch commented 3 years ago

That would be very cool