[FFmpeg-devel] [PATCH] Use v4l2 input format automatically if filename starts with "/dev/video"

wm4 nfxjfg at googlemail.com
Sat Oct 25 13:40:11 CEST 2014

On Sat, 25 Oct 2014 13:14:26 +0200
Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:

> On Sat, Oct 25, 2014 at 01:10:20PM +0200, wm4 wrote:
> > On Sat, 25 Oct 2014 11:43:12 +0200
> > Nicolas George <george at nsup.org> wrote:
> > 
> > > Le tridi 3 brumaire, an CCXXIII, Timothy Gu a écrit :
> > > > Those URLs are very explicit, while `/dev/` can mean anything,
> > > > including `/dev/stdin`.
> > > 
> > > Andrey quoted these bits of code to show that checking filename for NULL is
> > > not necessary. I believe his proof is conclusive for that point.
> > > 
> > > wm4 :
> > > > IMHO it should check whether it's really a video device.
> > > 
> > > Yes, it should. Do you intend to propose the patch that invokes stat() on
> > > all supported operating systems, check that can not devolve into a security
> > > issue in the context of probing, find the relevant list of major/minor
> > > pairs and a way of testing the dynamically allocated ones soon, or are you
> > > just bikeshedding.
> > 
> > Don't present your extremely bad ideas as mine. Thanks.
> Could you both please either bury or hide your hatchet?
> It is really annoying to all other when you write such obviously
> aggressive and non-constructive emails.

I agree.

> wm4, if you have a simple way of doing this check, please explain it.
> Otherwise I think EXTENSION score is good enough to signal "well, we
> guess that's what it is".

There are two solutions:
- actually open the video device, and try a v4l-only ioctl() to test
  whether it's really a device (the artificial separation between
  avio/probing/actual opening becomes rather annoying here)
- add a specific protocol prefix that forces the input format, and which
  lets the user invoke video capture (think MPlayer's "tv://")

All in all, there's much you can do about raw devices. A video device
probably doesn't even need to be named /dev/video..., nor does that
filename need to be a reliable indicator that the device understand
V4L. Whatever you do, it can't be perfect, because you're working on a
too low level and system specific layer. "tv://" could solve that
actually rather elegantly, including abstracting platform differences
from the user.

More information about the ffmpeg-devel mailing list