我正在运行 Ubuntu 18.04 LTS。这是我连接相机时的 dmesg。看起来不对劲。
[ 4721.516013] input: UVC Camera (046d:0825) as /devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11.1/1-11.1.4/1-11.1.4:1.0/input/input21
[ 4722.857466] usb 1-11.1.4: set resolution quirk: cval->res = 384
[ 4780.532548] usb 1-11.1.4: USB disconnect, device number 11
[ 4788.179290] usb 1-11.1.4: new high-speed USB device number 12 using xhci_hcd
[ 4788.319128] usb 1-11.1.4: New USB device found, idVendor=058f, idProduct=3822
[ 4788.319134] usb 1-11.1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4788.319138] usb 1-11.1.4: Product: USB 2.0 HD Camera
[ 4788.323968] uvcvideo: Found UVC 1.00 device USB 2.0 HD Camera (058f:3822)
[ 4788.327948] uvcvideo 1-11.1.4:1.0: Entity type for entity Processing 2 was not initialized!
[ 4788.327954] uvcvideo 1-11.1.4:1.0: Entity type for entity Extension 6 was not initialized!
[ 4788.327958] uvcvideo 1-11.1.4:1.0: Entity type for entity Camera 1 was not initialized!
[ 4788.328284] input: USB 2.0 HD Camera : USB 2.0 HD as /devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11.1/1-11.1.4/1-11.1.4:1.0/input/input22
当我使用 /dev/video0 捕获设备运行 VLC 时,我没有得到图像。
当我访问 webrtc 网站时,例如https://appr.tc在 Chrome 中,网络摄像头可以正常工作。
当我尝试使用以下 gstreamer 管道将摄像头传输到 VLC 时,没有生成 UDP 数据包。我认为这意味着 gstreamer 无法初始化摄像头或类似的东西。
gst-launch-1.0 v4lsrc ! videoconvert ! x264enc ! rtph264pay config-interval=10 pt=96 ! udpsink host=224.0.0.1 port=5000
有人知道这里可能出了什么问题吗?为什么 Chrome 和 VLC 的网络摄像头行为似乎不同?
更新:
我现在发现,如果我将 VLC 中的摄像头分辨率强制为 640x480,那么视频就会显示出来。但是,图像似乎被裁剪了,并且宽高比也不对。这是我执行此操作时 VLC 的日志。我发现,如果我尝试其他分辨率,无论如何,它看起来仍然一样。
Jun 21 22:28:05 dawkids vlc[23973]: processing request item: v4l2://, node: Playlist, skip: 0
Jun 21 22:28:05 dawkids vlc[23973]: rebuilding array of current - root Playlist
Jun 21 22:28:05 dawkids vlc[23973]: rebuild done - 9 items, index 8
Jun 21 22:28:05 dawkids vlc[23973]: starting playback of new item
Jun 21 22:28:05 dawkids vlc[23973]: resyncing on v4l2://
Jun 21 22:28:05 dawkids vlc[23973]: v4l2:// is at 6
Jun 21 22:28:05 dawkids vlc[23973]: creating new input thread
Jun 21 22:28:05 dawkids vlc[23973]: Creating an input for 'v4l2://'
Jun 21 22:28:05 dawkids vlc[23973]: requesting art for new input thread
Jun 21 22:28:05 dawkids vlc[23973]: using timeshift granularity of 50 MiB
Jun 21 22:28:05 dawkids vlc[23973]: using default timeshift path
Jun 21 22:28:05 dawkids vlc[23973]: `v4l2://' gives access `v4l2' demux `any' path `'
Jun 21 22:28:05 dawkids vlc[23973]: creating demux: access='v4l2' demux='any' location='' file='(null)'
Jun 21 22:28:05 dawkids vlc[23973]: looking for access_demux module matching "v4l2": 17 candidates
Jun 21 22:28:05 dawkids vlc[23973]: opening device '/dev/video0'
Jun 21 22:28:05 dawkids vlc[23973]: looking for meta fetcher module matching "any": 1 candidates
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /home/peter/.local/share/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/share/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: no meta fetcher modules matched
Jun 21 22:28:05 dawkids vlc[23973]: looking for art finder module matching "any": 2 candidates
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /home/peter/.local/share/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/00_musicbrainz.luac
Jun 21 22:28:05 dawkids vlc[23973]: device USB 2.0 HD Camera : USB 2.0 HD using driver uvcvideo (version 4.15.18) on usb-0000:00:14.0-11.1.4
Jun 21 22:28:05 dawkids vlc[23973]: with capabilities 0x05200001 (overall 0x85200001)
Jun 21 22:28:05 dawkids vlc[23973]: video input Camera 1 (0) is camera
Jun 21 22:28:05 dawkids vlc[23973]: selected input 0
Jun 21 22:28:05 dawkids vlc[23973]: no video standard selection
Jun 21 22:28:05 dawkids vlc[23973]: no tuning required (analog baseband input)
Jun 21 22:28:05 dawkids vlc[23973]: no audio input available
Jun 21 22:28:05 dawkids vlc[23973]: supports compressed format MJPG (MJPG): Motion-JPEG
Jun 21 22:28:05 dawkids vlc[23973]: supports raw format YUYV (YUY2): YUYV 4:2:2
Jun 21 22:28:05 dawkids vlc[23973]: emulates raw format RGB3 (RV24): RGB3
Jun 21 22:28:05 dawkids vlc[23973]: emulates raw format BGR3 (RV24): BGR3
Jun 21 22:28:05 dawkids vlc[23973]: emulates raw format YU12 (I420): YU12
Jun 21 22:28:05 dawkids vlc[23973]: emulates raw format YV12 (YV12): YV12
Jun 21 22:28:05 dawkids vlc[23973]: selected format YUYV (YUY2)
Jun 21 22:28:05 dawkids vlc[23973]: requested frame internal: 1/60
Jun 21 22:28:05 dawkids vlc[23973]: requested frame size: 640x480
Jun 21 22:28:05 dawkids vlc[23973]: discrete frame interval: 1/30
Jun 21 22:28:05 dawkids vlc[23973]: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/00_musicbrainz.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/01_googleimage.luac
Jun 21 22:28:05 dawkids vlc[23973]: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/01_googleimage.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/02_frenchtv.luac
Jun 21 22:28:05 dawkids vlc[23973]: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/02_frenchtv.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/03_lastfm.luac
Jun 21 22:28:05 dawkids vlc[23973]: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/03_lastfm.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/share/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: no art finder modules matched
Jun 21 22:28:05 dawkids vlc[23973]: looking for meta fetcher module matching "any": 1 candidates
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /home/peter/.local/share/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/share/vlc/lua/meta/fetcher
Jun 21 22:28:05 dawkids vlc[23973]: no meta fetcher modules matched
Jun 21 22:28:05 dawkids vlc[23973]: looking for art finder module matching "any": 2 candidates
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /home/peter/.local/share/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/00_musicbrainz.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/01_googleimage.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/02_frenchtv.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/03_lastfm.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/share/vlc/lua/meta/art
Jun 21 22:28:05 dawkids vlc[23973]: no art finder modules matched
Jun 21 22:28:05 dawkids vlc[23973]: IM: Deleting the input
Jun 21 22:28:05 dawkids vlc[23973]: cannot reset cropping limits: Inappropriate ioctl for device
Jun 21 22:28:05 dawkids vlc[23973]: 614400 bytes maximum for complete image
Jun 21 22:28:05 dawkids vlc[23973]: Interlacing setting: progressive
Jun 21 22:28:05 dawkids vlc[23973]: color primaries: 8
Jun 21 22:28:05 dawkids vlc[23973]: transfer function: 0
Jun 21 22:28:05 dawkids vlc[23973]: YCbCr encoding: 0
Jun 21 22:28:05 dawkids vlc[23973]: quantization: 0
Jun 21 22:28:05 dawkids vlc[23973]: added new video ES YUY2 640x480 (640x480)
Jun 21 22:28:05 dawkids vlc[23973]: frame rate: 30/1
Jun 21 22:28:05 dawkids vlc[23973]: aspect ratio: 1/1
Jun 21 22:28:05 dawkids vlc[23973]: selecting program id=0
Jun 21 22:28:05 dawkids vlc[23973]: streaming with 4 memory-mapped buffers
Jun 21 22:28:05 dawkids vlc[23973]: integer Brightness (00980900)
Jun 21 22:28:05 dawkids vlc[23973]: current: 5, default: 5
Jun 21 22:28:05 dawkids vlc[23973]: integer Contrast (00980901)
Jun 21 22:28:05 dawkids vlc[23973]: current: 15, default: 15
Jun 21 22:28:05 dawkids vlc[23973]: integer Saturation (00980902)
Jun 21 22:28:05 dawkids vlc[23973]: current: 64, default: 64
Jun 21 22:28:05 dawkids vlc[23973]: integer Hue (00980903)
Jun 21 22:28:05 dawkids vlc[23973]: current: 0, default: 0
Jun 21 22:28:05 dawkids vlc[23973]: integer Gamma (00980910)
Jun 21 22:28:05 dawkids vlc[23973]: current: 120, default: 120
Jun 21 22:28:05 dawkids vlc[23973]: menu Power Line Frequency (00980918)
Jun 21 22:28:05 dawkids vlc[23973]: current: 1, default: 1
Jun 21 22:28:05 dawkids vlc[23973]: choice 0) Disabled
Jun 21 22:28:05 dawkids vlc[23973]: choice 1) 50 Hz
Jun 21 22:28:05 dawkids vlc[23973]: choice 2) 60 Hz
Jun 21 22:28:05 dawkids vlc[23973]: integer Sharpness (0098091B)
Jun 21 22:28:05 dawkids vlc[23973]: current: 10, default: 10
Jun 21 22:28:05 dawkids vlc[23973]: integer Backlight Compensation (0098091C)
Jun 21 22:28:05 dawkids vlc[23973]: current: 0, default: 0
Jun 21 22:28:05 dawkids vlc[23973]: menu Exposure, Auto (009A0901)
Jun 21 22:28:05 dawkids vlc[23973]: current: 3, default: 3
Jun 21 22:28:05 dawkids vlc[23973]: choice 1) Manual Mode
Jun 21 22:28:05 dawkids vlc[23973]: choice 3) Aperture Priority Mode
Jun 21 22:28:05 dawkids vlc[23973]: integer Exposure (Absolute) (009A0902)
Jun 21 22:28:05 dawkids vlc[23973]: current: 333, default: 312
Jun 21 22:28:05 dawkids vlc[23973]: boolean Exposure, Auto Priority (009A0903)
Jun 21 22:28:05 dawkids vlc[23973]: current: true, default: false
Jun 21 22:28:05 dawkids vlc[23973]: using access_demux module "v4l2"
Jun 21 22:28:05 dawkids vlc[23973]: looking for video decoder module matching "any": 16 candidates
Jun 21 22:28:05 dawkids vlc[23973]: using video decoder module "rawvideo"
Jun 21 22:28:05 dawkids vlc[23973]: looking for meta reader module matching "any": 2 candidates
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /home/peter/.local/share/vlc/lua/meta/reader
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/reader
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/reader/filename.luac
Jun 21 22:28:05 dawkids vlc[23973]: Trying Lua scripts in /usr/share/vlc/lua/meta/reader
Jun 21 22:28:05 dawkids vlc[23973]: no meta reader modules matched
Jun 21 22:28:05 dawkids vlc[23973]: `v4l2://' successfully opened
Jun 21 22:28:05 dawkids vlc[23973]: IM: Setting an input
Jun 21 22:28:05 dawkids vlc[23973]: IM: Deleting the input
Jun 21 22:28:05 dawkids vlc[23973]: IM: Setting an input
Jun 21 22:28:06 dawkids vlc[23973]: Buffering 0%
Jun 21 22:28:06 dawkids vlc[23973]: trying to reuse free vout
Jun 21 22:28:06 dawkids vlc[23973]: removing module "freetype"
Jun 21 22:28:06 dawkids vlc[23973]: looking for text renderer module matching "any": 2 candidates
Jun 21 22:28:06 dawkids vlc[23973]: Building font databases.
Jun 21 22:28:06 dawkids vlc[23973]: Took -21504 microseconds
Jun 21 22:28:06 dawkids vlc[23973]: using text renderer module "freetype"
Jun 21 22:28:06 dawkids vlc[23973]: reusing provided vout
Jun 21 22:28:06 dawkids vlc[23973]: Received first picture
Jun 21 22:28:06 dawkids vlc[23973]: Logical video size: 640x480
Jun 21 22:28:06 dawkids vlc[23973]: resized to 640x480
Jun 21 22:28:06 dawkids vlc[23973]: VoutDisplayEvent 'resize' 640x480
Jun 21 22:28:06 dawkids vlc[23973]: Buffering 18%
Jun 21 22:28:06 dawkids vlc[23973]: Buffering 35%
Jun 21 22:28:06 dawkids vlc[23973]: auto hiding mouse cursor
Jun 21 22:28:06 dawkids vlc[23973]: Buffering 53%
Jun 21 22:28:07 dawkids vlc[23973]: Buffering 70%
Jun 21 22:28:07 dawkids vlc[23973]: Buffering 88%
Jun 21 22:28:07 dawkids vlc[23973]: Stream buffering done (319 ms in 316 ms)
Jun 21 22:28:07 dawkids vlc[23973]: Decoder wait done in 0 ms