Your Name 4 anni fa
parent
commit
996629216e
1 ha cambiato i file con 153 aggiunte e 0 eliminazioni
  1. 153 0
      tests/openshottest.py

+ 153 - 0
tests/openshottest.py

@@ -0,0 +1,153 @@
+#!/usr/bin/env python3
+import openshot
+
+
+head= openshot.FFmpegReader("/home/jared/logo_audio.mp4")
+head.Open()         # Open the reader
+
+
+# Create an FFmpegReader
+r = openshot.FFmpegReader("/var/video/6320757395.mp4")
+
+r.Open()         # Open the reader
+r.DisplayInfo()  # Display metadata
+
+
+col=openshot.Color()
+col.red=openshot.Keyframe(16)
+col.green=openshot.Keyframe(254)
+col.blue=openshot.Keyframe(5)
+
+
+#ck=openshot.ChromaKey(col, openshot.Keyframe(120))
+ck=openshot.ChromaKey(col, openshot.Keyframe(170))
+
+#ck.Layer(2)
+#ck.End(60)
+
+# Set up Writer
+w = openshot.FFmpegWriter("/tmp/out.mp4")
+
+#w.SetAudioOptions(True, "libmp3lame", r.info.sample_rate, r.info.channels, r.info.channel_layout, 128000)
+#w.SetAudioOptions(True, "libmp3lame", 44100, 1, r.info.channel_layout, 128000)
+#w.SetAudioOptions(True, "aac", 44100, 2, openshot.LAYOUT_STEREO, 128000)
+w.SetAudioOptions(True, "aac", 44100, 2, openshot.LAYOUT_STEREO, 3000000)
+
+
+#w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720,
+#                  openshot.Fraction(1, 1), False, False, 3000000)
+
+w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720,
+                  openshot.Fraction(1, 1), False, False, 3000000)
+
+
+w.info.metadata["title"] = "testtest"
+w.info.metadata["artist"] = "aaa"
+w.info.metadata["album"] = "bbb"
+w.info.metadata["year"] = "2015"
+w.info.metadata["description"] = "ddd"
+w.info.metadata["comment"] = "eee"
+w.info.metadata["comment"] = "comment"
+w.info.metadata["copyright"] = "copyright OpenShot!"
+
+# Open the Writer
+w.Open()
+
+t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)
+t.Open()
+
+
+c0 = openshot.Clip(head)
+c0.Layer(1)
+c0.Position=openshot.Keyframe(0)
+c0.Start=openshot.Keyframe(0)
+
+t.AddClip(c0)
+
+
+
+
+
+#lower = openshot.QtImageReader("/home/jared/tests/libopenshot/examples/back.png")
+#lower = openshot.QtImageReader("/home/jared/Wav2Lip-master/person.png")
+lower = openshot.QtImageReader("/home/jared/bk.jpg")
+
+c1 = openshot.Clip(lower)
+c1.has_audio=openshot.Keyframe(0)
+
+c1.Layer(2)
+
+c1.Position(3.03)
+c1.Start=0
+t.AddClip(c1)
+
+
+subtitle = openshot.FFmpegReader("/home/jared/subtitle.mov")
+subtitle.Open()         # Open the reader
+
+
+
+
+c2 = openshot.Clip(r)
+#c2.has_audio=openshot.Keyframe(0)
+
+
+#c2.channel_filter=openshot.Keyframe(-1)
+#c2.channel_mapping=openshot.Keyframe(-1)
+c2.crop_x=openshot.Keyframe(0.14)
+#c2.crop_y=openshot.Keyframe(1.0)
+#c2.crop_height=openshot.Keyframe(1.0)
+c2.crop_width=openshot.Keyframe(0.69)
+#c2.location_x=openshot.Keyframe(0.18)
+c2.location_x=openshot.Keyframe(0.35)
+
+c2.location_y=openshot.Keyframe(0.05)
+c2.scale_x=openshot.Keyframe(0.55)
+c2.scale_y=openshot.Keyframe(0.55)
+
+c2.Position(3.03)
+c2.AddEffect(ck)
+
+
+c2.Layer(3)
+#c2.Position=openshot.Keyframe(10)
+
+t.AddClip(c2)
+
+
+c5 = openshot.Clip(subtitle)
+c5.Position(3.03)
+
+c5.location_x=openshot.Keyframe(-0.03)
+c5.location_y=openshot.Keyframe(0.1)
+c5.Layer(4)
+t.AddClip(c5)
+
+
+
+#c3 = openshot.Clip(r2)
+#c3.Layer(4)
+#c3.has_video=openshot.Keyframe(0)
+#c3.has_audio=openshot.Keyframe(1)
+#c3.volume=openshot.Keyframe(1)
+
+#t.AddClip(c3)
+
+
+for n in range(800):
+# print(n, end=" ", flush=1)
+ f=t.GetFrame(n)
+ w.WriteFrame(f)
+
+
+# Grab 30 frames from Reader and encode to Writer
+#for frame in range(100):
+#    f = r.GetFrame(frame)
+#    w.WriteFrame(f)
+
+# Close out Reader & Writer
+w.Close()
+r.Close()
+
+print("Completed successfully!")
+