Why I am not able to read this file. I tried reading this file with cat as :
cat /dev/video0
But it says
cat: /dev/video0 : invalid arguments
Similarly, if I try to use dd as :
dd if=/dev/video0 ~/vid
It still is not able to read it.
Note that video0 is the device file for my webcam.
In such cases, one way to find out more is to run the command in strace
strace cat /dev/video0
which will show more details of the point of failure:
....
open("/dev/video0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(81, 0), ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, 0x2379000, 65536) = -1 EINVAL (Invalid argument)
....
which in my case seems to be saying that my /dev/video0 device does not support the required operation: so in this case, 'cat' is trying to read 64k bytes from the device.
However, I found that using nc (netcat) instead of cat did work for this purpose:
nc -l 1234 </dev/video0
With a corresponding:
nc 127.0.0.1 1234 | mplayer tv://device=/dev/stdin
to display locally; an SSH tunnel port would also work here.