Endless stream from a video file (in a loop)

Is there a way to create an endless stream h264

from a video file (e.g. mp4, avi, ...). I would like to use ffmpeg to transcode an avi file to h264

, but there is no option loop

for output.

+3


source to share


2 answers


No, you cannot. There is no such command in ffmpeg for recording video. You can -loop

only use for images. If you are interested, you can use the concat demuxer. Create a playlist file eg. playlist.txt

Inside playlist.txt add video location

file '/path/to/video/video.mp4'
file '/path/to/video/video.mp4'
file '/path/to/video/video.mp4'
file '/path/to/video/video.mp4'
file '/path/to/video/video.mp4'

      



Execute ffmpeg

ffmpeg -f concat -i playlist.txt -c copy output.mp4

      

See here

+3


source


You should be able to use a flag -stream_loop -1

before entering ( -i

):

ffmpeg -threads 2 -re -fflags +genpts -stream_loop -1 -i ./test.mp4 -c copy ./test.m3u8

      



-fflags +genpts

will reconstruct the pts timestamps so that it smoothes smoothly, otherwise the time sequence will be wrong as it will loop.

+8


source







All Articles