astromo
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2011
04:02 PM
How to get the video height and width ?
Hello,
I want to get the height and width of a video file to be streamed and then use the metadata for stretching the video to fullscreen as explained in
viewtopic.php?f=34&t=36583&start=0
But I don't know how "item.height" and item.width" are obtained. Please suggest me.
I want to get the height and width of a video file to be streamed and then use the metadata for stretching the video to fullscreen as explained in
viewtopic.php?f=34&t=36583&start=0
But I don't know how "item.height" and item.width" are obtained. Please suggest me.
8 REPLIES 8
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2011
05:22 PM
Re: How to get the video height and width ?
I don't think brigthscript can do that yet. So you could use something like ffmpeg to get the information from your video and break it out into the xml file your channel is parsing.
<?php
// get video width and height
// Will - 10-14-07
// for testing call with: ffmpeg_image.php?file=video.mp4
$videofile = (isset($_GET['file'])) ? strval($_GET['file']) : 'video.mp4';
ob_start();
passthru("ffmpeg-10141.exe -i \"". $videofile . "\" 2>&1");
$size = ob_get_contents();
ob_end_clean();
preg_match('/(\d{2,4})x(\d{2,4})/', $size, $matches);
$width = $matches[1];
$height = $matches[2];
" Size: " . $size . "<br />\n";
print " Width: " . $width . "<br />\n";
print "Height: " . $height . "<br />\n";
?>
astromo
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2011
11:45 PM
Re: How to get the video height and width ?
Thank you. It seems quite strange to see there are functions to retrieve metadata of images and audio files but there is none for videos. Do I miss something in the reference manual?
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
12:07 AM
Re: How to get the video height and width ?
"astromo" wrote:
Thank you. It seems quite strange to see there are functions to retrieve metadata of images and audio files but there is none for videos. Do I miss something in the reference manual?
Both roAudioMetadata and roImageMetadata are fairly recent additions, introduced in the SDK version 2.9. Both components only operate on local files and will not currently extract the metadata from streams delivered over the network. I'm not sure if/when Roku plans to offer support to retrieve meta data from network streams or for video streams.
astromo
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
01:08 AM
Re: How to get the video height and width ?
So is there any possible way to stretch a video stream to the full screen? Thanks.
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
09:04 AM
Re: How to get the video height and width ?
"astromo" wrote:
So is there any possible way to stretch a video stream to the full screen? Thanks.
Are all the videos the same size, one of several sizes, or any number of different sizes?
You can determine the width and height of a video, and anything else you want to know about it, by downloading it and examining it using mediainfo. You can then use the width and height values with SetDestinationRect as described in the post you cited earlier. If you have two or three possible video sizes you could offer the user an option to display the video in full-screen mode by selecting from one of a list of corresponding zoom factors; I know, that's not a very elegant solution though. If you have no idea what the video dimensions will be then I think you're out of luck.
Ideally, if you have control over the video content, you should determine the width and height before the video is streamed and pass that info along with the video url and other metadata in an XML feed that your Roku code can extract.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
01:06 PM
Re: How to get the video height and width ?
"astromo" wrote:
So is there any possible way to stretch a video stream to the full screen? Thanks.
There's no way to "stretch" video at all on the Roku. You can "zoom" in or out using SetDestinationRect, but the video will always maintain the detected aspect ratio. The ability to stretch has been requested in the past, but I don't think Roku has ever commented.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
01:30 PM
Re: How to get the video height and width ?
"TheEndless" wrote:
You can "zoom" in or out using SetDestinationRect, but the video will always maintain the detected aspect ratio.
The last time I checked, SetDestinationRect has no effect on an roVideoScreen on a Roku 2. Also, even on a Roku 1 you can only zoom in so far (and it's not very far).
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2011
01:43 PM
Re: How to get the video height and width ?
I've been able to alter the video height and width - whether that was 'stretch' or 'zoom' I don't know - but there were limits and it took a lot of time to find 'close to the sweet spot' I wanted. It is a lot more headache than it's worth if you're using a bunch of different video dimensions - and then the stretching effect has to be changed based on the display mode of the roku box on top of that, so your settings for 720p and 640i are going to be different. If you have a few days or weeks to kill trying different values for each and every new proportion of video to play back with custom videoplayer, great - I think the stretch limit I could come up with was something like 14-15% larger than the original video size. It is much easier to simply leave the source videos alone, or re-encode them to what the dimensions should be to fit the tv.
Alternatively - if you're looking at the custom videoplayer example, it looks like it's a lot easier to 'shrink' the video, but I don't know of many people who actually do that.
Alternatively - if you're looking at the custom videoplayer example, it looks like it's a lot easier to 'shrink' the video, but I don't know of many people who actually do that.