Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

feature: idle frame generation when no input #12

wants to merge 30 commits into


None yet
2 participants

an146 commented Feb 15, 2012

Hi, I've implemented the subj functionality (repeating last received frame or sending a placeholder picture when writer process dies/doesn't send frames in time, more explanation in README).
It has involved some changes in existing code; what worries me is read()/write() implementations, I have changed them appropriately (they might work), but haven't found a way to test them yet; all testing was done with gstreamer's v4l2src/sink using q/dqbuf(). Can you provide me with a hint on how to do it using some existing software?
Anyway, I'll continue playing with it, and probably there are more changes to come, so any your thoughts on code/cooperation will be helpful


umlaeute commented Feb 15, 2012

thanks, i'll have a look at it (and will have to learn how to deal with "merge pull requests" ion github...)


umlaeute commented Feb 15, 2012

actually, what i don't like in your patch is that "idle_fps" is a integer.

shouldn't it be like that:

  • allow for arbitrary values, in a v4l2 (nominator/denominator) fashion?
  • if the producer sets the fps of the stream, should that be taken?

i think this could also solve issue#11


umlaeute commented Feb 16, 2012

so i changed a number of things

  • renamed "idle_fps" to "fps", and linking it to the devices frameduration settings
  • allow to set/get the "fps" via sysfs
  • renamed "placeholder_delay" to "timeout"

what i'm still unsure about is the way how the placeholder frame is injected.
i think using the current way is a bit clumsy (writing to an extra non-announce mmaped buffer). maybe a better way would be to use sysfs for that (have to read the docs about whether it is actually "allowed" to use sysfs for that)


an146 commented Feb 17, 2012

it's impossible to do it with sysfs, the maximum size of files read/written through it is fixed to PAGE_SIZE (e.g. 4096 bytes)
and I think there's no real need for sustaining stream fps at idle times, as long as we set correct timestamps and some existing software chokes at decreased real fps. Also, if no frame arrives in expected 1/fps seconds time, how do we know that it won't be received a millisecond later, and should we really produce a copy of last received frame? Current code actually produces extra frame copies even with local frame input when idle_fps is set equal to stream fps, imagine input stream being read from some unstable network source. I think default of, like, idle_fps <= stream_fps / 2 is reasonable; and if user really wants to override it, he can, through sysfs parameter


umlaeute commented Feb 17, 2012

thanks for the clarification about sysfs.

however, i cannot really follow your explanation about real fps vs idle_fps.
i cannot see any harm done in having idle_fps==fps.
in a causal system, we will never know whether a real frame will arrive 1ms in the future.
therefore we have a timeout.

i think the problem you describe can only happen if you set the timeout to "0".

@umlaeute umlaeute closed this Feb 17, 2012

@umlaeute umlaeute reopened this Feb 17, 2012


umlaeute commented Feb 17, 2012

sorry, i incidentally clicked on "close&comment" rather than "comment"


umlaeute commented Feb 17, 2012

hmm, i'm getting more of your picture.
i included your patch (heavily modified by me) into the "experimental" branch of v4l2loopback.

i re-added the "idle_fps" attribute (though allowed fractions rather than integers), which - if not set (or rather, if the denominator==0) falls back to fps/2.

please check whether this works for you
(esp. i haven't done any tests since i merged with feature/fix-format)

@an146 an146 closed this Mar 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment