I need to read all videos in a folder and then compare each video with its original type and after calculating the PSNR, save the PSNR text file. for this aim I used the following code:
subprocess.call(['ffmpeg.exe', '-i', {i}, '-i', {o}, '-lavfi', 'psnr=stats_file=''{n}', '-f', 'null', '-'])
I enter the name of input and output file as variables {i}
and {o}
that each time can be a different video file, I also need to save the related PSNR text file, for this aim I define n
(n=psnrmkv.txt'). but it could not produce psnrmkv.txt. do you have any suggestions? what is the problem?
I wrote the following code for read all mp4 file in a folder and calculating the PSNR:
import subprocess
import os
import numpy as np
import scipy.io as sio
import cv2
os.chdir("E:/mpeg_file/") #change directory to downloads folder
suffix =".mp4" #variable holdinng the .mp4 tag
fnames = os.listdir('.') #looks at all files
# files = [x for x in os.listdir() if x.endswith(".mp4")]
files =[] #an empty array that will hold the names of our mp3 files
i=0
for fname in fnames:
if fname.endswith(suffix):
pname = os.path.abspath(fname)
n="psnr"
n=n+str(i)+".txt"
subprocess.call(['ffmpeg.exe', '-i', pname, '-i', pname, '-lavfi', f'psnr=stats_file={n}', '-f', 'null', '-'])
i=i+1
files.append(pname) #add the mp3 files to our array
print (files)
but it does not produce any psnr text file!! could you please tell me what is the problem? it runs completely, but I do not have any outputs. I also need to add the location of saving the psnr text file in subprocess
.