-
Notifications
You must be signed in to change notification settings - Fork 417
Description
Sorry that I ask my question here, but I hoped that I get some thought from you.
I have write a playout solution, based on python and ffmpeg. It works, but not 100% clean, that is way I would like to rewrite it based on PyAV.
I have play a bit around with your module, but some things I can't figure out:
1) When I want to concat multiple clips, would you recommend to buffer them? So when the script change from one clip to the next, that there is no delay.
2) The most easy way to concat can be done like this:
import os
import av
dir_path = os.path.dirname(os.path.realpath(__file__))
output = av.open('concat.mkv', 'w')
out_stream_v = output.add_stream('libx264', 50)
out_stream_a = output.add_stream('aac')
out_stream_v.width = 512
out_stream_v.height = 288
out_stream_v.options = {'preset': 'faster', 'crf': '24'}
out_stream_a.options = {}
list = [
'waves.mp4',
'waves.mp4'
]
for clip in list:
input_ = av.open(os.path.join(dir_path, 'test_clips', clip))
in_stream_v = input_.streams.video[0]
in_stream_a = input_.streams.audio[0]
for packet in input_.demux(in_stream_v, in_stream_a):
if packet.dts is None:
continue
type = packet.stream.type
for frame in packet.decode():
if type == 'video':
packet = out_stream_v.encode(frame)
elif type == 'audio':
packet = out_stream_a.encode(frame)
output.mux(packet)
output.close()But now I have the problem, that my dts and pts are not monotonically. So how can I generate a clean increasing dts and pts packet stream? And also: What would be, when the values are increasing over multiple day, or weeks, do I have to rest the values one time?
3) How can I encode in real time? I saw in this tutorial that he works with a timer and an older player example from you uses also a clock. Could you give me here a hint, for my use case?
As I say I would appreciate your thought on that very much!
Have a nice day!