Looping over an input with ffmpeg

This example shows a simple way to loop over an input file using the lavfi filter and also the -re option which is essential as it only encodes at realtime of the file instead of as fast as possible. This is a useful technique if you want to simulate a live stream for testing.


ffmpeg -f lavfi -re -i movie=golf_680_640x360.mp4:loop=0 -acodec libfaac -b:a 64k -pix_fmt yuv420p -vcodec libx264 -x264opts level=41 -r 25 -profile:v baseline -b:v 1500k -maxrate 2000k -force_key_frames 50 -s 640×360 -map 0 -flags -global_header -f segment -segment_list index_1500.m3u8 -segment_time 10 -segment_format mpeg_ts -segment_list_type m3u8 segment%05d.ts