Nov-04-2019, 04:30 PM
Hi,
I just start to learn pyhton. I'm using 3.7.2 on windows. I have text files which contain full paths of video files, like:
video.lst:
I want to find out how they are encoded with ffprobe. With the full given path of the video file everything works fine:
r"c:\videos\video1.mp4
"
:Invalid argument.
When I change it to
Cheers
I just start to learn pyhton. I'm using 3.7.2 on windows. I have text files which contain full paths of video files, like:
video.lst:
Quote:c:\videos\video1.mp4
c:\videos\video2.mp4
c:\videos\video3.mp4
...
I want to find out how they are encoded with ffprobe. With the full given path of the video file everything works fine:
import os import subprocess filePath = r"c:\videos\video1.mp4" ffprobeResult = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=codec_name', '-of', 'default=noprint_wrappers=1:nokey=1', filePath], universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(ffprobeResult.stdout)What doesn't work:
import os import subprocess with open(r"c:\video\video.lst","r") as f: filePath = 'r"' + str(f.readline()) + '"' ffprobeResult = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=codec_name', '-of', 'default=noprint_wrappers=1:nokey=1', filePath], universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(ffprobeResult.stdout)It returns:
r"c:\videos\video1.mp4
"
:Invalid argument.
When I change it to
filePath = 'r"' + str(f.readline(18)) + '"'it works again (18: the bytes of the path). readline seems to add a new line. Does anyone know how to change this or has something else up one's sleeve?
Cheers