Sign up here and you can log into the forum!

Webend remote view

Feature requests / enhancements discussion regarding the web interface

Re: Webend remote view   

Postby Darren » Wed Jan 09, 2013 8:33 pm

I found the perfect image header (TGA) but then discovered that convert has a slowness issue when reading this one specific format, lol.

Then I realized I could use a BMP header. Its 6 bytes too big, but I'd say the speed improvement is worth sacrificing two pixels, which it turns out you can't really see. :-)

I think this new method is about as fast as I can make it, taking about 2 seconds to capture and save a screenshot directly on the wdtv.

Code: Select all
printf "\x01" | nc localhost 3490 > /tmp/screen.bmp
bytes=`stat -c %s /tmp/screen.bmp`
if [ "$bytes" -eq "3686420" ]; then   # the normal uncompressed image file always has the same number of bytes
   echo Screen update: Yes
   # here we overwrite the existing image header with a BMP v2 format one, which lets convert understand the image data
   printf "\x42\x4D\x1A\x40\x38\x00\x00\x00\x00\x00\x1C\x00\x00\x00\x0C\x00\x00\x00\x00\x05\xD0\x02\x01\x00\x20\x00\x44\x44" | dd of=/tmp/screen.bmp bs=1 count=28 conv=notrunc 2> /dev/null
   printf "\x00\x00\x00\xFF\x00\x00\x00\xFF" >> /tmp/screen.bmp            # need to append two extra pixels of data, since the new header overwrote two of them
   convert -flip -roll +2+0 /tmp/screen.bmp -quality 70 /tmp/screen.jpg      # 90 is good quality, 70 is okay and 600ms faster
else
   echo Screen update: No
fi
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby Darren » Wed Jan 09, 2013 8:55 pm

mad_ady wrote:...the idea is to have a script/program on the WDTV that will request a screen refresh and save it in a temporary file and have a web page (integrated into the webend) periodically request this image.

Thanks for your help on this, and recliq too.

The webend idea sounds great, and seems very doable, and would make a good platform agnostic viewing method. I'd like to use it!
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Wed Jan 09, 2013 9:00 pm

Great job! One more test - is it significantly faster to generate a bmp image instead? It might be faster to download a bmp in LAN than to convert to jpg.
Also another idea is to run your script with a higher priority - it shouldn't affect playback - just it might slow down the osd a bit...
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby mad_ady » Wed Jan 09, 2013 9:04 pm

Regarding the webend idea, i was thinking of a page with two frames - on the left load the webend remote, on the right load the screenshot image. Request the image via an ajax call (and maybe display a timestamp with the last received image...)
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby Darren » Wed Jan 09, 2013 9:49 pm

You can get a usable bmp image in about 350ms, but at 3.6 MB in size it takes a second or two to load in my browser over a 100mbit copper connection. It might be a choice between causing cpu load on the wdtv vs using more bandwidth to your browser. There are various levels in between too... like a 2.7 MB bmp takes under 1 second to create.

Oh good, I like the ajax idea; that should give a better experience. I was thinking you could also have direct keyboard control while viewing the screenshot image, similar to how the WDTVTelnetRemote app works. I've used this before in a browser and it works well. Just need to monitor the right keyboard events in the browser, and then you can use your arrow keys, enter, backspace, etc, to control the gui remotely. The visible remote could be toggled for people who like to use their mouse, or just the keyboard.
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Wed Jan 09, 2013 10:53 pm

Regarding the image format - have you tested with various sizes? Does it take longer to downscale the image from 1280x720 to something smaller (like 640x360?). In the end it could be user selectable in the webend.

Regarding direct keyboard control - do you mean this http://forum.wdlxtv.com/viewtopic.php?f=40&t=4463&start=20? This is supported only on 1.05. Or, do you mean catching standard key events (arrows, enter, backspace) with javascript and pushing the corresponding remote key presses? This is doable, and would be nice. The visible remote could be toggled on demand.

This turns out to be a nice app.bin :)
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby Darren » Thu Jan 10, 2013 12:51 am

It does take longer to resize an image -- about twice as long. I guess the math for that is cpu intensive.

Yes, I meant catching the key events with javascript and sending the remote key events with the existing webend methods.

Here are the keys used by the WDTVTelnetRemote. It might be good to use the same ones? Or if there is a config page they could be user defined.

Code: Select all
ctrl-Q   reboot
Q         power
space   play
esc      stop
enter   enter
arrows   arrows
home      home
page      prev/next
back      backspace
O         option
F         FF
R         RW
E         eject
S         search
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Thu Jan 10, 2013 1:10 am

I'd use the calls implemented by the webend remote - it seems to make POST calls to /addons/remote/?noMenu=1 with the parameter button:T_back. No need to reimplement anything here. The advantage is - if anything were to change in future versions, correcting the webend remote would correct your code as well.

Regarding resizing - it probably does interpolation to figure out the best pixel value based on adjacent values. You can probably tell it not to use any interpolation (and just strip even numbered lines and columns). This should be a bit faster, but I'm not fluent in imagemagick syntax... The visual results should be fine for the regular user - since you rarely have 1px width items onscreen that you are interested in...
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Webend remote view   

Postby Darren » Thu Jan 10, 2013 1:49 am

You're right, I gave you the interpolation numbers. You can do pixel discarding too, but the results are not pretty. :?
It takes about a second with that method, bmp or jpg, but text is not as easy to read, as those elements are quite thin and get faint, and the letters get all jaggy looking too.
But having options is good...

And yep, the benefit of modular code :-)
Darren
DLX'er
 
Posts: 69
Joined: Sat Jun 19, 2010 3:35 pm

Re: Webend remote view   

Postby mad_ady » Thu Jan 10, 2013 1:59 am

Can you post an example with pixel discarding to see how bad it is?
The reason for it might be for people who use music services with the tv off and who need to navigate to shoutcast/pandora and click play. They might not need to do a lot of reading. And also there are those who mostly use thumbnails/sheets in their navigation...

Having it as an option might be nice - something like a drop down menu with several possible values with the best option (in terms of quality) set as default:
* 1280x720 bmp (3.6MB, ~2 seconds)
* 1280x720 jpg (xMB, y seconds)
* 640x360 bmp (xMB, y seconds)
* 640x360 jpg (xMB, y seconds)

Also, it would be nice if you package your script as a standalone binary that can be called from the command line, pass a resolution and image format as parameter and write out the image (either to a specified file or directly to stdout). It could then be called through a php wrapper in ajax mode and the php part can set the necessary headers and passthru($cmd) to get the image. The php wrapper can be called by other applications that want to get a screenshot (e.g. a remote application on a phone/tablet).

In the end I see this binary extended to support image generation on 1.05 as well, and packed together with the web interface in an app.bin.
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

PreviousNext

Return to Webend Web Interface

Who is online

Users browsing this forum: No registered users and 2 guests