<p>You should be able to achieve this by prepending the source with stream_loop parameter and -1 value specifying indefinite looping.</p>

<p>Replace</p>

<pre><code>-i "$SOURCE" -deinterlace \
</code></pre>

<p>with</p>

<pre><code>-stream_loop -1 -i "$SOURCE" -deinterlace \
</code></pre>

<p>See <a href="https://ffmpeg.org/ffmpeg.html#Main-options" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg.html#Main-options</a></p>

CC BY-SA 3.0
2018-01-12T16:07:12.707Z
2018-01-12T16:07:12.707Z
tbucher
<p>its my first post on this community.</p>

<p>Im from brazil, so im sorry for bad english.</p>

<p>I am using FFMPEG on Ubuntu VPS for streaming 24/7 mp4 video on youtube.</p>

<p>I am using this code:</p>

<pre>
VBR="2500k"                                    
FPS="30"                                    
QUAL="veryfast"                              
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"

SOURCE="/stream/video.mp4"           
KEY="my_Secret_key"                               

ffmpeg \
    -i "$SOURCE" -deinterlace \
    -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
    -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
    -f flv "$YOUTUBE_URL/$KEY"
</pre>

<p>With this code, i have sucesfully put my stream online, but i need that the code loop and repeat the mp4 file, because i dont want to make a 24h mp4 file.</p>

<p>How can i make that this mp4 file (SOURCE="/stream/video.mp4") repeat itself infinitely?</p>

<p>I dont have imagens and notthing, i only put a mp4 file on stream!</p>

<p>Ideas?</p>

<ffmpeg>
FFMPEG - Youtube MP4 video stream loop?
Gabriel Weiss
# FFMPEG - Youtube MP4 video stream loop?

(Asked by: username_0 on 2017-12-30)

its my first post on this community.
Im from brazil, so im sorry for bad english.
I am using FFMPEG on Ubuntu VPS for streaming 24/7 mp4 video on youtube.
I am using this code:

VBR="2500k"                                    
FPS="30"                                    
QUAL="veryfast"                              
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"

SOURCE="/stream/video.mp4"           
KEY="my_Secret_key"                               

ffmpeg \
    -i "$SOURCE" -deinterlace \
    -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
    -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k \
    -f flv "$YOUTUBE_URL/$KEY"

With this code, i have sucesfully put my stream online, but i need that the code loop and repeat the mp4 file, because i dont want to make a 24h mp4 file.
How can i make that this mp4 file (SOURCE="/stream/video.mp4") repeat itself infinitely?
I dont have imagens and notthing, i only put a mp4 file on stream!
Ideas?

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-01-12. Score: 4

You should be able to achieve this by prepending the source with stream_loop parameter and -1 value specifying indefinite looping.
Replace
-i "$SOURCE" -deinterlace \

with
-stream_loop -1 -i "$SOURCE" -deinterlace \

See https://ffmpeg.org/ffmpeg.html#Main-options


---

