Opened 8 years ago

Last modified 4 years ago

#6279 open enhancement

can't request rgb24 (uvc over dshow, unknown compression type)

Reported by: Djfe Owned by:
Priority: wish Component: avdevice
Version: git-master Keywords: dshow
Cc: Diederick Niehorster Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

ffmpeg doesn't seem to know some of the color space id's that dshow uses.
In particular the rgb24 color space:
"[dshow @ 0000000000756320] unknown compression type 0xE436EB7D min s=1920x1080 fps=15 max s=1920x1080 fps=59.9999"
(I provided a log output, containing more similar lines)

A quick google search for the id (0xE436EB7D) in question reveals, that it represents rgb24:
https://github.com/opencv/opencv/blob/master/modules/videoio/test/test_fourcc.cpp#L81

I bet ffmpeg doesn't know the other RGB GUIDs either, but I can't verify it, since my device only supports outputting in those two color spaces.

I'm unsure if it is allowed to simply take the information from the linked opencv file (regarding the opencv license (vs LGPL)) though.
But it would be nice if other GUIDs apart from rgb could be "imported" into ffmpeg's knowledge as well.

But now to the interesting part:
is it enough if ffmpeg knows, that the data is of color space rgb24, or not?

until someone finds the time: I'm looking forward to rgb24 support for uvc over dshow :) (maybe that will give you some motivation )
The reason being, that I'm recording to qtrle (lossless, but only rgb color space).
Asking the grabber to give me rgb avoids unneccessary color space conversion on both sides.

PS:
I'm unsure if the type of this bug report is a defect or an enhancement,
feel free to correct it, if you think it isn't a defect ;)

Attachments (2)

ffmpeg-20170330-204303.log (10.9 KB ) - added by Djfe 8 years ago.
ffmpeg report log; device: Magewell USB Capture HDMI (it does HDMI -> USB 3.0 -> UVC)
patchdshowguid.diff (619 bytes ) - added by Carl Eugen Hoyos 8 years ago.

Download all attachments as: .zip

Change History (8)

by Djfe, 8 years ago

Attachment: ffmpeg-20170330-204303.log added

ffmpeg report log; device: Magewell USB Capture HDMI (it does HDMI -> USB 3.0 -> UVC)

comment:1 by Carl Eugen Hoyos, 8 years ago

Component: ffmpegavdevice
Keywords: dshow added
Priority: normalwish
Type: defectenhancement

Please test attached patch.

by Carl Eugen Hoyos, 8 years ago

Attachment: patchdshowguid.diff added

comment:2 by Djfe, 8 years ago

Thx for your quick answer, I'll do that.
I only have to setup an environment for compiling ffmpeg on windows now
so I'll reply in a few hours/tomorrow when I'm done.

comment:3 by Djfe, 5 years ago

now that I finally got around to compiling ffmpeg for windows:

so the detection works fine with your patch, in addition to yuyv422 it now lists the second half of all entries as "rgb24"
nice
(for some reason all entries seem to be duplicated, but maybe there is a difference, that isn't visible here)

ffmpeg -list_options true -f dshow -i video="USB Capture HDMI"
ffmpeg version N-94089-gbc3306fd5b Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3-win32 (GCC) 20180312
  configuration: --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32-
  libavutil      56. 29.100 / 56. 29.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 28.100 / 58. 28.100
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
[dshow @ 01f53400] DirectShow video device options (from video devices)
[dshow @ 01f53400]  Pin "Capture" (alternative pin name "0")
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1920x1080 fps=25 max s=1920x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1920x1080 fps=25 max s=1920x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=640x360 fps=25 max s=640x360 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=640x360 fps=25 max s=640x360 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=640x480 fps=25 max s=640x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=640x480 fps=25 max s=640x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=720x480 fps=25 max s=720x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=720x480 fps=25 max s=720x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=720x576 fps=25 max s=720x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=720x576 fps=25 max s=720x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=768x576 fps=25 max s=768x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=768x576 fps=25 max s=768x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=800x600 fps=25 max s=800x600 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=800x600 fps=25 max s=800x600 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=856x480 fps=25 max s=856x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=856x480 fps=25 max s=856x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=960x540 fps=25 max s=960x540 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=960x540 fps=25 max s=960x540 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1024x576 fps=25 max s=1024x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1024x576 fps=25 max s=1024x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1024x768 fps=25 max s=1024x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1024x768 fps=25 max s=1024x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x720 fps=25 max s=1280x720 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x720 fps=25 max s=1280x720 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x800 fps=25 max s=1280x800 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x800 fps=25 max s=1280x800 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x960 fps=25 max s=1280x960 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x960 fps=25 max s=1280x960 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x1024 fps=25 max s=1280x1024 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1280x1024 fps=25 max s=1280x1024 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1368x768 fps=25 max s=1368x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1368x768 fps=25 max s=1368x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1440x900 fps=25 max s=1440x900 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1440x900 fps=25 max s=1440x900 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1600x1200 fps=25 max s=1600x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1600x1200 fps=25 max s=1600x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1680x1050 fps=25 max s=1680x1050 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1680x1050 fps=25 max s=1680x1050 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1920x1200 fps=25 max s=1920x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=1920x1200 fps=25 max s=1920x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=2048x1080 fps=25 max s=2048x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=yuyv422  min s=2048x1080 fps=25 max s=2048x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1920x1080 fps=25 max s=1920x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1920x1080 fps=25 max s=1920x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=640x360 fps=25 max s=640x360 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=640x360 fps=25 max s=640x360 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=640x480 fps=25 max s=640x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=640x480 fps=25 max s=640x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=720x480 fps=25 max s=720x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=720x480 fps=25 max s=720x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=720x576 fps=25 max s=720x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=720x576 fps=25 max s=720x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=768x576 fps=25 max s=768x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=768x576 fps=25 max s=768x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=800x600 fps=25 max s=800x600 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=800x600 fps=25 max s=800x600 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=856x480 fps=25 max s=856x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=856x480 fps=25 max s=856x480 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=960x540 fps=25 max s=960x540 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=960x540 fps=25 max s=960x540 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1024x576 fps=25 max s=1024x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1024x576 fps=25 max s=1024x576 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1024x768 fps=25 max s=1024x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1024x768 fps=25 max s=1024x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x720 fps=25 max s=1280x720 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x720 fps=25 max s=1280x720 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x800 fps=25 max s=1280x800 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x800 fps=25 max s=1280x800 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x960 fps=25 max s=1280x960 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x960 fps=25 max s=1280x960 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x1024 fps=25 max s=1280x1024 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1280x1024 fps=25 max s=1280x1024 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1368x768 fps=25 max s=1368x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1368x768 fps=25 max s=1368x768 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1440x900 fps=25 max s=1440x900 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1440x900 fps=25 max s=1440x900 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1600x1200 fps=25 max s=1600x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1600x1200 fps=25 max s=1600x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1680x1050 fps=25 max s=1680x1050 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1680x1050 fps=25 max s=1680x1050 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1920x1200 fps=25 max s=1920x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=1920x1200 fps=25 max s=1920x1200 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=2048x1080 fps=25 max s=2048x1080 fps=59.9999
[dshow @ 01f53400]   pixel_format=rgb24  min s=2048x1080 fps=25 max s=2048x1080 fps=59.9999
video=USB Capture HDMI: Immediate exit requested

But I can't save the rawvideo, yet. It shows "[125][235]6[228]" instead of RGB and errors "Invalid pixel format."

ffmpeg -f dshow -video_size 1280x720 -framerate 25 -pixel_format rgb24 -i video="USB Capture HDMI" -c:v qtrle test.mov
ffmpeg version N-94089-gbc3306fd5b Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3-win32 (GCC) 20180312
  configuration: --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32-
  libavutil      56. 29.100 / 56. 29.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 28.100 / 58. 28.100
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
[rawvideo @ 022bedc0] Invalid pixel format.
Input #0, dshow, from 'video=USB Capture HDMI':
  Duration: N/A, start: 751073.323000, bitrate: N/A
    Stream #0:0: Video: rawvideo ([125][235]6[228] / 0xE436EB7D), none, 1280x720, 25 fps, 25 tbr, 10000k tbn, 10000k tbc

[rawvideo @ 01f52580] Invalid pixel format.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> qtrle (native))
Error while opening decoder for input stream #0:0 : Invalid argument

yuyv422 still works fine (yes I'm saving as rgb here, but that was only as a test to see if everything still works as expected, which it does)

ffmpeg -f dshow -video_size 1280x720 -framerate 25 -pixel_format yuyv422 -i video="USB Capture HDMI" -c:v qtrle test.mov
ffmpeg version N-94089-gbc3306fd5b Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7.3-win32 (GCC) 20180312
  configuration: --arch=x86 --target-os=mingw32 --cross-prefix=i686-w64-mingw32-
  libavutil      56. 29.100 / 56. 29.100
  libavcodec     58. 53.100 / 58. 53.100
  libavformat    58. 28.100 / 58. 28.100
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 55.100 /  7. 55.100
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
Input #0, dshow, from 'video=USB Capture HDMI':
  Duration: N/A, start: 751105.511000, bitrate: N/A
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 25 fps, 25 tbr, 10000k tbn, 10000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> qtrle (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'test.mov':
  Metadata:
    encoder         : Lavf58.28.100
    Stream #0:0: Video: qtrle (rle  / 0x20656C72), rgb24, 1280x720, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.53.100 qtrle
frame=   67 fps= 25 q=-0.0 Lsize=    5244kB time=00:00:02.64 bitrate=16271.0kbits/s dup=13 drop=0 speed=0.997x
video:5243kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019857%

comment:4 by Djfe, 5 years ago

and now I forgot to mention, that I had to modify your patch diff to get it running:

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index f2453e6..a23b1d9 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -51,6 +51,14 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount)
                 return AV_PIX_FMT_0RGB32;
         }
+    case 0xe436eb7b:
+        return AV_PIX_FMT_RGB565;
+    case 0xe436eb7c:
+        return AV_PIX_FMT_RGB555;
+    case 0xe436eb7d:
+        return AV_PIX_FMT_RGB24;
+    case 0xe436eb7e:
+        return AV_PIX_FMT_0RGB32;
     }
     return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others
 }

I needed to move one of the curly brackets below the new cases, without that the cases were outside of the outer switch statement (variable: biCompression).

Last edited 5 years ago by Djfe (previous) (diff)

comment:5 by Diederick Niehorster, 4 years ago

Cc: Diederick Niehorster added

comment:6 by Balling, 4 years ago

Status: newopen

This is a strange problem. Why avpriv_find_pix_fmt() does not find it? Like it does for https://trac.ffmpeg.org/ticket/8454#comment:6 as the functions searches through those.

Those are just not the MKTAG??

Last edited 4 years ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.