Opened 2 years ago

Last modified 2 years ago

#5850 open defect

Using Hauppauge HD-PVR fails (streaming I/O)

Reported by: naums Owned by:
Priority: normal Component: avdevice
Version: git-master Keywords: v4l2
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Using the Hauppauge HD-PVR does not work anymore. Used to work on Ubuntu 14.04, does not at Ubuntu 16.04 nor at Arch Linux. A self-compiled avplay does the job. If it helps: open broadcast studio (obs-studio) cannot open the device-file either, same error as 'ffplay /dev/video0'

I used Arch Linux for the output below:

How to reproduce:

% ffplay /dev/video0
ffplay started on 2016-09-16 at 19:44:29
Report written to "ffplay-20160916-194429.log"
Command line:
ffplay /dev/video0 -report
ffplay version 3.1.3 Copyright (c) 2003-2016 the FFmpeg developers
  built with gcc 6.1.1 (GCC) 20160802
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 48.101 / 57. 48.101
  libavformat    57. 41.100 / 57. 41.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 47.100 /  6. 47.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
[video4linux2,v4l2 @ 0x7f5478009240] fd:7 capabilities:81220001/0   
[video4linux2,v4l2 @ 0x7f5478009240] The device does not support the streaming I/O method.
/dev/video0: Function not implemented

Using the device with 'cat /dev/video0 > test.mp4' works perfectly well. Even 'gst-play-1.0 /dev/video0' works. Output of v4l2-ctl:

% v4l2-ctl --all -d /dev/video0
Driver Info (not using libv4l2):
	Driver name   : hdpvr
	Card type     : Hauppauge HD PVR
	Bus info      : usb-0000:00:14.0-4
	Driver version: 4.7.2
	Capabilities  : 0x81220001
		Video Capture
		Audio
		Read/Write
		Extended Pix Format
		Device Capabilities
	Device Caps   : 0x01220001
		Video Capture
		Audio
		Read/Write
		Extended Pix Format
Priority: 2
Video input : 0 (Component: ok)
Audio input : 0 (RCA back)
Video Standard = 0x0000f900
	PAL-M/60
	NTSC-M/M-JP/443/M-KR
DV timings:
	Active width: 720
	Active height: 480
	Total width: 858
	Total height: 525
	Frame format: interlaced
	Polarities: -vsync -hsync
	Pixelclock: 13500000 Hz (59.94 fields per second)
	Horizontal frontporch: 19
	Horizontal sync: 62
	Horizontal backporch: 57
	Field 1:
	Vertical frontporch: 4
	Vertical sync: 3
	Vertical backporch: 15
	Field 2:
	Vertical frontporch: 4
	Vertical sync: 3
	Vertical backporch: 16
	Standards: CEA-861
	Flags: half-line, CE-video
DV timings capabilities:
	Minimum Width: 720
	Maximum Width: 1920
	Minimum Height: 480
	Maximum Height: 1080
	Minimum PClock: 27000000
	Maximum PClock: 74250000
	Standards: CEA-861
	Capabilities: Interlaced, Progressive
Format Video Capture:
	Width/Height      : 720/480
	Pixel Format      : 'MPEG'
	Field             : Interlaced
	Bytes per Line    : 0
	Size Image        : 8192
	Colorspace        : SMPTE 170M
	Transfer Function : Default
	YCbCr Encoding    : Default
	Quantization      : Default
	Flags             : 

User Controls

                     brightness (int)    : min=0 max=255 step=1 default=128 value=128 flags=slider
                       contrast (int)    : min=0 max=255 step=1 default=64 value=64 flags=slider
                     saturation (int)    : min=0 max=255 step=1 default=64 value=64 flags=slider
                            hue (int)    : min=0 max=30 step=1 default=15 value=15 flags=slider
                      sharpness (int)    : min=0 max=255 step=1 default=128 value=128 flags=slider

Codec Controls

                    stream_type (menu)   : min=0 max=1 default=1 value=1 flags=update
                 audio_encoding (menu)   : min=0 max=4 default=3 value=3 flags=update
                 video_encoding (menu)   : min=0 max=2 default=2 value=2
             video_bitrate_mode (menu)   : min=0 max=1 default=1 value=1 flags=update
                  video_bitrate (int)    : min=1000000 max=13500000 step=100000 default=6500000 value=6500000
             video_peak_bitrate (int)    : min=1100000 max=20200000 step=100000 default=9000000 value=9000000 flags=inactive

Attachments (1)

patchv4l2.diff (406 bytes) - added by cehoyos 2 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 2 years ago by cehoyos

  • Component changed from undetermined to avdevice
  • Keywords v4l2 added; hdpvr video4linux removed
  • Status changed from new to open
  • Version changed from unspecified to git-master

Related to ticket #4708
The following should also work:

$ cat /dev/video0 | ffplay -

comment:2 Changed 2 years ago by cehoyos

Or simpler:

$ ffmpeg -i file:/dev/video0

Changed 2 years ago by cehoyos

comment:3 Changed 2 years ago by cehoyos

Please test if the attached patch fixes the issue for you.

comment:4 follow-up: Changed 2 years ago by naums

to the first to commenters: these work but only for mere seconds, then the device shuts itself off and the video freezes.

The patch has no effect. Without file:/ does not work, and with file:/ same as above.

comment:5 in reply to: ↑ 4 ; follow-up: Changed 2 years ago by cehoyos

Replying to naums:

to the first to commenters: these work but only for mere seconds, then the device shuts itself off and the video freezes.

Not sure I understand:
The following works perfectly well?

$ cat /dev/video0 > test.mp4

But this does not?

$ cat /dev/video0 | ffplay -

The patch has no effect. Without file:/ does not work, and with file:/ same as above.

Thanks for testing!

comment:6 in reply to: ↑ 5 Changed 2 years ago by naums

Replying to cehoyos:

Replying to naums:

to the first to commenters: these work but only for mere seconds, then the device shuts itself off and the video freezes.

Not sure I understand:
The following works perfectly well?

$ cat /dev/video0 > test.mp4

This works perfectly well.

But this does not?

$ cat /dev/video0 | ffplay -

This works for about five to ten seconds, the video freezes and the device shuts its light off, the last frame sticks. There is btw. a latency of about four seconds from executing the command to seeing the first frame (the device introduced some latency of about a second, the rest seems to be ffplay).

Is there any way to give more information that might help you? Is it for example possible to see the filling-percentage of internal video buffers?

comment:7 follow-up: Changed 2 years ago by cehoyos

And this also doesn't work, correct?

$ ffplay -i file:/dev/video0

And the same is true if you don't use ffplay but ffmpeg?

$ cat /dev/video0 | ffmpeg -i - -qscale 2 out1.avi
$ ffmpeg -i file:/dev/video0 -qscale 2 out2.avi

comment:8 in reply to: ↑ 7 Changed 2 years ago by naums

Replying to cehoyos:

And this also doesn't work, correct?

$ ffplay -i file:/dev/video0

doesn't work, same as above

And the same is true if you don't use ffplay but ffmpeg?

$ cat /dev/video0 | ffmpeg -i - -qscale 2 out1.avi
$ ffmpeg -i file:/dev/video0 -qscale 2 out2.avi

Both work for over a minute (so I'm assuming that it will work even longer). Interesting thing to note is, that it seems to build up a buffer at the start, then render the video at 2x speed, becoming slower as the buffer gets empty.

EDIT: the parameter -qscale 2 is not needed, works also without it.

Last edited 2 years ago by naums (previous) (diff)

comment:9 Changed 2 years ago by naums

Hello,

I've done some more testing (with avplay and open broadcast software (OBS)). I've tried building avconv 12 myself and tested it with the HD PVR: Segmentation fault on

./avplay /dev/video0

I've built avplay 11.8 and it works fine (opens the device correctly and plays the video-stream correctly. Does not stop after some seconds. Call like above.

So I went into it and built shared libaries and changes the version numbers of libavdevice, libavcodec and libavformat to 57 (like the ffmpeg-ones in my computer), and libavutil to 55. Then ran configure and make again:

./configure --enable-shared
make

So I got libavdevice.so.57 and the other files. Told my system to look for the libs in this directory (after moving the files into the libav-main-folder) by

export LD_LIBRARY_PATH=$(pwd)

and ran OBS -> crashed, could not initiate some audio-buffers. Okay. Deleted every avconv-Shared Object file except for libavdevice.so.57 and it works quite fine. Opening the HD PVR in OBS works fine now.

On a side note: using the device with ffplay also works fine, when opening like:

# this works fine
ffplay /dev/video0

# this does not work (same error as above)
ffplay file://dev/video0

I guess ffplay (and therefore the current ffmpeg-libav) considers the HD PVR-file as regular file, not as streamable(?). Patching the libavdevice with the one from avconv 11.8 apparently fixes this behaviour and lets ffplay use the device as a video-stream.

I hope that helps in any way to fix the bug.

Kind regards

Last edited 2 years ago by naums (previous) (diff)

comment:10 Changed 2 years ago by cehoyos

If you just need a work-around, please try the following:

$ ffplay -probesize 32 -analyzeduration 0 file:/dev/video0

This assumes that the stream is really mp4-compatible, a larger probesize would be needed for other stream types.

Note: See TracTickets for help on using tickets.