How do I adjust the video resolution?

1

I'm trying to adjust the resolution of the incoming H.264 RTSP stream. I am running on Windows 10 for now, but will eventually move this to Linux. I am creating the LibVLC object passing in several command line args, but nothing I have tried affects the resulting screen resolution.

When I open the same RTSP steam in the VLC media player app, the resolution is 2560x1980, which is the native resolution I want in my app. But, when my app runs, it's only 640x480. FYI - this is not a Windows UI app. It's a service that is just taking screenshots. So, there is not media control on a form to adjust.

Here is what I have right now:

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);

Some of the x264 options are just ones that I tested that I saw in the VLC App. They did not adjust the resolution.

Here is the log file:

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"

So, all of the resulting screen shots from the stream are 640x480 and I need them to be based on the size of the incoming video stream if possible.

libvlc
libvlcsharp
asked on Stack Overflow Aug 20, 2019 by runninggeek • edited Aug 20, 2019 by runninggeek

2 Answers

0

Try this method on the MediaPlayer

bool TakeSnapshot(uint num, string filePath, uint width, uint height)
answered on Stack Overflow Aug 20, 2019 by mfkl
0

I just figured out what the issue was. The RTSP stream has a preview and a main feed. I was consuming the preview feed in my code, which is 640x480. Once I switched to the correct (main) feed, everything is working as expected.

answered on Stack Overflow Aug 21, 2019 by runninggeek

User contributions licensed under CC BY-SA 3.0