@@ -70,15 +70,15 @@
videoRotation = subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream_tags=rotate", "-of", "default=noprint_wrappers=1:nokey=1", "/"+inputPathPy ])
else:
videoRotation = 0
- videoResolution = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", "/"+inputPathPy ])
- playbackDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", "/"+inputPathPy ])
- videoInfos = ( subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=codec_name,sample_aspect_ratio,display_aspect_ratio,pix_fmt,avg_frame_rate", "-of", "default=noprint_wrappers=1:nokey=1", "/"+inputPathPy ]) ).splitlines()
+ videoResolution = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", inputPathPy ])
+ playbackDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", inputPathPy ])
+ videoInfos = ( subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=codec_name,sample_aspect_ratio,display_aspect_ratio,pix_fmt,avg_frame_rate", "-of", "default=noprint_wrappers=1:nokey=1", inputPathPy ]) ).splitlines()
videoCodec = videoInfos[0]
sampleAspectRatio = videoInfos[1]
displayAspectRatio = videoInfos[2]
pixelFormat = videoInfos[3]
frameRate = videoInfos[4]
- audioInfos = ( subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "a:0", "-show_entries", "stream=codec_name,sample_rate,channel_layout", "-of", "default=noprint_wrappers=1:nokey=1", "/"+inputPathPy ]) ).splitlines()
+ audioInfos = ( subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "a:0", "-show_entries", "stream=codec_name,sample_rate,channel_layout", "-of", "default=noprint_wrappers=1:nokey=1", inputPathPy ]) ).splitlines()
try: #Patch: if there is audio track after all
audioCodec = audioInfos[0]
except:
@@ -130,7 +130,7 @@
pyotherside.send( 'previewImageCreated', )
def getPlaybackDuration ( inputPathPy, targetName ):
- playbackDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", "/"+inputPathPy ])
+ playbackDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", inputPathPy ])
pyotherside.send( 'playbackDurationParsed', playbackDuration, targetName)
@@ -281,7 +281,8 @@
global currentFunctionErrorName
currentFunctionErrorName = "addTimeFunction"
if "blank_clip" in addClipType:
- subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-f", "lavfi", "-i", "color=c="+addColor+":s="+origVideoWidth+"x"+origVideoHeight+":r="+origFrameRate, "-t", addLength, "-f", "lavfi", "-i", "anullsrc=channel_layout="+origAudioLayout+":sample_rate="+origAudioSamplerate, "-t", addLength, "-c:v", origCodecVideo, "-tune", "stillimage", "-pix_fmt", origPixelFormat, "-c:a", origCodecAudio, "/"+tempMediaFolderPath+"new_part."+origContainer ] )
+ #subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-f", "lavfi", "-i", "color=c="+addColor+":s="+origVideoWidth+"x"+origVideoHeight+":r="+origFrameRate, "-t", addLength, "-f", "lavfi", "-i", "anullsrc=channel_layout="+origAudioLayout+":sample_rate="+origAudioSamplerate, "-t", addLength, "-c:v", origCodecVideo, "-tune", "stillimage", "-pix_fmt", origPixelFormat, "-c:a", origCodecAudio, "/"+tempMediaFolderPath+"new_part."+origContainer ] )
+ subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "color=c="+addColor+":s="+origVideoWidth+"x"+origVideoHeight+":r="+origFrameRate, "-t", addLength, "-i", "anullsrc=channel_layout="+origAudioLayout+":sample_rate="+origAudioSamplerate, "-t", addLength, "-c:v", origCodecVideo, "-tune", "stillimage", "-pix_fmt", origPixelFormat, "-c:a", origCodecAudio, "/"+tempMediaFolderPath+"new_part."+origContainer ] )
if "start" in whereInVideo:
first_path = "/"+tempMediaFolderPath+"new_part."+origContainer
second_path = "/"+inputPathPy
@@ -310,7 +311,7 @@
if "freeze_frame" in addClipType:
subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-ss", atTimestamp, "-frames:v", "1", "/"+tempMediaFolderPath+"freeze_frame.png" ], shell = False ) # at marker
- subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-loop", "1", "-t", addLength, "-framerate", origFrameRate, "-i", "/"+tempMediaFolderPath+"freeze_frame.png", "-f", "lavfi", "-i", "anullsrc=channel_layout="+origAudioLayout+":sample_rate="+origAudioSamplerate, "-t", addLength, "-c:v", origCodecVideo, "-tune", "stillimage", "-pix_fmt", origPixelFormat, "-c:a", origCodecAudio, "/"+tempMediaFolderPath+"freeze_part."+origContainer ], shell = False )
+ subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-loop", "1", "-t", addLength, "-framerate", origFrameRate, "-i", "/"+tempMediaFolderPath+"freeze_frame.png", "-i", "anullsrc=channel_layout="+origAudioLayout+":sample_rate="+origAudioSamplerate, "-t", addLength, "-c:v", origCodecVideo, "-tune", "stillimage", "-pix_fmt", origPixelFormat, "-c:a", origCodecAudio, "/"+tempMediaFolderPath+"freeze_part."+origContainer ], shell = False )
if "start" in whereInVideo:
first_path = "/"+tempMediaFolderPath+"freeze_part."+origContainer
second_path = "/"+inputPathPy
@@ -547,7 +548,7 @@
for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", effectName+"=5:5:"+someValue1+":5:5:"+someValue2+":enable='between(t,"+fromSec+","+toSec+")'", "-c:a", "copy", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', progress)
elif ("photosensitivity" in effectName) or ("stereo3d" in effectName):
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", effectName+"=5:5:"+someValue1+":5:5:"+someValue2+":enable='between(t,"+fromSec+","+toSec+")'", "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", effectName+"=5:5:"+someValue1+":5:5:"+someValue2+":enable='between(t,"+fromSec+","+toSec+")'", "-c:v", "mpeg4", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', progress)
else:
for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", effectName+"=enable='between(t,"+fromSec+","+toSec+")'", "-c:a", "copy", "/"+outputPathPy ]):
@@ -566,7 +567,7 @@
for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "vidstabdetect=stepsize=32:shakiness=10:accuracy=10:result=/"+tempMediaFolderPath+"transforms.trf", "-f", "null", "-" ]):
pyotherside.send('progressPercentage', (progress / 2) )
step2finished = "false"
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "vidstabtransform=input=/"+tempMediaFolderPath+"transforms.trf:optzoom=2:smoothing=10,unsharp=5:5:0.8:3:3:0.4", "-c:v", "libx264", "-preset", "veryfast", "-tune", "film", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "vidstabtransform=input=/"+tempMediaFolderPath+"transforms.trf:optzoom=2:smoothing=10,unsharp=5:5:0.8:3:3:0.4", "-c:v", "mpeg4", "-preset", "veryfast", "-tune", "film", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', (progress / 2 + 50) )
step2finished = "true"
for i in os.listdir( "/"+tempMediaFolderPath ) :
@@ -596,10 +597,10 @@
currentFunctionErrorName = "imageFrei0rFunction"
if "true" in useParams:
#subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "frei0r=filter_name="+applyEffect+":filter_params="+applyParams, "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ], shell = False )
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "frei0r=filter_name="+applyEffect+":"+applyParams, "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "frei0r=filter_name="+applyEffect+":"+applyParams, "-c:v", "mpeg4", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', progress)
else: # "false"
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "frei0r=filter_name="+applyEffect, "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-i", "/"+inputPathPy, "-filter:v", "frei0r=filter_name="+applyEffect, "-c:v", "mpeg4", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', progress)
if "true" in success :
pyotherside.send('loadTempMedia', outputPathPy )
@@ -634,16 +635,16 @@
for i in range (0, len(allSelectedPathsList)) :
if "still_images" in panZoom:
if i == 0:
- inputFilesList.extend([ "-loop", "1", "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) ), "-i", "/" + str(allSelectedPathsList[i]) ])
+ inputFilesList.extend([ "-loop", "1", "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) ), "-i", str(allSelectedPathsList[i]) ])
else: # Patch: length + fade before and fade after are needed, otherwise too short
- inputFilesList.extend([ "-loop", "1", "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) + float(allSelectedTransitionDurationsList[i-1]) ), "-i", "/" + str(allSelectedPathsList[i]) ])
+ inputFilesList.extend([ "-loop", "1", "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) + float(allSelectedTransitionDurationsList[i-1]) ), "-i", str(allSelectedPathsList[i]) ])
applyZoomPan = ""
elif "pan_and_zoom" in panZoom: # Patch: pan/zoom does not work with "loop 1" input, would loop endlessly
if i == 0:
- inputFilesList.extend([ "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) ), "-i", "/" + str(allSelectedPathsList[i]) ])
+ inputFilesList.extend([ "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) ), "-i", str(allSelectedPathsList[i]) ])
panZoomDuration = str( (float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i])) * 25 ) # fps * sec
else: # Patch: length + fade before and fade after are needed, otherwise too short
- inputFilesList.extend([ "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) + float(allSelectedTransitionDurationsList[i-1]) ), "-i", "/" + str(allSelectedPathsList[i]) ])
+ inputFilesList.extend([ "-t", str( float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) + float(allSelectedTransitionDurationsList[i-1]) ), "-i", str(allSelectedPathsList[i]) ])
panZoomDuration = str( (float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i]) + float(allSelectedTransitionDurationsList[i-1])) * 25 ) # fps * sec
randomPanZoom = random.randint(-4,4)
if randomPanZoom is lastRandom :
@@ -670,6 +671,23 @@
applyZoomPan = ",zoompan=z='if(eq(on,1),1.5,zoom-0.0015)':d="+panZoomDuration+":y='ih-ih/zoom':s="+targetWidth+"x"+targetHeight
lastRandom = randomPanZoom
+
+ # generic fade
+ #-filter_complex \
+ #"[1]fade=d=1:t=in:alpha=1,setpts=PTS-STARTPTS+2/TB[f0]; \
+ # [2]fade=d=1:t=in:alpha=1,setpts=PTS-STARTPTS+4/TB[f1]; \
+ # [3]fade=d=1:t=in:alpha=1,setpts=PTS-STARTPTS+6/TB[f2]; \
+ # [4]fade=d=1:t=in:alpha=1,setpts=PTS-STARTPTS+8/TB[f3]; \
+ # [0][f0]overlay[bg1];[bg1][f1]overlay[bg2];[bg2][f2]overlay[bg3]; \
+ # [bg3][f3]overlay,format=yuv420p[v]" -map "[v]"
+
+ # generic xFade -filter_complex \
+ #"[0][1]xfade=transition=slideleft:duration=0.5:offset=2.5[f0]; \
+ #[f0][2]xfade=transition=slideleft:duration=0.5:offset=5[f1]; \
+ #[f1][3]xfade=transition=slideleft:duration=0.5:offset=7.5[f2]; \
+ #[f2][4]xfade=transition=slideleft:duration=0.5:offset=10[f3]" \
+ #-map "[f3]"
+ #
currentTransition = allSelectedTransitionsList[i]
if "none" in currentTransition:
if i == 0:
@@ -697,15 +715,24 @@
lastOutputVX = str("[vx"+str(i+1)+"]")
if i == len(allSelectedPathsList)-1 :
xFadeInfos = xFadeInfos[:-1] # remove last simicolon since it is not needed
- #pyotherside.send('debugPythonLogs', xFadeInfos)
+
+ #pyotherside.send('xFadeInfos', xFadeInfos)
complexFilter += ( "["+str(i)+":v]" + "scale="+targetWidth+":"+targetHeight+":force_original_aspect_ratio=decrease,pad="+targetWidth+":"+targetHeight+":(ow-iw)/2:(oh-ih)/2,setsar=1"+applyZoomPan+",settb=AVTB[v"+str(i)+"];" )
durationCounter += float(allSelectedDurationsList[i]) + float(allSelectedTransitionDurationsList[i])
# add info on how to chain these videos one after another and add a zero audio input for whole length
complexFilter += xFadeInfos
- inputFilesList.extend ([ "-f", "lavfi", "-t", str(durationCounter), "-i", "anullsrc=channel_layout=stereo:sample_rate=48000" ])
+ #inputFilesList.extend ([ "-f", "lavfi", "-t", str(durationCounter), "-i", "anullsrc=channel_layout=stereo:sample_rate=48000" ])
+ # the last file needs to be added again because of some bug in ffmpeg
+ inputFilesList.extend([ "-i", str(allSelectedPathsList[len(allSelectedPathsList)-1]) ])
+ inputFilesList.extend ([ "-t", str(durationCounter) ])
+ #inputFilesList.extend ([ "-i", "anullsrc=channel_layout=stereo:sample_rate=48000" ])
+
+ #pyotherside.send('complexfilter', complexFilter)
+ #pyotherside.send('fileList', inputFilesList)
+
#subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y", "-framerate", "25" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-map", str(len(allSelectedPathsList))+":a", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ])
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-framerate", "25" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-map", str(len(allSelectedPathsList))+":a", "-c:v", "libx264", "-preset", "veryfast", "-r", "25", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y", "-framerate", "25" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-c:v", "mjpeg", "-preset", "veryfast", "-r", "25", "-pix_fmt", "yuv420p", "-c:a", "aac", outputPathPy ]):
pyotherside.send('progressPercentage', progress)
if "true" in success :
pyotherside.send('newClipCreated', outputPathPy, newFileName )
@@ -722,7 +749,8 @@
totalDuration = max( float(lengthClip1), float(lengthClip2) )
inputFilesList = []
inputFilesList.clear()
- inputFilesList.extend([ "-i", "/"+inputPathPy, "-i", "/"+pathSecondVideo, "-f", "lavfi", "-t", str(totalDuration), "-i", "anullsrc=channel_layout=stereo:sample_rate=48000" ])
+ inputFilesList.extend([ "-i", "/"+inputPathPy, "-i", "/"+pathSecondVideo, "-t", str(totalDuration), "-i", "anullsrc=channel_layout=stereo:sample_rate=48000" ])
+ #inputFilesList.extend([ "-i", "/"+inputPathPy, "-i", "/"+pathSecondVideo, "-t", str(totalDuration) ])
if "first" in useAudioFrom:
audioMix = ";[0:a][2:a]amix=inputs=2[outa]" #amerge
@@ -747,7 +775,7 @@
stackOrder = "[orig][new]hstack"
#subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", "[0]scale="+scaleBy+",setsar=1:1[orig];[1]scale="+scaleBy+",setsar=1:1[new];"+stackOrder+",format=yuv420p[outv]"+audioMix, "-map", "[outv]", "-map", "[outa]", "-c:v", "libx264", "-c:a", "aac", "/"+outputPathPy ], shell = False)
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", "[0]scale="+scaleBy+",setsar=1:1[orig];[1]scale="+scaleBy+",setsar=1:1[new];"+stackOrder+",format=yuv420p[outv]"+audioMix, "-map", "[outv]", "-map", "[outa]", "-c:v", "libx264", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", "[0]scale="+scaleBy+",setsar=1:1[orig];[1]scale="+scaleBy+",setsar=1:1[new];"+stackOrder+",format=yuv420p[outv]"+audioMix, "-map", "[outv]", "-map", "[outa]", "-c:v", "mpeg4", "-c:a", "aac", "/"+outputPathPy ]):
pyotherside.send('progressPercentage', progress)
if "true" in success :
pyotherside.send('loadTempMedia', outputPathPy )
@@ -771,8 +799,8 @@
offsetXfadeStart = 0
for i in range (0, len(allSelectedPathsList)) :
- currentFileDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", "/"+str(allSelectedPathsList[i]) ])
- inputFilesList.extend([ "-i", "/" + str(allSelectedPathsList[i]) ])
+ currentFileDuration = subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0:s=x", str(allSelectedPathsList[i]) ])
+ inputFilesList.extend([ "-i", str(allSelectedPathsList[i]) ])
currentTransition = allSelectedTransitionsList[i]
if "none" in currentTransition:
if i == 0:
@@ -814,7 +842,7 @@
# add info on how to chain these videos one after another
complexFilter += xFadeInfos
#subprocess.run([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-map", lastOutputAX, "-threads", "0", "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ])
- for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-map", lastOutputAX, "-threads", "0", "-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", "/"+outputPathPy ]):
+ for progress in run_ffmpeg_command([ ffmpeg_staticPath, "-hide_banner", "-y" ] + inputFilesList + [ "-filter_complex", str(complexFilter), "-map", lastOutputVX, "-map", lastOutputAX, "-threads", "0", "-c:v", "mpeg4", "-preset", "veryfast", "-pix_fmt", "yuv420p", "-c:a", "aac", outputPathPy ]):
pyotherside.send('progressPercentage', progress)
if "true" in success :
pyotherside.send('newClipCreated', outputPathPy, newFileName )
@@ -1135,12 +1163,18 @@
global success
total_dur = None
cmd_with_progress = [cmd[0]] + ["-progress", "-", "-nostats"] + cmd[1:]
+
+ #pyotherside.send('cmd_wth:', cmd_with_progress)
+
stderr = []
stderr.clear()
|