Search code examples
videoffmpegvideo-streamingavconv

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.


Solution

  • 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