Python Forum
OpenCV - extract 1st frame out of a video file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OpenCV - extract 1st frame out of a video file
#1
Hi All,

I'm trying to extract the first frame of a sample video file with OpenCV however it doesnt work:

import cv2

f = cv2.VideoCapture('1.mkv')

rval, frame = f.read()
cv2.imwrite('first_frame.jpg', frame)
f.release()
Could you help me out, what do I do wrong, the jpeg file is empty after running the code

Thanks

Zoli
Reply


Messages In This Thread
OpenCV - extract 1st frame out of a video file - by kerzol81 - Nov-10-2018, 03:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  extract and plot data from a txt file usercat123 2 1,238 Apr-20-2022, 06:50 PM
Last Post: usercat123
  save video frames into pandas data-frame tofi 0 2,679 Oct-18-2018, 07:02 PM
Last Post: tofi
  Upload csv file as numbers (floating?) and extract element, row, and column bentaz 7 4,526 Mar-19-2018, 05:34 PM
Last Post: bentaz
  Reading json file as pandas data frame? Alberto 1 8,383 Feb-05-2018, 12:43 AM
Last Post: snippsat
  Extract data between two dates from a .csv file using Python 2.7 sujai_banerji 1 10,399 Nov-15-2017, 09:48 PM
Last Post: snippsat
  Identifying items in a csv file that also appear in a Text extract Jaynorth 17 17,560 Sep-21-2016, 10:51 PM
Last Post: Jaynorth

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020