beginner.py 683 B

12345678910111213141516171819202122232425262728
  1. import openshot
  2. def video_writer_init(path):
  3. w = openshot.FFmpegWriter(path)
  4. w.SetAudioOptions(True, "aac", 44100, 2, openshot.LAYOUT_STEREO, 3000000)
  5. w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720,
  6. openshot.Fraction(1, 1), False, False, 3000000)
  7. return w
  8. t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)
  9. t.Open()
  10. text_title = openshot.QtImageReader("./tt.jpg")
  11. clip = openshot.Clip(text_title)
  12. t.AddClip(clip)
  13. w = video_writer_init("./test.mp4")
  14. w.Open()
  15. frames = t.info.fps.ToInt ()*3
  16. for n in range(frames):
  17. f=t.GetFrame(n)
  18. w.WriteFrame(f)
  19. t.Close()
  20. w.Close()