Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
360tv
Streaming Star

getting a black image on roScreen

I'm getting a black square where I should be getting the image i'm trying to display.

screen.Clear(&h00000000)
print "overlay URL = " + device.overlayurl
http = CreateObject("roUrlTransfer")
http.SetUrl(device.overlayurl)
http.GetToFile("tmp:/overlay.png")


dfDrawImage(screen, "tmp:/overlay.png",0,0)
screen.swapbuffers()


that code runs once per 10 seconds. If I moved the draw and swap functions into an message = invalid loop, it will flicker sometimes displaying the image, but mostly not. The image is to display over a videoplayer, 95% transparent.

I'm sure it's something stupid.
0 Kudos
16 REPLIES 16
TheEndless
Channel Surfer

Re: getting a black image on roScreen

What are the dimensions of overlay.png, and what happens if you don't have video playing? What other bitmaps do you have loaded into memory at the time? The available bitmap memory is extremely limited when you have video playing, so if you're overrunning the limit, you'll see the behavior you're describing.
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)
0 Kudos
360tv
Streaming Star

Re: getting a black image on roScreen

It's a full screen overlay, so 720x1280. It's the only image I'm attempting to display. I have not tried to display the image while video is not playing, since it wouldn't suit my needs.

I had no problem displaying the image using roImagecanvas but since I can't seem to do roImageCanvas and roScreen at the same time I can't use it with everything else I'm doing.

What is the memory limit while playing video?

Also, Endless, while I have you here and since you seem to be the leading expert, let me ask you;
I've implimented a news craw on my videoplayer with roscreen, scrolling text a few pixels, per buffer swap, per invalid port message. When I did try to draw an image to the screen during that same loop, it slows down a ton. Probably by a quarter or so. Do you know any tricks?
0 Kudos
RokuMarkn
Visitor

Re: getting a black image on roScreen

Drawing an image shouldn't take a significant amount of time. You're not downloading the image each frame, are you?

--Mark
0 Kudos
TheEndless
Channel Surfer

Re: getting a black image on roScreen

"360tv" wrote:
It's a full screen overlay, so 720x1280. It's the only image I'm attempting to display. I have not tried to display the image while video is not playing, since it wouldn't suit my needs.

I understand that it wouldn't suit your needs. I suggested it, because it would help narrow down the cause. If the image draws when no video is playing, but doesn't draw when video is playing, then that would suggest a video memory issue. You should also try calling roVideoPlayer.SetMaxVideoDecodeResolution(1280, 720), as this will reduce the amount of memory the roVideoPlayer pre-allocates for itself.

"360tv" wrote:
I've implimented a news craw on my videoplayer with roscreen, scrolling text a few pixels, per buffer swap, per invalid port message. When I did try to draw an image to the screen during that same loop, it slows down a ton. Probably by a quarter or so. Do you know any tricks?

Without seeing your code, it's hard to say, but as RokuMarkn stated, adding an image shouldn't have a significant impact on the framerate unless you're creating the bitmap every frame, instead of creating it once, then re-using it.
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)
0 Kudos
360tv
Streaming Star

Re: getting a black image on roScreen

I've changed my image to a super small one, like 100x20 px. it's showing up with the code bellow but I'm getting this annoying, inconsistent flicker on mostly the lower half of my screen. The further down, the more persistent it is. It does not affect the video or the image, only text, lines, and squares being drawn (of which there are about 35 total)

Does dfDrawImage recreate a bitmap? because that's what I'm using in my draw loop. Here's an overview of my code. I've taken out some parts of the code, xml fetches and such. I promise the important stuff is there.

Library "v30/bslDefender.brs"
Function showVideoStream(url as object)

'...declare about 6 xml elements, 6 timespans, 3 arrays, and about 20 variables. I hope that isn't causing a memory issue.

if displaymode = "720p" then
fontsmall = reg.GetDefaultFont(12, false, false)
font = reg.GetDefaultFont(18, false, false)
fontlarge = reg.GetDefaultFont(24, false, false)
else
fontsmall = reg.GetDefaultFont(8, false, false)
font = reg.GetDefaultFont(12, false, false)
fontlarge = reg.GetDefaultFont(22, false, false)
end if

screen = CreateObject("roScreen", true)
screen.SetMessagePort(port)




preroll = {
stream: { url: url.preroll}
streamFormat : url.prerollFormat
}

player = CreateObject("roVideoPlayer")
player.SetMaxVideoDecodeResolution(1280, 720)
player.SetMessagePort(port)
player.SetPositionNotificationPeriod(url.PositionNotificationPeriod)
player.SetDestinationRect({x:0, y:0, w:0, h:0})
player.setloop(false)
player.SetContentList([{
streamFormat: url.streamformat
stream: { url: url.streamurls[0] }
}])

if ShowPreroll(preroll)
player.Play()
end if

viewpost = "www"
print viewpost
xfer.seturl(viewpost)
RawXMLData=xfer.gettostring()
if xml.parse(RawXMLData) then
'fill "Device" array
end if

screen.Clear(&h00000000)
screen.finish()


m.buffercount = 0
while true

msg=port.getmessage()

'*******************************
'Viewpost Timer
'*******************************
if (viewposttimer.TotalMilliseconds() / 1000) >= m.PositionNotificationPeriod
viewposttimer.mark()
nowpos = nowpos + url.PositionNotificationPeriod
print "Playback position: " + nowpos.toStr()
device.clear()
overlays.clear()
nextoverlays.clear()
xml.clear()
viewpost = "www"
xfer.seturl(viewpost)
RawXMLData=xfer.gettostring()
if xml.parse(RawXMLData) then
'fill "device" array
end if

'***************************************
'Print Items
'***************************************
else if (msg = invalid)
if (screenmode = 0)
'nothin


'*******************************************HD Drawing *********************************
'*********** PROBLEM AREA

else if (screenmode = 1) and ( displaymode = "720p")
screen.Clear(&h00000000)
dfDrawImage(screen, "tmp:/overlay.png",200,200)
for idx = 0 to ( catcount.count() - 1)
if idx = newsindex then
if (newslength > 0) and (newstimer.totalseconds() > 6) and (Xcrawl < newslength +200 )
screen.DrawRect(strtoi(interfacexml.cat[idx].x1.gettext()),strtoi(interfacexml.cat[idx].y1.gettext()), strtoi(interfacexml.cat[idx].w1.gettext()) - Ccrawl, strtoi(interfacexml.cat[idx].h1.gettext()), HexToInteger3(interfacexml.cat[idx].color.gettext()))
Ccrawl = Ccrawl + (( strtoi(interfacexml.cat[idx].w0.gettext()) /(newslength +200)) * device.newscrawlspeed)
else
screen.DrawRect(strtoi(interfacexml.cat[idx].x1.gettext()),strtoi(interfacexml.cat[idx].y1.gettext()), strtoi(interfacexml.cat[idx].w1.gettext()), strtoi(interfacexml.cat[idx].h1.gettext()), HexToInteger3(interfacexml.cat[idx].color.gettext()))
end if
else
screen.DrawRect(strtoi(interfacexml.cat[idx].x0.gettext()),strtoi(interfacexml.cat[idx].y0.gettext()), strtoi(interfacexml.cat[idx].w0.gettext()), strtoi(interfacexml.cat[idx].h0.gettext()), HexToInteger3(interfacexml.cat[idx].color.gettext()))
end if
screen.DrawText(interfacexml.cat[idx].subcat[subcatindex[idx]].label.gettext(), strtoi(interfacexml.cat[idx].x.gettext()), strtoi(interfacexml.cat[idx].y.gettext()), &hFFFFFFFF, font)
next idx

if (newstimer.totalseconds() >= 4) and (newstimer.totalseconds() <= 6)
for each obj in newsxml.overlay
screen.DrawText(obj.text.gettext(), strtoi(obj.X.gettext()), strtoi(obj.Y.gettext()), &hFFFFFFFF, font)
next
else if (newstimer.totalseconds() >= 6) and (Xcrawl < newslength +200 )
xcrawl = xcrawl + device.newscrawlspeed
for each obj in newsxml.overlay
screen.DrawText(obj.text.gettext() , strtoi(obj.X.gettext()) - xcrawl , strtoi(obj.Y.gettext()), &hFFFFFFFF, font)
next
end if


if (weathertimer.TotalSeconds() <= m.WeatherNotificationPeriod)
for each obj in weatherxml.overlay
screen.DrawRect(strtoi(obj.X.gettext()), strtoi(obj.Y.gettext()), strtoi(obj.W.gettext()), strtoi(obj.H.gettext()), HexToInteger3(obj.color.gettext()))
next
screen.DrawRect(1030,20, 200 - ((weathertimer.totalmilliseconds() / 1000) * (200 / m.WeatherNotificationPeriod ) ),5, HexToInteger3("40404040"))
else if (weathertimer.totalseconds() > m.WeatherNotificationPeriod)
for each obj in weatherxml.overlay
screen.DrawRect(strtoi(obj.X.gettext()), strtoi(obj.Y.gettext()), strtoi(obj.W.gettext()), strtoi(obj.H.gettext()), HexToInteger3(obj.color.gettext()))
next
weatherxml.clear()
weathermark = 0
weathertimer.mark()
end if


screen.SwapBuffers()

end if

End Function
0 Kudos
RokuMarkn
Visitor

Re: getting a black image on roScreen

Yes, dfDrawImage does create a bitmap. That's probably what's slowing you down. You can see the source for dfDrawImage in the debugger like this:

BrightScript Debugger> ?readasciifile("common:/LibCore/v30/bslDefender.brs")


--Mark
0 Kudos
RokuJoel
Binge Watcher

Re: getting a black image on roScreen

You might move your swapbuffers outside the if/then so:

...
while true
if blah then drawstuff

end if
screen.swapbuffers()
end while
0 Kudos
TheEndless
Channel Surfer

Re: getting a black image on roScreen

"360tv" wrote:
but I'm getting this annoying, inconsistent flicker on mostly the lower half of my screen.

Yes, that came about when the new home screen interface was introduced. You can now have screen tearing/flicker when using double-buffered screens if your framerate drops below 30fps. It's extremely annoying. If you reuse your bitmaps, instead of recreating them on every loop via dfDrawImage, that'll probably go away for the most part.
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)
0 Kudos
RokuJoel
Binge Watcher

Re: getting a black image on roScreen

Endless, can you maybe email me a side loadable example of double-buffered tearing, so I can file a bug on that?

- Joel
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.