I would like to dynamically generate infinite video stream from video clips, so that choose next one on the fly.
I was inspired by ffplayout project which runs
ffplay and make it read from stdin,
and then runs
ffmpeg and stdout is redirected to
ffplay. It works nice when streaming to rtmp server (probably because there is some buffering applied on the way), but when using
ffplay you can notice some glitches on video transition.
Video is converted to mpegts for transport through pipe.
I was testing on this video which is made for looping.
In order to eliminate ffmpeg startup, file read delay, I did what follows:
# saved raw output ffmpeg -i tunnel.mp4 -f mpegts tunnel.mpegts # made fifo.ts mkfifo fifo # run ffplay to read from stdin ffplay -an -f mpegts -i pipe:0 <fifo.ts # write video to fifo cat tunnel.mpegts tunnel.mpegts tunnel.mpegts tunnel.mpegts >> fifo.ts
still glitches on transition. I even tried to read video to memory and write to fifo to eliminate disk io
def main(): with open('tunnel.mpegts', 'rb') as fd: tunnel = fd.read() with open('fifo.ts', 'wb') as fd: for _ in range(5): fd.write(tunnel)
Any idea how to make it work? Maybe another ffmpeg on the way that would buffer/delay/join/transcode?