Thanks for the reply Markus:smile:
Im still trying to get it to work but so far Ive manged to nearly complete it with following code:
I’ve install ffmpeg for python here [https://github.com/kkroening/ffmpeg-python]
(https://github.com/kkroening/ffmpeg-python)
#!/usr/bin/python
import os
import sys
import shutil
import subprocess
import shlex
import os.path
import pipes
import ffmpeg
inputFile = os.environ.get('Sonarr_EpisodeFile_Path')
newone = (os.path.splitext(inputFile)[0])
newimage = ''.join([newone , '-thumb.jpg '])
outputFile = newimage
in_stream = ffmpeg.input('inputFile')
video_stream = in_stream # automatically equivalent to in_stream.video()
video_stream = ffmpeg.filter_(video_stream, '-ss', '00:15:00', '-i',)
video_stream = ffmpeg.filter_(video_stream, '-vframes', '1', '-q:v', '2')
out_stream = ffmpeg.output(out_stream, 'outputFile')
ffmpeg.run(out_stream)
So this get the full path of the
inputFile from Sonarr_EpisodeFile_Path,
which looks like:
D:\Rebuild\Done\Series Source\Looming Tower, The\Season 1\The.Looming.Tower.S01E01.WEBDL-720p.Proper.h264.EAC3-NTb.mkv
Then it removes the extension making newone like:
D:\Rebuild\Done\Series Source\Looming Tower, The\Season 1\The.Looming.Tower.S01E01.WEBDL-720p.Proper.h264.EAC3-NTb
Then I want to add “-thumbs.jpg” to the end of that filepath and endup with outputFile which is:
D:\Rebuild\Done\Series Source\Looming Tower, The\Season 1\The.Looming.Tower.S01E01.WEBDL-720p.Proper.h264.EAC3-NTb-thumbs.jpg
Then ffmegp is fired with the inputfile & outputFile
It all appears to work until outputting the file, where it failes. in sonarr logs is says:
|Component|Message|Time|
|---|---|---|
|python.exe|NameError: name 'out_stream' is not defined|14:49|
|python.exe|out_stream = ffmpeg.output(out_stream, 'outputFile')|14:49|
|python.exe|File "D:\Scripts\Testing\ffmpeg2.py", line 42, in <module>|14:49|
|python.exe|Traceback (most recent call last):|14:49|
the line: |python.exe|File “D:\Scripts\Testing\ffmpeg2.py”, line 42, in related to following line:
out_stream = ffmpeg.output(out_stream, ‘outputFile’)
implying its outputfile problem??
Any ideas on how to fix would be appreciated, thanks in advance.