Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDMI to S-Video glitches with mencoder #20

Open
laimison opened this issue Sep 1, 2018 · 5 comments
Open

HDMI to S-Video glitches with mencoder #20

laimison opened this issue Sep 1, 2018 · 5 comments

Comments

@laimison
Copy link

laimison commented Sep 1, 2018

Hi,

I have tested

  • two different converters:

https://www.ebay.co.uk/itm/Mini-Portable-USB-2-0-Port-HD-1-Way-HDMI-1080P-Video-Capture-Card-For-PC-Laptop/142907175902?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

and

https://www.ebay.co.uk/itm/TV-DVD-VHS-RCA-S-Video-Video-Audio-AV-EasyCAP-Grabber-Capture-USB-2-0-Adapter/183096373306?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649
+
https://www.ebay.co.uk/itm/HDMI-to-3RCA-AV-CVBS-Composite-S-Video-R-L-Audio-Converter-Adapter-Upscaler/262370360688?epid=1140068747&hash=item3d167dfd70:g:gZYAAOSwCpRbEhZ7

  • two different HDMI cables
  • two different computers to output HDMI (PC with GTX1070 and Macbook Pro 2014)
  • Raspberry Pi3 B+ with latest Raspbian Stretch 9 (Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux)

I've got the same result by using any of these converters and cables.

I'm using mencoder command to record test.avi and the output is almost not visible because of many green lines and glitches:

40517727_2246338448931231_4390862817524187136_n

This is a mencoder command which prints some drops (14 frames successfully processed, -10 frames dropped):

pi@raspberrypi:~ $ mencoder tv:// -tv driver=v4l2:norm=NTSC:device=/dev/video0:input=1:fps=5 -nosound -ovc copy -o test.avi
MEncoder 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
success: format: 9  data: 0x0 - 0x0
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <[email protected]>
 comment: first try, more to come ;-)
Selected device: usbtv
 Capabilities:  video capture  read/write  streaming
 supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR; 4 = NTSC-443; 5 = PAL; 6 = PAL-BG; 7 = PAL-H; 8 = PAL-I; 9 = PAL-DK; 10 = PAL-M; 11 = PAL-60;
 inputs: 0 = Composite; 1 = S-Video;
 Current input: 0
 Current format: YUYV
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
[V] filefmt:9  fourcc:0x32595559  size:720x480  fps:5.000  ftime:=0.2000
videocodec: framecopy (720x480 24bpp fourcc=32595559)
Forcing audio preload to 0, max pts correction to 0.
v4l2: select timeout

Skipping frame!
Pos:   0.0s      1f ( 0%)  0.95fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.0s      2f ( 0%)  1.27fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
Pos:   0.0s      3f ( 0%)  1.43fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.0s      4f ( 0%)  1.53fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
Pos:   0.0s      5f ( 0%)  1.59fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.0s      6f ( 0%)  1.85fps Trem:   0min   0mb  A-V:0.000 [0:0]
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:   0.0s      7f ( 0%)  2.13fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s      8f ( 0%)  2.40fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s      9f ( 0%)  2.67fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s     10f ( 0%)  2.93fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s     12f ( 0%)  3.43fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.4s     13f ( 0%)  3.68fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.4s     14f ( 0%)  3.92fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.4s     15f ( 0%)  4.15fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.4s     17f ( 0%)  4.61fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.6s     18f ( 0%)  4.82fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.6s     19f ( 0%)  5.03fps Trem:   0min   0mb  A-V:0.000 [0:0]

Invalid frame duration value (0.520/0.000 => -0.520). Defaulting to 0.040 sec.

Skipping frame!
Pos:   0.6s     20f ( 0%)  4.65fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
Pos:   0.6s     21f ( 0%)  4.35fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.6s     22f ( 0%)  4.11fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
Pos:   0.6s     23f ( 0%)  3.92fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.6s     24f ( 0%)  3.75fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
^Cs:   0.6s     25f ( 0%)  3.61fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.6s     26f ( 0%)  3.50fps Trem:   0min   0mb  A-V:0.000 [0:0]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 27648.000 kbit/s  (3456000 B/s)  size: 2073600 bytes  0.600 secs  26 frames
v4l2: select timeout
v4l2: ioctl set mute failed: Invalid argument
v4l2: 14 frames successfully processed, -10 frames dropped.
pi@raspberrypi:~ $

Another attempt. This time 26 frames successfully processed, 31 frames dropped.:

pi@raspberrypi:/tmp $ mencoder tv:// -tv driver=v4l2:norm=NTSC:device=/dev/video0:input=1:fps=5 -nosound -ovc copy -o test.avi
MEncoder 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team
success: format: 9  data: 0x0 - 0x0
TV file format detected.
Selected driver: v4l2
 name: Video 4 Linux 2 input
 author: Martin Olschewski <[email protected]>
 comment: first try, more to come ;-)
Selected device: usbtv
 Capabilities:  video capture  read/write  streaming
 supported norms: 0 = NTSC; 1 = NTSC-M; 2 = NTSC-M-JP; 3 = NTSC-M-KR; 4 = NTSC-443; 5 = PAL; 6 = PAL-BG; 7 = PAL-H; 8 = PAL-I; 9 = PAL-DK; 10 = PAL-M; 11 = PAL-60;
 inputs: 0 = Composite; 1 = S-Video;
 Current input: 1
 Current format: YUYV
Selected input hasn't got a tuner!
v4l2: ioctl set mute failed: Invalid argument
[V] filefmt:9  fourcc:0x32595559  size:720x480  fps:5.000  ftime:=0.2000
videocodec: framecopy (720x480 24bpp fourcc=32595559)
Forcing audio preload to 0, max pts correction to 0.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s      2f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s      3f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]

Invalid frame duration value (0.120/0.000 => -0.120). Defaulting to 0.040 sec.

Skipping frame!
Pos:   0.2s      4f ( 0%)  3.96fps Trem:   0min   0mb  A-V:0.000 [0:0]
v4l2: select timeout

Skipping frame!
Pos:   0.2s      5f ( 0%)  3.26fps Trem:   0min   0mb  A-V:0.000 [0:0]

Skipping frame!
Pos:   0.2s      6f ( 0%)  2.91fps Trem:   0min   0mb  A-V:0.000 [0:0]

7 duplicate frame(s)!
Pos:   0.2s      7f ( 0%)  3.25fps Trem:   0min   0mb  A-V:0.000 [0:0]

Invalid frame duration value (1.800/0.000 => -1.800). Defaulting to 1.800 sec.

8 duplicate frame(s)!
Pos:   1.8s      8f ( 0%)  2.98fps Trem:   0min   0mb  A-V:0.000 [9216:0]

11 duplicate frame(s)!
Pos:   6.2s     11f ( 0%)  3.82fps Trem:   0min   0mb  A-V:0.000 [5351:0]

Skipping frame!
Pos:   6.4s     12f ( 0%)  4.11fps Trem:   0min   0mb  A-V:0.000 [5184:0]

Skipping frame!
Pos:   6.4s     13f ( 0%)  4.39fps Trem:   0min   0mb  A-V:0.000 [5184:0]

Invalid frame duration value (2.599/0.000 => -2.599). Defaulting to 0.040 sec.

Skipping frame!
Pos:   6.4s     14f ( 0%)  4.01fps Trem:   0min   0mb  A-V:0.000 [5184:0]
v4l2: select timeout

Skipping frame!
Pos:   6.4s     15f ( 0%)  3.73fps Trem:   0min   0mb  A-V:0.000 [5184:0]

Skipping frame!
Pos:   6.4s     16f ( 0%)  3.52fps Trem:   0min   0mb  A-V:0.000 [5184:0]

20 duplicate frame(s)!
Pos:   6.4s     17f ( 0%)  3.70fps Trem:   0min   0mb  A-V:0.000 [6048:0]

Invalid frame duration value (4.239/0.000 => -4.239). Defaulting to 4.239 sec.

20 duplicate frame(s)!
Pos:  10.6s     18f ( 0%)  3.51fps Trem:   0min   0mb  A-V:0.000 [4173:0]

23 duplicate frame(s)!
Pos:  19.8s     21f ( 0%)  3.92fps Trem:   0min   0mb  A-V:0.000 [3072:0]

Skipping frame!
Pos:  20.0s     22f ( 0%)  4.07fps Trem:   0min   0mb  A-V:0.000 [3041:0]

Invalid frame duration value (5.039/0.000 => -5.039). Defaulting to 0.040 sec.

Skipping frame!
Pos:  20.0s     23f ( 0%)  3.88fps Trem:   0min   0mb  A-V:0.000 [3041:0]
v4l2: select timeout

Skipping frame!
Pos:  20.0s     24f ( 0%)  3.72fps Trem:   0min   0mb  A-V:0.000 [3041:0]

Skipping frame!
Pos:  20.0s     25f ( 0%)  3.58fps Trem:   0min   0mb  A-V:0.000 [3041:0]

32 duplicate frame(s)!
Pos:  20.0s     26f ( 0%)  3.67fps Trem:   0min   0mb  A-V:0.000 [3317:0]

Invalid frame duration value (6.718/0.000 => -6.718). Defaulting to 6.718 sec.

32 duplicate frame(s)!
Pos:  26.6s     27f ( 0%)  3.55fps Trem:   0min   0mb  A-V:0.000 [2702:0]

36 duplicate frame(s)!
Pos:  40.8s     30f ( 0%)  3.85fps Trem:   0min   0mb  A-V:0.000 [2168:0]

Skipping frame!
Pos:  41.0s     31f ( 0%)  3.96fps Trem:   0min   0mb  A-V:0.000 [2157:0]

Invalid frame duration value (7.478/0.000 => -7.478). Defaulting to 0.040 sec.

Skipping frame!
Pos:  41.0s     32f ( 0%)  3.83fps Trem:   0min   0mb  A-V:0.000 [2157:0]
v4l2: select timeout

Skipping frame!
Pos:  41.0s     33f ( 0%)  3.71fps Trem:   0min   0mb  A-V:0.000 [2157:0]

Skipping frame!
Pos:  41.0s     34f ( 0%)  3.61fps Trem:   0min   0mb  A-V:0.000 [2157:0]

44 duplicate frame(s)!
Pos:  41.0s     35f ( 0%)  3.67fps Trem:   0min   0mb  A-V:0.000 [2292:0]

Invalid frame duration value (9.158/0.000 => -9.158). Defaulting to 9.158 sec.

45 duplicate frame(s)!
Pos:  50.0s     36f ( 0%)  3.58fps Trem:   0min   0mb  A-V:0.000 [1990:0]

48 duplicate frame(s)!
Pos:  69.0s     38f ( 0%)  3.73fps Trem:   0min   0mb  A-V:0.000 [1602:0]

Skipping frame!
Pos:  69.2s     39f ( 0%)  3.81fps Trem:   0min   0mb  A-V:0.000 [1598:0]

Skipping frame!
Pos:  69.2s     40f ( 0%)  3.89fps Trem:   0min   0mb  A-V:0.000 [1598:0]

Invalid frame duration value (9.918/0.000 => -9.918). Defaulting to 0.040 sec.

Skipping frame!
^Cs:  69.2s     41f ( 0%)  3.80fps Trem:   0min   0mb  A-V:0.000 [1598:0]
v4l2: select timeout

Skipping frame!
Pos:  69.2s     42f ( 0%)  3.71fps Trem:   0min   0mb  A-V:0.000 [1598:0]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1598.150 kbit/s  (199768 B/s)  size: 13824000 bytes  69.200 secs  42 frames
v4l2: ioctl set mute failed: Invalid argument
v4l2: 26 frames successfully processed, 31 frames dropped.
pi@raspberrypi:/tmp $ 

dmesg information when I connect this HDMI->USB converter:

[ 2132.394435] usb 1-1.3: new high-speed USB device number 7 using dwc2
[ 2132.527882] usb 1-1.3: config 1 interface 0 altsetting 1 bulk endpoint 0x83 has invalid maxpacket 256
[ 2132.530876] usb 1-1.3: New USB device found, idVendor=1b71, idProduct=3002
[ 2132.530898] usb 1-1.3: New USB device strings: Mfr=3, Product=4, SerialNumber=2
[ 2132.530906] usb 1-1.3: Product: usbtv007
[ 2132.530915] usb 1-1.3: Manufacturer: fushicai
[ 2132.530923] usb 1-1.3: SerialNumber: 300000000002
[ 2132.532973] usbtv 1-1.3:1.0: Fushicai USBTV007 Audio-Video Grabber

mencoder version:

pi@raspberrypi:/tmp $ mencoder -v
MEncoder 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team

Can you see guys causes for an issue or do you need more details? I really appreciate any comment on that - thanks!

@laimison
Copy link
Author

laimison commented Sep 5, 2018

I have found that removing modules-load=dwc2 from /boot/cmdline.txt and dtoverlay=dwc2 from /boot/config.txt seems sorted the root cause in my case. I came to idea to remove this because of [253805.452822] dwc2 3f980000.usb: dwc2_hc_halt() Channel can't be halted error in dmesg.

I still have two issues that

  1. video quality is not good enough to see very small fonts (it's like 30+ years old TV display)
    I still see the error buffer contains corrupted data when using ffmpeg or avconv tools manually

  2. lower corner of screen is not visible through web server (so when I'm in the Linux console, I don't see few last lines what I'm typing in) - I have also checked the jpg file in /mnt/ramdisk to confirm that it's not web interface and css styling issue

Not sure whether these next issues are related with original issue at the moment

@laimison
Copy link
Author

laimison commented Sep 13, 2018

I wanted to share a resolution.

An second issue solved by changing avconv -f video4linux2 ... to avconv -f v4l2 -standard pal ... in /var/www/html/image.php so it fits into the screen now.

Video/image quality still could be better, but decided to not invest time on this issue.

An example with "HD Capture":
screen shot 2018-09-14 at 00 08 04

@DedupOperator
Copy link

DedupOperator commented Sep 21, 2018

Unfortunately, analog video has a very low quality.
From my past experience there are EasyCap devices that use bad qualiy ADC chip, device looks the same but different chips inside.
The Amazon link provided should be the better quality one.

You can research more but I think the best way is going fully digital, you can check issue #6 for alternatives.

@laimison
Copy link
Author

laimison commented Sep 23, 2018

Thanks for useful info. Did you mean the amazon links from README.md? If I remember correctly I had some difficulties to get this in the UK with limited time and also found that "HD Capture" doesn't require a separate powering so I bought that one.
Do you know whether these devices in README.md support resolution such as 1024x768 or at least 800x600?

Do you have some examples of digital solutions? Are they sold only at higher prices comparing with EasyCap devices?

I have attached the photos of "HD Capture" and lsusb output (not sure whether this is ADC bad quality chip):
42410223_471686063324298_6751867345850859520_n
42423660_325918848181305_7756501187553132544_n

pi@raspberrypi:/var/www/html $ lsusb -D /dev/bus/usb/001/007 
Device: ID 1b71:3002 Fushicai USBTV007 Video Grabber [EasyCAP]
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1b71 Fushicai
  idProduct          0x3002 USBTV007 Video Grabber [EasyCAP]
  bcdDevice            1.00
  iManufacturer           3 
  iProduct                4 
  iSerial                 2 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           83
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       1
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x1400  3x 1024 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0100  1x 256 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
pi@raspberrypi:/var/www/html $

Many thanks if you have a few minutes to reply this

@DedupOperator
Copy link

@laimison refer issue #14 for an interesting "hackish" way to capture HDMI signals with minimal budget if you would like to upgrade your quality.

About the cloned devices, I meant the Easycap device.
But anyway you can't expect much from those cheapo product.
The downscaling from HDMI resolutions, to analog TV resolutions like S-Video will give you approximately the equivalent of 640x480-800x600 resoluion.
Text won't be sharp in this technology unless higher quality analog-to-digital and digital-to-analog converters are used.

Best option is to use an all-digital path as I mentioned before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants