Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Infinite stream from a video file (in a loop)

Is there any way howto create an infinite h264 stream from a video file (eg. mp4, avi, ...). I'd like to use ffmpeg to transcode avi file to h264 but there's no loop option for output.

like image 322
Josef Zamrzla Avatar asked Jun 15 '15 13:06

Josef Zamrzla


People also ask

How to stream a video on loop?

1. On the YouTube website, go to the video you want to put on repeat. 2. Right-click the video and select Loop in the pop-up.


2 Answers

You should be able to use the -stream_loop -1 flag before the input (-i):

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

The -fflags +genpts will regenerate the pts timestamps so it loops smoothly, otherwise the time sequence will be incorrect as it loops.

like image 134
chovy Avatar answered Sep 22 '22 06:09

chovy


No you can't. There is no such command in ffmpeg to loop video. You can use -loop for image only. If you are interested you can use concat demuxer. Create a playlist file e.g. playlist.txt

Inside playlist.txt add the 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'

Run ffmpeg

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

See here

like image 43
budthapa Avatar answered Sep 22 '22 06:09

budthapa