【问题标题】:How do I adjust the video resolution?如何调整视频分辨率?
【发布时间】:2019-08-20 15:57:33
【问题描述】:

我正在尝试调整传入 H.264 RTSP 流的分辨率。我目前在 Windows 10 上运行,但最终会将其移至 Linux。我正在创建传递几个命令行参数的 LibVLC 对象,但我尝试过的任何操作都不会影响生成的屏幕分辨率。

当我在 VLC 媒体播放器应用程序中打开相同的 RTSP 流时,分辨率为 2560x1980,这是我想要在我的应用程序中使用的本机分辨率。但是,当我的应用程序运行时,它只有 640x480。仅供参考 - 这不是 Windows UI 应用程序。这是一项只是截取屏幕截图的服务。因此,表单上没有媒体控件可以调整。

这是我现在拥有的:

Core.Initialize();
LibVLC libVLC = new LibVLC("--no-audio", "--no-spu", "--sout-transcode-venc=x264", "--sout-x264-preset=ultrafast", "--sout-x264-profile=high", "--sout-x264-tune=film", "--video-filter=scene", "--scene-format=jpeg", "--scene-prefix=MyVision", "--scene-path=C:\\temp\\", "--scene-ratio=100", $"--rtsp-user={rtspUser}", $"--rtsp-pwd={rtspPassword}");

player = new MediaPlayer(libVLC);
var media = new Media(libVLC, _rtspEndpoint, FromType.FromLocation);
player.Play(media);

一些 x264 选项只是我在 VLC 应用程序中看到的测试过的选项。他们没有调整分辨率。

这是日志文件:

VLC media player - 3.0.7.1 Vetinari
Copyright © 1996-2019 the VideoLAN team
revision 3.0.7.1-0-gf3940db4af
configured with ../extras/package/win32/../../../configure  '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-dvdread' '--enable-shout' '--enable-goom' '--enable-caca' '--enable-qt' '--enable-skins2' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=x86_64-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' 'host_alias=x86_64-w64-mingw32' 'PKG_CONFIG_LIBDIR=/home/jenkins/workspace/vlc-release/windows/vlc-release-win32-x64/contrib/x86_64-w64-mingw32/lib/pkgconfig'
creating audio output
looking for audio output module matching "any": 6 candidates
using default device
display name changed: VLC media player (LibVLC 3.0.7.1)
version 2 session control unavailable
volume from -65.250000 dB to +0.000000 dB with 0.031250 dB increments
using audio output module "mmdevice"
keeping audio output
Creating an input for 'rtsp://192.168.1.108:554/h264Preview_01_sub'
using timeshift granularity of 50 MiB
using timeshift path: C:\Users\dwjen\AppData\Local\Temp
`rtsp://192.168.1.108:554/h264Preview_01_sub' gives access `rtsp' demux `any' path `192.168.1.108:554/h264Preview_01_sub'
creating demux: access='rtsp' demux='any' location='192.168.1.108:554/h264Preview_01_sub' file='\\192.168.1.108:554\h264Preview_01_sub'
looking for access_demux module matching "rtsp": 15 candidates
version 2016.11.28
RTP subsession 'video/H264'
selecting program id=0
RTP subsession 'audio/MPEG4-GENERIC'
setup start: 0.000000 stop:0.000000
We have a timeout of 60 seconds
play start: 0.000000 stop:0.000000
using access_demux module "live555"
looking for packetizer module matching "any": 25 candidates
found NAL_SPS (sps_id=0)
found NAL_PPS (pps_id=0 sps_id=0)
using packetizer module "h264"
looking for video decoder module matching "any": 19 candidates
using ffmpeg Lavc58.6.103
CPU flags: 0x0007d3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
audio is disabled, not selecting ES 0x1
looking for meta reader module matching "any": 2 candidates
Trying Lua scripts in C:\Users\dwjen\AppData\Roaming\vlc\lua\meta\reader
Trying Lua scripts in C:\Source\BlueMetal\Internal\VideoTest\RtspSnapshots\bin\Debug\netcoreapp2.2\libvlc\win-x64\lua\meta\reader
Trying Lua playlist script C:\Source\BlueMetal\Internal\VideoTest\RtspSnapshots\bin\Debug\netcoreapp2.2\libvlc\win-x64\lua\meta\reader\filename.luac
no meta reader modules matched
`rtsp://192.168.1.108:554/h264Preview_01_sub' successfully opened
Buffering 0%
Buffering 3%
Buffering 7%
restarting module due to input format change
removing module "avcodec"
looking for video decoder module matching "any": 19 candidates
using ffmpeg Lavc58.6.103
CPU flags: 0x0007d3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
available hardware decoder output format 119 (cuda)
available hardware decoder output format 53 (dxva2_vld)
available hardware decoder output format 118 (d3d11va_vld)
available hardware decoder output format 174 (d3d11)
available software decoder output format 0 (yuv420p)
tk->rtpSource->hasBeenSynchronizedUsingRTCP()
trying format d3d11va_vld
looking for text renderer module matching "any": 3 candidates
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for video converter module matching "any": 24 candidates
32x32 (32x32) chroma: YUVA -> 16x16 (16x16) chroma: RGBA with scaling using Bicubic (good quality)
using video converter module "swscale"
looking for video converter module matching "any": 24 candidates
YUVP to YUVA converter
using video converter module "yuvp"
Deinterlacing available
deinterlace -1, mode auto, is_needed 0
looking for vout window module matching "any": 3 candidates
no vout window modules matched
Opening vout display wrapper
looking for vout display module matching "any": 12 candidates
creating Vout EventThread
Win32VoutCreateWindow
inclinometer not found. (hr=0x80070490)
created video sub-window
Vout EventThread running
Created the D3D11 device type 1 level b100.
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
supports colorspace RGB Rec.709 gamma:22 range:FULL
supports colorspace RGB Rec.709 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:STUDIO
Output max luminance: 270.0, colorspace RGB Rec.709 gamma:22 range:FULL, bits per pixel 8
using colorspace RGB Rec.709 gamma:22 range:FULL
Using pixel format VA_NV12 for chroma DX11
Direct3D11 resources created
Direct3D11 device adapter successfully initialized
Direct3D11 Open Succeeded
using vout display module "direct3d11"
D3D11 pool succeed with 40 surfaces (640x512) context 0x00000209797c34e0
original format sz 640x480, of (0,0), vsz 640x480, 4cc DX11, sar 1:1, msk r0x0 g0x0 b0x0
VoutDisplayEvent 'window state' 0
VoutDisplayEvent 'window state' 0
Adding 'scene' as interactive
looking for video filter module matching "scene,chain": 46 candidates
Trying to use chroma I420 as middle man
looking for video converter module matching "any": 24 candidates
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978091e80) appended to chain
looking for video filter module matching "scene,chain": 46 candidates
using video filter module "scene"
Filter 'scene' (00000209780917a0) appended to chain
using video filter module "chain"
Filter 'scene' (0000020978091b10) appended to chain
Adding a filter to compensate for format changes
looking for video converter module matching "any": 24 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
looking for video converter module matching "any": 24 candidates
using video converter module "i420_nv12"
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (00000209780921f0) appended to chain
removing module "chain"
removing module "d3d11_filters"
Filter 0000020978091e80 removed from chain
removing module "scene"
Filter 00000209780917a0 removed from chain
Filter 0000020978091b10 removed from chain
removing module "d3d11_filters"
removing module "i420_nv12"
Filter 00000209780921f0 removed from chain
Adding 'scene' as interactive
looking for video filter module matching "scene,chain": 46 candidates
Trying to use chroma I420 as middle man
looking for video converter module matching "any": 24 candidates
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978091e80) appended to chain
looking for video filter module matching "scene,chain": 46 candidates
using video filter module "scene"
Filter 'scene' (0000020978092560) appended to chain
using video filter module "chain"
Filter 'scene' (00000209780921f0) appended to chain
Adding a filter to compensate for format changes
looking for video converter module matching "any": 24 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
looking for video converter module matching "any": 24 candidates
using video converter module "i420_nv12"
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978090d50) appended to chain
removing module "freetype"
looking for text renderer module matching "any": 3 candidates
VoutDisplayEvent 'resize' 640x480
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for hw decoder module matching "any": 2 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
Reusing Direct3D11 device
CreateDevice succeed
- 'MPEG-2 variable-length decoder' is supported
- 'MPEG-2 inverse discrete cosine transform' is supported
- 'VC-1 variable-length decoder' is supported
- 'VC-1 variable-length decoder 2 (Intel)' is supported
- 'VC-1 variable-length decoder (Intel)' is supported
- 'Windows Media Video 9 IDCT' is supported
- 'VC-1 inverse discrete cosine transform' is supported
- 'H.264 variable-length decoder, no film grain technology' is supported
- 'H.264 stereo high profile, mbs flag set' is supported
- 'H.264 stereo high profile' is supported
- 'H.264 multiview high profile' is supported
- 'Unknown decoder 0xc528916c-0xc0af-0x4645-0x8cb2372b6d4adc2a' is supported
- 'Unknown decoder 0x91cd2d6e-0x897b-0x4fa1-0xb0d751dc88010e0a' is supported
- 'VP8' is supported
- 'Unknown decoder 0x442b942a-0xb4d9-0x4940-0xbc45a882e5f919f3' is supported
- 'Unknown decoder 0x97688186-0x56a8-0x4094-0xb543fc9daaa49f4b' is supported
- 'Unknown decoder 0x1424d4dc-0x7cf5-0x4bb1-0x9cd7b63717a72a6b' is supported
- 'Unknown decoder 0xc346e8a3-0xcbed-0x4d27-0x87cca70eb4dc8c27' is supported
- 'Unknown decoder 0xffc79924-0x5eaf-0x4666-0xa73606190f281443' is supported
- 'Unknown decoder 0xf416f7bd-0x098a-0x4cf1-0xa11bce54959ca03d' is supported
- 'Unknown decoder 0xbf44dacd-0x217f-0x4370-0xa383d573bc56707e' is supported
- 'Unknown decoder 0x2364d06a-0xf67f-0x4186-0xaed062b99e1784f1' is supported
- 'Unknown decoder 0x464bdb3c-0x91c4-0x4e9b-0x896f225496ac4ed6' is supported
- 'Unknown decoder 0x28566328-0xf041-0x4466-0x8b148f5831e78f8b' is supported
- 'Unknown decoder 0x6b4a94db-0x54fe-0x4ae1-0x9be47a7dad004600' is supported
- 'Unknown decoder 0x8c56eb1e-0x2b47-0x466f-0x8d337dbcd63f3df2' is supported
- 'HEVC Main profile' is supported
- 'Unknown decoder 0x75fc75f7-0xc589-0x4a07-0xa25b72e03b0383b3' is supported
- 'HEVC Main 10 profile' is supported
- 'Unknown decoder 0x07cfaffb-0x5a2e-0x4b99-0xb62ae4ca53b6d5aa' is supported
- 'VP9 profile 0' is supported
- 'VP9 profile 2' is supported
- 'VP9 profile Intel' is supported
- 'Unknown decoder 0x80a3a7bd-0x89d8-0x4497-0xa2b82126af7e6eb8' is supported
- 'Unknown decoder 0x8de911c4-0xc898-0x4364-0x97151de6b3fe773d' is supported
- 'Unknown decoder 0x50925b7b-0xe931-0x4978-0xa12a586630f095f9' is supported
- 'Unknown decoder 0xb69c20e0-0x2508-0x8790-0x0305875499e0a2d0' is supported
- 'Unknown decoder 0x49761bec-0x4b63-0x4349-0xa5ff87ffdf088466' is supported
Trying to use 'H.264 variable-length decoder, no film grain technology' as input
NV12 output is supported for decoder H.264 variable-length decoder, no film grain technology.
Using output format NV12 for decoder H.264 variable-length decoder, no film grain technology
va_pool_SetupDecoder id 27 640x480 count: 24
using external surface pool
ID3D11VideoDecoderOutputView succeed with 24 surfaces (640x480)
we got 9 decoder configurations
configuration[0] ConfigBitstreamRaw 2
configuration[1] ConfigBitstreamRaw 1
configuration[2] ConfigBitstreamRaw 2
configuration[3] ConfigBitstreamRaw 2
configuration[4] ConfigBitstreamRaw 2
configuration[5] ConfigBitstreamRaw 2
configuration[6] ConfigBitstreamRaw 2
configuration[7] ConfigBitstreamRaw 1
configuration[8] ConfigBitstreamRaw 1
DxCreateDecoderSurfaces succeed
using hw decoder module "d3d11va"
Using D3D11VA (Intel(R) UHD Graphics P630, vendor 8086(Intel), device 3e94, revision 0) for hardware decoding
Buffering 19%
auto hiding mouse cursor
Buffering 32%
Buffering 46%
Buffering 59%
Buffering 75%
Buffering 89%
tk->rtpSource->hasBeenSynchronizedUsingRTCP()
Stream buffering done (1026 ms in 2238 ms)
buffer deadlock prevented
Decoder wait done in 0 ms
looking for encoder module matching "any": 24 candidates
using encoder module "jpeg"
looking for video converter module matching "any": 24 candidates
640x480 (640x480) chroma: I420 -> 640x480 (640x480) chroma: J420 with scaling using Bicubic (good quality)
using video converter module "swscale"

因此,从流中生成的所有屏幕截图都是 640x480,如果可能,我需要它们基于传入视频流的大小。

【问题讨论】:

  • 你是怎么截屏的?
  • 我正在使用“--video-filter=scene”选项。它会自动创建图像文件。我使用的是 TakeSnapshot 方法,但它没有产生任何不同的结果。

标签: libvlc libvlcsharp


【解决方案1】:

MediaPlayer上试试这个方法

bool TakeSnapshot(uint num, string filePath, uint width, uint height)

【讨论】:

  • 我一开始是用这个方法的,但是结果对我来说是一样的。
  • 我只是做了一些改变来测试一些东西,我可以生成更大尺寸的快照,但是原始视频源显然没有缩放到正确的质量,因为图像非常像素化。所以,我认为我需要一些关于如何正确缩放(而不是调整大小)原始视频输入源的选项,而不仅仅是调整快照的大小。
  • x264 预设“超快”的意思是“优先考虑编码速度而不是质量”您正在重新编码质量较差的视频,这就是输出中有像素化图片的原因
  • @cube45 我试图模仿我在 VLC 应用程序中看到的设置。它具有相同的设置并使用相同的流,并且它的快照没有像素化。
【解决方案2】:

我刚刚发现问题出在哪里。 RTSP 流具有预览和主提要。我正在使用我的代码中的预览提要,即 640x480。一旦我切换到正确的(主要)提要,一切都按预期工作。

【讨论】:

  • 刚刚发现了那个奇怪的 URL,很高兴您找到了解决方案。您可以将此标记为解决方案以将问题标记为“已解决”
猜你喜欢
  • 2013-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-27
  • 2018-01-18
  • 2018-10-22
  • 2012-07-01
相关资源
最近更新 更多