Using the Samsung SPF-87H Digital Photo Frame as a Mini-Monitor under Linux with a Python Program

Sunday, March 11, 2012

A video showing video on the Samsung photoframe

Using the Python programs from this site I demonstrate with a video recorded by digital camera from a Samsung SPF-87H Digital Photo Frame. The quality of the video shown here on the blog is awful in color and resolution, while on the photoframe itself both are excellent. But at least this clip shows that the video plays smoothly through all scenes.

The setup used a virtual frame buffer, so this setting can also be used for in a headless client. In a terminal give these commands :

This creates a virtual frame buffer xserver as #99 with a screen resolution the same as the photoframe (800x480, change to match your frame if needed, here and also in the script ), and in it starts the Python videoframe script (see below), and uses mplayer to play a movie in full screen mode. This was then recorded with a digital camera from the photoframe, and uploaded to this post.

The videoframe script records some frame and transfer rates. Here is an excerpt from the final scenes (each line is an average over 50 frames, i.e. 2-3 seconds):

Depending on the complexity of the picture to be jpg coded, the observed variation in fps ranges from 11 ... 27fps. In this setup the cpu is a 6 year old Intel Core2 T7200 2.0GHz, running at ~50% load (its cpu-mark is 1150; for reference: today's Intel Core i5-2500 has a cpu-mark of 6750). As noticed earlier, the bottleneck appears to be the frame itself. The speed of movements within the movie scenes does NOT play a role for the transfer rate, as always a single screenshot is taken and processed. However, fine structures (grass, hair, fur,...) which make for big jpg files slow the frame rate down.

The python code for videoframe is shown below the line. See code in other posts below for more detailed comments on parts of the script.

Update:
the command:

pmap.save(buffer, 'jpeg')

is the same as:

pmap.save(buffer, 'jpeg', quality = -1)

which sets the quality to its default setting of 75. Quality ranges from 0 (=very poor) to 100 (=very good). The save command itself is not faster at poorer settings, but the resulting picture size is smaller, and thus transfer speed over the USB bus increases, allowing higher frame rates! Quality settings of 60 are usually good enough; certainly for video.

# Program: videoframe## This videoframe program plays videos on the 'Samsung SPF-87H Digital Photo Frame'# by taking rapid snapshots from a video playing on a screen and transfers them as jpeg# pictures to the photo frame# # It is an application of the sshot2frame program found on the same# website as this program# Read that post to understand details not commented here# Copyright (C) ullix

# Enter into a loop to repeatedly take screenshots and send them to the framestart = time.time()frames = 0mbyte = 0

while True: # take a screenshot and store into a pixmap # the screen was set to 800x480, so it already matches the photoframe # dimensions, and no further processing is necessary pmap = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId())

# create a buffer object and store the pixmap in it as if it were a jpeg file buffer = QtCore.QBuffer() buffer.open(QtCore.QIODevice.WriteOnly)

pmap.save(buffer, 'jpeg')

# now get the just saved "file" data into a string, which we will send to the frame pic = buffer.data().__str__()