I have a little Python script. What it should do is to take the last file out a folder and convert it to another with the same filename.
The Script:
from moviepy.editor import *
import glob
import os.path
#Variabels
folder_path = r'/pathtofolder/Recordings'
file_type = r'/*h264'
file_type_conv = r'/*mp4'
files = glob.glob(folder_path + file_type)
files_conv = glob.glob(folder_path + file_type_conv)
clip_latest = max(files, key=os.path.getctime)
clip_conv = max(files_conv, key=os.path.getctime)
#print(clip_latest)
#print(clip_conv)
ffmpeg -i clip_latest -r 25 clip_conv
This gives me back:
SyntaxError: invalid syntax
When I 'print" the code it gives me the path I need. But I cannot get the path into the ffmpeg code. What anm I doing wrong?
Thanks in advance!
I tried to place the variables in "" and in {}. When I give a full path it works good.
UPDATE:
Got it working! Thaqnks to the advise of@Daviid I've used python-ffmpeg library. Here's the code:
import glob
import os.path
import subprocess
#Variabels
folder_path = r'/home/wessie/Halloween/Recordings'
file_type = r'/*h264'
file_type_conv = r'/*mp4'
files = glob.glob(folder_path + file_type)
files_conv = glob.glob(folder_path + file_type_conv)
clip_latest = max(files, key=os.path.getctime)
clip_conv = clip_latest + '.mp4'
print(clip_latest)
print(clip_conv)
subprocess.run(['ffmpeg', '-i', clip_latest, clip_conv])
Thanks!