Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Help recording webcam video to file via OpenCV

edited September 2015 in OpenSesame

Hello,

I am currently trying to implement a background video recording process that would run while a movie was played onscreen. Conceptually, everything is in place and ready, the only problem is when I attempt to save the video being recorded to a file, the file is saved without content. Some investigating shows that the main issue behind this error is codecs, or lack there of.

I was able to record the video to file successfully in PsychoPy, and upon investigation saw that there is a DLL folder holding all the binaries necessary for ffmpeg, is there an equivalent location for the compiled version of OpenSesame?

If that is the case with ffmpeg, what I would like to do is utilize ffmpeg binaries to save the video file to mpeg, but I can't determine how to do this without running OpenSesame from source, which at this point in development is not feasible.

Here is my (simplified) code for testing purposes:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
fourcc = cv2.cv.CV_FOURCC(*'MJPG')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
i=0

while(cap.isOpened()):
    ret, frame = cap.read()
    i += 1
    if ret==True:
        # write the frame
        out.write(frame)
        # show frame
        cv2.imshow('frame',frame)
        # escape after a few seconds of recording
        if i > 200:
            break
    else:
        break

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

As a side note, when I run this script, it doesn't show the image being stored to the frame variable. I assume this is related to the codec issue, but is to some degree irrelevant as we don't want to show the frame during the experiment.

Comments

  • edited 6:06PM

    I was able to record the video to file successfully in PsychoPy, and upon investigation saw that there is a DLL folder holding all the binaries necessary for ffmpeg, is there an equivalent location for the compiled version of OpenSesame?

    Not really, but I imagine that just copying the .dll files from PsychoPy to the main OpenSesame folder (i.e. not a subfolder) should do the trick. Does this work for you?

    As a side note, when I run this script, it doesn't show the image being stored to the frame variable. I assume this is related to the codec issue, but is to some degree irrelevant as we don't want to show the frame during the experiment.

    The cv2.imshow() function shows the frame on the cv2 window, which you have to initialize separately. I guess it fails silently if you haven't done this. In any case, it will not show the image on the OpenSesame window, because cv2 knows nothing about that.

    Cheers!
    Sebastiaan

  • Hi,

    Maybe the solution here https://forum.cogsci.nl/index.php?p=/discussion/comment/16103 might come in handy. I could use it to successfully record webcam feed while displaying stimuli.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games