Stretching Video and Images

This forum is about all development around libVLC.
SaundersB
Blank Cone
Blank Cone
Posts: 16
Joined: 30 Dec 2016 15:44

Stretching Video and Images

Postby SaundersB » 03 Feb 2017 23:10

I'm attempting to play video and images inside a Qt QFrame. I have to set the QFrame dimensions manually, and need to stretch the video to match the QFrame dimensions.

No matter what I do I can't seem to get the video to stretch to both the horizontal and vertical. I want to change the video and not the widget.

I've attempted calculating the aspect ratio and setting the input to transcode as an output with a set width and height.

Any other ideas or methods out there are greatly appreciated. Thank you.

Note: I've read just about every post on this topic and haven't found that I would be able to stretch video/images to match their parent frame.

Code: Select all

/* Create a new LibVLC media descriptor */ _m = libvlc_media_new_path(_vlcinstance, (const char *)(file.toUtf8())); libvlc_media_add_option(_m, ":transcode{vcodec=mp4v,width=400,height=200}"); libvlc_video_set_aspect_ratio(_mp, "9:3"); libvlc_media_player_set_media(_mp, _m); HWND windowID = reinterpret_cast<HWND>(this->winId()); /* Get our media instance to use our window */ libvlc_media_player_set_hwnd(_mp, windowID); libvlc_media_player_set_position(_mp, 0); /* Play */ libvlc_media_player_play(_mp);

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Stretching Video and Images

Postby Rémi Denis-Courmont » 04 Feb 2017 07:20

As far as I recall, there currently exists no options inr LibVLC to ignore the P.A.R. and stretch the video rectangle in both dimensions.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

kodela
Big Cone-huna
Big Cone-huna
Posts: 632
Joined: 25 Sep 2012 19:40
VLC version: 2.2.4
Operating System: Windows 10
Location: Germany

Re: Stretching Video and Images

Postby kodela » 04 Feb 2017 09:36

Try using the Monitor pixel aspect ratio option.
This allows the ratio of the width to the height to be adjusted.
The "Zoom video" option allows you to adjust the ratio of the size of the display to the size of the video.

Example:
A video with resolution 1280 x 720

Monitor pixel aspect ratio: 0.8
Zoom video: 1
Display: 1600 x 720

Monitor pixel aspect ratio: 0.8
Zoom video: 0.8
Display: 1280 x 576

SaundersB
Blank Cone
Blank Cone
Posts: 16
Joined: 30 Dec 2016 15:44

Re: Stretching Video and Images

Postby SaundersB » 13 Feb 2017 16:59

Thank you for your help.

I ended up calculating the aspect ratio dynamically.

Code: Select all

int gcd = greatest_common_divisor(window_width, window_height); int new_width = window_width / gcd; int new_height = window_height / gcd; std::string ratio = convert_int_to_string(new_width) + ":" + convert_int_to_string(new_height); const char * final_ratio = ratio.c_str(); libvlc_video_set_aspect_ratio(_mp, final_ratio); std::string convert_int_to_string(int number) { std::ostringstream ss; ss << number; return ss.str(); }
Hope this helps anybody else out there looking to do the same!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 21 guests