123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #!/usr/bin/env python3
- import openshot
- import sys
- fname=None
- if len(sys.argv)<=1:
-
- print('not enough parameters')
- fname="full.mp4"
- # sys.exit()
- if fname is None:
- fname=sys.argv[1]
- head= openshot.FFmpegReader("/home/jared/logo_audio.mp4")
- head.Open() # Open the reader
- # Create an FFmpegReader
- #r = openshot.FFmpegReader("/var/video/6320757395.mp4")
- r = openshot.FFmpegReader("/var/video/"+fname)
- 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("/var/video/s1/6320757395.mp4")
- w = openshot.FFmpegWriter("/var/video/s1/"+fname)
- #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"] = "ChoozMo"
- w.info.metadata["artist"] = "ChoozMo"
- w.info.metadata["album"] = "ChoozMo"
- w.info.metadata["year"] = "2021"
- w.info.metadata["description"] = "ChoozMo"
- w.info.metadata["comment"] = "ChoozMo"
- w.info.metadata["comment"] = "ChoozMo"
- w.info.metadata["copyright"] = "copyright ChoozMo!"
- # 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)
- txt1 = openshot.QtImageReader("/var/txt/title.png")
- c_txt1 = openshot.Clip(txt1)
- c_txt1.has_audio=openshot.Keyframe(0)
- c_txt1.Layer(7)
- c_txt1.Position(3.5)
- c_txt1.location_x=openshot.Keyframe(0.22)
- #c_txt1.location_y=openshot.Keyframe(0.02)
- c_txt1.location_y=openshot.Keyframe(0.68)
- c_txt1.Start=0
- t.AddClip(c_txt1)
- bg1 = openshot.QtImageReader("/var/txt/bg1.jpg")
- c_bg1 = openshot.Clip(bg1)
- c_bg1.has_audio=openshot.Keyframe(0)
- c_bg1.Layer(6)
- c_bg1.Position(3.5)
- c_bg1.scale_x=openshot.Keyframe(0.65)
- c_bg1.scale_y=openshot.Keyframe(0.65)
- c_bg1.location_x=openshot.Keyframe(-0.18)
- c_bg1.location_y=openshot.Keyframe(-0.08)
- c_bg1.Start=0
- t.AddClip(c_bg1)
- #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!")
|