Yes, your last modifications made it work after about 2 or 3 seconds.<div>(I moved the gst initialisation and implemented the try/catch loop)</div><div>Thanks<br><br><div class="gmail_quote">2011/12/7 James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Wed, Dec 07, 2011 at 01:07:46AM +0100, laurent bernabe wrote:<br>
> 2011/12/7 James Cameron <<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>> wrote:<br>
> > You might also try moving the setup of the gst stream to after the<br>
> > initialisation of pygame.  Experiment, and let us know your results.<br>
><br>
> Sorry but I did not understand this sentence<br>
<br>
</div>Sorry.  Try moving the "setup of the gst stream" to after the<br>
"initialisation of pygame".<br>
<br>
The "setup of the gst stream" are the lines:<br>
<br>
        # grab a frame from camera to file<br>
        pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc !  filesink location=/tmp/pippypic.jpg')<br>
        pipeline.set_state(gst.STATE_PLAYING)<br>
<br>
The "initialisation of pygame" is the line:<br>
<br>
        # start using pygame<br>
        pygame.init()<br>
<br>
Moving one beyond the other means to change the order in which these<br>
operations occur.  I expect the result will be certain failure, which is<br>
a useful result because it proves the timing is important.<br>
<br>
--<br>
<br>
Given your test results of success if more time is wasted, perhaps the<br>
program should retry the read of the file until it works, like this:<br>
<br>
# start using pygame<br>
pygame.init()<br>
<br>
# turn off cursor<br>
pygame.mouse.set_visible(False)<br>
<br>
# create the pygame window and return a Surface object for<br>
# drawing in that window.<br>
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)<br>
<br>
# grab a frame from camera to file<br>
pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc !<br>
filesink location=/tmp/pippypic.jpg')<br>
pipeline.set_state(gst.STATE_PLAYING)<br>
<br>
while True:<br>
    try:<br>
        # load in the grabbed camera frame<br>
<div class="im">        image = pygame.image.load('/tmp/pippypic.jpg')<br>
</div>        break<br>
    except pygame.error:<br>
        # pause to allow more time for the camera frame to be grabbed<br>
        time.sleep(1)<br>
<br>
...<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</div></div></blockquote></div><br></div>