【发布时间】:2019-12-06 16:28:35
【问题描述】:
我必须播放来自特定帧的视频,我可以使用 opencv 来完成,但是如何播放该特定视频的音频 我有我必须开始播放视频的帧,我也想要相应的音频。
cap = cv2.VideoCapture('tcs.mp4')
fps = cap.get(cv2.CAP_PROP_FPS)
count = 0
success = True
while success:
success,frame = cap.read()
count+=1
ts = count/fps
if t == ts:
print("time stamp of current frame:",count/fps)
print("Press Q to quit")
f_count = count
cap.set(cv2.CAP_PROP_POS_FRAMES, f_count)
# Check if camera opened successfully
if (cap.isOpened()== False):
print("Error opening video file")
# Read until video is completed
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
# Display the resulting frame
cv2.imshow('Frame', frame)
# Press Q on keyboard to exit
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# Break the loop
else:
break
# When everything done, release
# the video capture object
cap.release()
# Closes all the frames
cv2.destroyAllWindows()
【问题讨论】:
-
我在 python 中需要帮助,而不是 c 或 cpp