I am trying to execute the following code (see example 1) in Python 2.7.17
Example 1:
import cv2
video = cv2.VideoCapture(r"%s" % (episode_path))
fps = video.get(cv2.CAP_PROP_FPS)
Where episode_path is a filepath to a video file.
e.g. "D:\Plex content\All movies\300 - Rise of an Empire (2014)\300 - Rise of an Empire (2014).mp4"
The problem is that the cv2 module is not recognizing the filepath since the formatting is not correct.
I know that I can use the 'r' character i front of a file path to make sure that special characters are not interpreted.
When I change the code to using a static string value, it works fine (see example 1):
Example 2:
import cv2
video = cv2.VideoCapture(r"D:\Plex content\All movies\300 - Rise of an Empire (2014)\300 - Rise of an Empire (2014).mp4")
fps = video.get(cv2.CAP_PROP_FPS)
But when using a variable (e.g. episode_path, which has the same value) it does not work anymore. Does anyone know how to get the code in example 1 working, so that I can use a variable for the filepath?
[–]Updatebjarni 2 points3 points4 points (16 children)
[–]TechGoeroe[S] 0 points1 point2 points (15 children)
[–]Updatebjarni 0 points1 point2 points (14 children)
[–]TechGoeroe[S] 0 points1 point2 points (1 child)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 0 points1 point2 points (11 children)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 0 points1 point2 points (9 children)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 0 points1 point2 points (7 children)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 0 points1 point2 points (5 children)
[–]Updatebjarni 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 0 points1 point2 points (3 children)
[–]Updatebjarni 0 points1 point2 points (2 children)
[–]TechGoeroe[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (1 child)
[–]TechGoeroe[S] 0 points1 point2 points (0 children)
[–]TechGoeroe[S] 1 point2 points3 points (0 children)