Answers.Body: <p>With ffmpeg 2.8.4, the following command creates output.mp4 that is a repeating copy of input.mp4 until the ffmpeg process is stopped:</p>
  
  <pre><code>ffmpeg -stream_loop -1 -i input.mp4 -c copy output.mp4
  </code></pre>
  
  <p>This command won't terminate on its own, and the output file will grow infinitely.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-23T17:43:24.717Z
Answers.Text: Seems to be the fastest method
Answers.UserDisplayName: josef
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-13T23:28:34.613Z
Answers.Text: Fastest method is an understatement, this method ramps up to multi-hour videos in a matter of seconds.
Answers.UserDisplayName: SleighBoy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-10T10:08:01.723Z
Answers.Text: This is a great convenient method, because there is no need to create a file with repeating lines.
Answers.UserDisplayName: Markus Zeller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-08T11:07:27.943Z
Answers.Text: People need to change the value for -stream_loop parameter from `-1` some positive integer according to theirs requirement. Otherwise, the file grows and the system throws `No space left on device` error.
Answers.UserDisplayName: S.K. Venkat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-11T14:53:24.213Z
Answers.Text: This should be best answer works from first try .
Answers.UserDisplayName: Salem F
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-06T23:21:11.983Z
Answers.Text: If you want to specify a time, add **-t 30** this will generate a looped video with 30 sec
Answers.UserDisplayName: Mouaad Abdelghafour AITALI
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2016-01-13T19:42:41.017Z
Answers.LastActivityDate: 2019-05-21T10:01:39.133Z
Answers.LastEditDate: 2019-05-21T10:01:39.133Z
Answers.UserDisplayName: Thingy
Answers.Body: <p>At least on FFmpeg 2.8.x (but oldie should works too) you can use <code>lavfi</code> as input format and complex filter graph using <code>movie</code> and <code>setpts</code> filters as a argument for <code>-i</code> option.</p>
  
  <p>Next command doing this work for you:</p>
  
  <pre><code>ffmpeg -re -f lavfi -i "movie=filename=input.mp4:loop=0, setpts=N/(FRAME_RATE*TB)" output.mp4
  </code></pre>
  
  <p>Zero <code>loop=</code> arguments means infinity loop. Values greater zero sets repeat counts. <code>setpts</code> filters required for PTS adjusting for second and later repeats, otherwise most output muxers will fails with non-monotonic PTS increasing: loop does not recalc PTS.</p>
  
  <p><strong>Note, that using filters assuming that bypass frames without decoding/encoding is impossible: by design filters deals with decoded frames only.</strong></p>
  
  <p>At the FFmpeg 2.8.2 new input option <code>-stream_loop</code> inroduced. I first look it works more simple and allows copy content without transcoding:</p>
  
  <pre><code>ffmpeg -re -stream_loop -1 -i input.mp4 -c copy -y output.mp4
  </code></pre>
  
  <p>But it does not recalculate PTS and output file is wrong. If you add filter to fix PTS (see <code>setpts</code>) you must remove <code>-c copy</code> too. Only bitstream filters can deals with encoded packets, but there is no any bitstream filters to fix PTS (see: <a href="https://ffmpeg.org/ffmpeg-bitstream-filters.html">https://ffmpeg.org/ffmpeg-bitstream-filters.html</a>)</p>
  
  <p>In any case ffmpeg on second pass fails with error:</p>
  
  <pre><code>input.mp4: Resource temporarily unavailable
  </code></pre>
  
  <p><strong>Known work around for me</strong>: use container for input file without PTS limits (streaming container). One of them, known me, is MPEG-TS. So, you can simple convert your MP4 file to the MPEG-TS:</p>
  
  <pre><code>ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input.ts
  </code></pre>
  
  <p>And use next command to compose infinity file:</p>
  
  <pre><code>ffmpeg -re -stream_loop -1 -i input.ts -c copy -strict -2 -bsf:a aac_adtstoasc -y output.mp4
  </code></pre>
  
  <p>(bitstream filters should be used only if needed, on my samples it is required)</p>
  
  <p>FFmpeg >= 2.8.2 is required in this case.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T08:35:28.413Z
Answers.Text: Running that command gives me error : "[mp4 @ 00000000053fa1a0] Could not find tag for codec rawvideo in stream #0, codec not currently supported in container". If I add -vcodec h264 before the input, that error disappears, but the encoder doesn't exit. Supplying a non-zero loop count produces a lot of errors but does exit. The file is not a valid output.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T08:36:47.677Z
Answers.Text: The documentation for stream_loop says "Loop 0 means no loop, loop -1 means infinite loop."
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T13:43:11.037Z
Answers.Text: Seems incorrect input files. Could you pleas share it? "Loop 0 means no loop, loop -1 means infinite loop." - seems I see old docs :-)
Answers.UserDisplayName: Monah Tuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T14:56:17.887Z
Answers.Text: Mine were valid MP4s but can't share the ones I used .You can generate one using ffmpeg and then use that. Paste the console output if it works.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T16:48:45.340Z
Answers.Text: I forgot: filters assuming transcoding (decode/encode). By design. So you must remove `-c copy`. Answer fixed.
Answers.UserDisplayName: Monah Tuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T17:02:13.640Z
Answers.Text: Nice to know, but that's a significant limitation if you have a large loop to generate.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T17:22:40.500Z
Answers.Text: Add info about stream_loop and WA to fix PTS issue without re-encode. FFmpeg >= 2.8.2 is required.
Answers.UserDisplayName: Monah Tuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-22T12:56:13.747Z
Answers.Text: @MonahTuk I find the loop filter works much  better than stream_loop (which causes a brief pause for any file I tried), with one exception: the moment I add the loop filter the audio disappears?
Answers.UserDisplayName: Mike Versteeg
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-23T00:05:28.147Z
Answers.Text: @MikeVersteeg, you should check files. Time to time different tracks in file has a little bit different length or offset it can affect muxing. Issues in never versions of FFmpeg also can be occured. Also, most working case - use MPEG TS container as input and output.
Answers.UserDisplayName: Monah Tuk
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T08:05:58.620Z
Answers.LastActivityDate: 2015-11-18T17:21:31.460Z
Answers.LastEditDate: 2015-11-18T17:21:31.460Z
Answers.UserDisplayName: Monah Tuk
Answers.Body: <pre><code>@echo off
  
  setlocal ENABLEDELAYEDEXPANSION
  
  REM When not there gives file not found message
  for /f &quot;tokens=*&quot; %%I in ('dir /b &quot;*.mkv&quot;') do (
      if exist &quot;%%~nI.nl.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      )
      if exist &quot;%%~nI.en.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      ) 
  )
  for /f &quot;tokens=*&quot; %%I in ('dir /b &quot;*.mp4&quot;') do (
      if exist &quot;%%~nI.nl.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      )
      if exist &quot;%%~nI.en.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      ) 
  )
  for /f &quot;tokens=*&quot; %%I in ('dir /b &quot;*.webm&quot;') do (
      if exist &quot;%%~nI.nl.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      )
      if exist &quot;%%~nI.en.srt&quot; (
          call :BURN_FILE &quot;%%~nI&quot; &quot;%%I&quot;
      ) 
  )
  
  pause
  
  if not exist ORIGINAL mkdir ORIGINAL
  move &quot;%%I&quot; ORIGINAL &gt;NUL
  move &quot;%%~nI.*&quot; ORIGINAL &gt;NUL
  
  exit /b
  
  :BURN_FILE
  
      set hoppa=%1
      set input=%2
      echo hoppa=!hoppa!
      echo input=!input!
  
      ffprobe.exe -v error -select_streams v:0 -show_entries format=bit_rate -of default=nw=1 !input! &gt; bit_rate2.txt
      ffprobe.exe -v error -show_entries format=duration -of default=nw=1 !input! &gt; duration2.txt
      ffprobe.exe -v error -show_entries format=duration -of default=nw=1 intro.wav &gt; duration_intro.txt
  
      for /F &quot;tokens=*&quot; %%R in (bit_rate2.txt) do (
          for /f &quot;tokens=1,2 delims==&quot; %%a in (&quot;%%R&quot;) do set NAME=%%a &amp; set bit_rate=%%b
      )
      for /F &quot;tokens=*&quot; %%R in (duration2.txt) do (
          for /f &quot;tokens=1,2 delims==&quot; %%a in (&quot;%%R&quot;) do set NAME=%%a &amp; set duration=%%b
      )
      for /F &quot;tokens=*&quot; %%R in (duration_intro.txt) do (
          for /f &quot;tokens=1,2 delims==&quot; %%a in (&quot;%%R&quot;) do set NAME=%%a &amp; set duration_intro=%%b
      )
      for /f &quot;tokens=1 delims=.&quot; %%a in ('echo !duration!') do set /a number=%%a
      for /f &quot;tokens=1 delims=.&quot; %%a in ('echo !duration_intro!') do set /a number_intro=%%a
  
      set /A number_offset = !number! - !number_intro! - 1
      set /A number_offset = !number_offset! * 1000
  
      sof.exe &quot;!hoppa!.nl.srt&quot;
  
      if not exist DUTCH mkdir DUTCH
  
      for %%x in (&quot;!hoppa!.nl.srt.fixed&quot;) do (
          if not %%~zx == 0 (
              if not  exist &quot;DUTCH/!hoppa!.nl.mp4&quot; (
  
              ffmpeg -y -hide_banner -i !input! -i intro.wav -i intro.wav -i pacman2.mp4 -loop 20 -filter_complex &quot;[1]adelay=500|500[s1];[1]adelay=!number_offset!|!number_offset![s2];[0][s1][s2]amix=inputs=3;[0:v]scale=1920:1080[j];[3:v]split[m][a];[a]geq='lum(X,Y)',hue=s=0[al];[m][al]alphamerge[ovr];[ovr]scale=150:-1[sml];[j][sml]overlay=main_w-overlay_w-2:main_h-overlay_h-2[l];[l]subtitles='!hoppa!.nl.srt.fixed':force_style='FontName=Mada Black,FontSize=32,BackColour=&amp;HA0000000,BorderStyle=4'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac -shortest &quot;DUTCH/!hoppa!.nl.PART.mp4&quot;
  
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex &quot;[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed':force_style='FontName=Mada Black,FontSize=32'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac &quot;DUTCH/!hoppa!.nl.PART.mp4&quot;
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex &quot;[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac &quot;DUTCH/!hoppa!.nl.PART.mp4&quot;
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex &quot;[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v libx264 -preset slow -crf 23 -pix_fmt yuv420p -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac &quot;DUTCH/!hoppa!.nl.PART.mp4&quot;
  
              ) else (
                  echo Already exists: &quot;DUTCH/!hoppa!.nl.mp4&quot; 
              )
          ) else (
              echo Subtitle file empty: !hoppa!.nl.srt.fixed
          )
      )
  
      if exist &quot;DUTCH/!hoppa!.nl.PART.mp4&quot; rename &quot;DUTCH\!hoppa!.nl.PART.mp4&quot; &quot;!hoppa!.nl.mp4&quot;
  
  rem if not exist SUBTITLES mkdir SUBTITLES
  rem if exist &quot;!hoppa!.nl.srt.fixed&quot; move &quot;!hoppa!.nl.srt.fixed&quot; SUBTITLES
  rem if exist &quot;!hoppa!.nl.srt&quot; move &quot;!hoppa!.nl.srt&quot; SUBTITLES
  
  rem remark (rem) goto for making second language
  goto :ENDING
  
  sof.exe &quot;!hoppa!.en.srt&quot;
  
  if not exist ENGLISH mkdir ENGLISH
  
  for %%x in (&quot;!hoppa!.en.srt.fixed&quot;) do (
      if not %%~zx == 0 (
          if not  exist &quot;ENGLISH/!hoppa!.en.mp4&quot; (
              ffmpeg -y -hide_banner -i !input! -filter_complex &quot;[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.en.srt.fixed'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac &quot;ENGLISH/!hoppa!.en.PART.mp4&quot;
  rem                 ffmpeg -y -hide_banner -i !input! -filter_complex &quot;[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.en.srt.fixed'[k]&quot; -map &quot;[k]&quot; -map 0:a -strict -2 -c:v libx264 -preset slow -crf 23 -pix_fmt yuv420p -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac &quot;ENGLISH/!hoppa!.en.PART.mp4&quot;
          ) else (
              echo Already exists: &quot;DUTCH/!hoppa!.en.mp4&quot; 
          )
      ) else (
          echo Subtitle file empty: !hoppa!.en.srt.fixed
      )
  )
  
  if exist &quot;ENGLISH/!hoppa!.en.PART.mp4&quot; rename &quot;ENGLISH\!hoppa!.en.PART.mp4&quot; &quot;!hoppa!.en.mp4&quot;
  
  rem     if exist &quot;!hoppa!.en.srt.fixed&quot; move &quot;!hoppa!.en.srt.fixed&quot; SUBTITLES &gt;NUL
  rem     if exist &quot;!hoppa!.en.srt&quot; move &quot;!hoppa!.en.srt&quot; SUBTITLES &gt;NUL
  
  :ENDING
  
  if not exist ORIGINAL mkdir ORIGINAL
  move !input! ORIGINAL &gt;NUL
  move &quot;!hoppa!.*&quot; ORIGINAL &gt;NUL
  
  exit /b
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-29T19:28:12.743Z
Answers.LastActivityDate: 2020-11-30T02:10:39.117Z
Answers.LastEditDate: 2020-11-30T02:10:39.117Z
Answers.UserDisplayName: Gerard Wensink
Answers.Body: <p>If you have MP4 files, these could be losslessly concatenated by first re-wrapping them to MPEG-2 transport streams. With H.264 video and AAC audio, the following can be used:</p>
  <pre><code>ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate.ts
  ffmpeg -i &quot;concat:intermediate.ts|intermediate.ts|intermediate.ts|intermediate.ts&quot; -c copy -bsf:a aac_adtstoasc output.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-02T19:28:35.717Z
Answers.LastActivityDate: 2022-07-08T20:11:50.960Z
Answers.LastEditDate: 2022-07-08T20:11:50.960Z
Answers.UserDisplayName: marbens
Answers.Body: <p>The simple method that avoids problems of which Commands work with which version is the 'trivial solution':</p>
  <pre><code>ffmpeg -i input.mp4 -i input.mp4 -i input.mp4 -i input.mp4 -c copy output.mp4
  </code></pre>
  <p>See also: <a href="https://trac.ffmpeg.org/wiki/Concatenate" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/Concatenate</a> for many examples.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-11T06:36:50.477Z
Answers.Text: This does not do *any* concatenation.  At least one of the concat methods has to be used: protocol, filter or demuxer. In this command, ffmpeg's auto mapping will select one video, one audio and one subtitle stream from among the inputs. Since they're identical,  it's equivalent to the OP's first command.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-11T17:28:19.393Z
Answers.Text: Thanks for testing that Mulvya, as it differs from the behavior described in the Docs: https://ffmpeg.org/ffmpeg.html#Description - If there's similarity in the File names using "-i -i /tmp/test%d.mp4" (et. al) is also possible.
Answers.UserDisplayName: Rob
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2017-03-11T03:52:29.547Z
Answers.LastActivityDate: 2022-07-12T17:20:25.357Z
Answers.LastEditDate: 2022-07-12T17:20:25.357Z
Answers.UserDisplayName: Rob
Answers.Body: <h1><code>-stream_loop</code> option</h1>
  <pre><code>ffmpeg -stream_loop 3 -i input.mp4 -c copy output.mp4
  </code></pre>
  <ul>
  <li>This can avoid re-encoding because it can use <a href="https://ffmpeg.org/ffmpeg.html#Stream-copy" rel="noreferrer">stream copy</a>.</li>
  <li><code>0</code> means no loop, <code>-1</code> means infinite loop.</li>
  <li>This may not work with anything older than FFmpeg 4.0.</li>
  </ul>
  <hr />
  <h1>concat demuxer</h1>
  <p>The <a href="https://ffmpeg.org/ffmpeg-formats.html#concat" rel="noreferrer">concat demuxer</a> allows you to loop an input without needing to re-encode because it can use <a href="https://ffmpeg.org/ffmpeg.html#Stream-copy" rel="noreferrer">stream copy</a>.</p>
  <ol>
  <li><p>Make a text file. Contents of an example text file to repeat 4 times.</p>
  <pre><code> file 'input.mp4'
   file 'input.mp4'
   file 'input.mp4'
   file 'input.mp4'
  </code></pre>
  </li>
  <li><p>Then run <code>ffmpeg</code>:</p>
  <pre><code> ffmpeg -f concat -i list.txt -c copy output.mp4
  </code></pre>
  </li>
  </ol>
  <p>If you want to add additional inputs make sure they all have the same attributes.</p>
  <h3>Automatically make <code>list.txt</code> in Linux/macOS</h3>
  <p>This example is the same as above but you don't have to manually make <code>list.txt</code>:</p>
  <pre><code>for i in {1..4}; do printf &quot;file '%s'\n&quot; input.mp4 &gt;&gt; list.txt; done
  ffmpeg -f concat -i list.txt -c copy output.mp4
  </code></pre>
  <p>With most commonly-used modern shells, you can even avoid the creation of the <code>list.txt</code> file entirely. For example, with bash:</p>
  <pre><code>ffmpeg -f concat -i &lt;(for i in {1..4}; do printf &quot;file '%s'\n&quot; input.mp4; done) -c copy output.mp4
  </code></pre>
  <h3>Also see:</h3>
  <ul>
  <li><a href="https://ffmpeg.org/ffmpeg-formats.html#concat" rel="noreferrer">FFmpeg concat demuxer documentation</a></li>
  <li><a href="https://trac.ffmpeg.org/wiki/Concatenate" rel="noreferrer">FFmpeg Wiki: Concatenate</a></li>
  </ul>
  <hr />
  <h1>loop filter</h1>
  <p>Example using the <a href="https://ffmpeg.org/ffmpeg-filters.html#loop" rel="noreferrer">loop filter</a> to loop 4 times, each loop is 75 frames, each loop skips the first 25 frames of the input:</p>
  <pre><code>ffmpeg -i input.mp4 -filter_complex &quot;loop=loop=3:size=75:start=25&quot; output.mp4
  </code></pre>
  <ul>
  <li>Or use the shorthand: <code>loop=3:75:25</code></li>
  <li>Filtering requires re-encoding.</li>
  <li>This filter <a href="https://ffmpeg.org/ffmpeg-filters.html#movie" rel="noreferrer">places all frames into memory</a>.</li>
  <li>Using <code>loop=3</code> will loop 4 times.</li>
  <li>To loop infinitely use <code>-1</code>.</li>
  <li>You must list the number of frames to loop (shown as 75 in the example above). Max value is 32767.</li>
  <li>Also see <code>ffmpeg -h filter=loop</code>.</li>
  </ul>
  <hr />
  <h1>movie filter</h1>
  <p>The <a href="https://ffmpeg.org/ffmpeg-filters.html#movie" rel="noreferrer">movie</a> and amovie filters have a loop option:</p>
  <pre><code>ffmpeg -f lavfi -i &quot;movie=filename=input.mp4:loop=4,setpts=N/FRAME_RATE/TB&quot; -f lavfi -i &quot;amovie=filename=input.mp4:loop=4,asetpts=N/SR/TB&quot; output.mp4
  </code></pre>
  <ul>
  <li>Filtering requires re-encoding.</li>
  <li><code>1</code> means no loop, <code>0</code> means infinite loop.</li>
  </ul>
  <hr />
  <h1><code>-loop</code> option</h1>
  <p>The <code>-loop</code> option is specific to the <a href="https://ffmpeg.org/ffmpeg-formats.html#image2-1" rel="noreferrer">image file demuxer</a> and <a href="https://ffmpeg.org/ffmpeg-formats.html#gif-2" rel="noreferrer">gif muxer</a>, so it can't be used for typical video files. But it can be used to infinitely loop a single image or a series of images.</p>
  <h3>single image</h3>
  <p>This example will loop a single image over and over but the <code>-t 30</code> will limit the output duration to 30 seconds:</p>
  <pre><code>ffmpeg -loop 1 -i input.png -t 30 -vf format=yuv420p output.mp4
  </code></pre>
  <p><code>-vf format=yuv420p</code> is for compatibility reasons.</p>
  <h3>series of images</h3>
  <pre><code>ffmpeg -loop 1 -i %03d.jpg -t 30 -vf format=yuv420p output.mp4
  </code></pre>
  <h3>GIF output</h3>
  <p>Or to loop a GIF:</p>
  <pre><code>ffmpeg -i input -loop 3 output.gif
  </code></pre>
  <p>For GIF output also see <a href="https://superuser.com/a/556031/">How do I convert a video to GIF using ffmpeg, with reasonable quality?</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-28T19:08:12.627Z
Answers.Text: Does this work fine with mp4 files?
Answers.UserDisplayName: Thomas King
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-09T18:46:50.250Z
Answers.Text: I get this error `> <(for i in {1..4}; do printf "file '%s'\n" input.mp4; done)
  -bash: /dev/fd/63: Permission denied`
Answers.UserDisplayName: JZ11
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-18T15:57:46.893Z
Answers.Text: @jamesfzhang - I think that's because you need an absolute path to the file (as explained here: https://trac.ffmpeg.org/wiki/Concatenate). To fulfill that, you could write: 
  ffmpeg -safe 0 -f concat -i <(for i in {1..4}; do printf "file '$PWD'/'%s'\n" input.mp4; done) -c copy output.mp4
Answers.UserDisplayName: Gnaural
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-15T07:28:19.677Z
Answers.Text: As for me this works to repeat **full time** video without skipping fames for 4 times `ffmpeg -i video.mp4 -filter_complex "loop=4:32767" output.mp4`
Answers.UserDisplayName: Vlad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-31T22:38:30.337Z
Answers.Text: This issue is 4 years old and noone noticed that the link to the second issue in the `-stream_loop` section is pointing to the same ticket as the first one...
Answers.UserDisplayName: Leonid Usov
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-31T23:42:53.943Z
Answers.Text: When working on images, is there any difference between `-i %03d.png -t 30` and `-t 30 -i %03d.png`? I know that when working on video, you usually want `-t` (and `-ss`) before the input to save on decode time, but does this matter for images? I've recently run some commands with `-t` before the input and it worked fine.
Answers.UserDisplayName: user3643
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-01T18:54:31.070Z
Answers.Text: @DigiVisionMedia Shouldn't make a difference.
Answers.UserDisplayName: llogan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-17T00:43:52.023Z
Answers.Text: Does the looped parts occupy extra size on output video? For example if the original video size is 1MB loop=loop=3 equals 3MB?
Answers.UserDisplayName: Ricardo Bohner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-31T06:49:08.750Z
Answers.Text: Thanks! Only place where I got clarification for difference between `-stream_loop` and `-loop`. I was wondering why the ffmpeg manpage doesn't show the `-loop` option. Now I understand it's because that doesn't give the options for filters or muxers.
Answers.UserDisplayName: jamadagni
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2014-10-28T06:15:51.107Z
Answers.LastActivityDate: 2022-07-14T21:15:31.527Z
Answers.LastEditDate: 2022-07-14T21:15:31.527Z
Answers.UserDisplayName: llogan
Body: <p>I just want to loop a mp4 video with ffmpeg and keep the current settings and codec.</p>
  
  <p>For example if input.mp4 is 0:10 long, and I would want to loop it 4 times so output.mp4 is 0:40 long, how could I change the following command line to do that?</p>
  
  <pre><code>ffmpeg -i input.mp4 -c copy output.mp4
  </code></pre>
  
  <p>I tried...</p>
  
  <pre><code>ffmpeg -loop 4 -i input.mp4 -c copy output.mp4
  </code></pre>
  
  <p>...but I get the error "Option loop not found."</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-26T09:05:14.400Z
Comments.Text: Use quicktime 7 pro and mov container. So you won't get a bigger file size, than with opensource one.
Comments.UserDisplayName: Дмитрий Мышков
Tags: <ffmpeg><mp4><h.264>
Title: Repeat/loop Input Video with ffmpeg?
UserDisplayName: Thomas King
ThreadText: # Repeat/loop Input Video with ffmpeg?
  
  (Asked by: username_0 on 2014-10-27)
  
  I just want to loop a mp4 video with ffmpeg and keep the current settings and codec.
  
  For example if input.mp4 is 0:10 long, and I would want to loop it 4 times so output.mp4 is 0:40 long, how could I change the following command line to do that?
  
  ```
  ffmpeg -i input.mp4 -c copy output.mp4
  
  ```
  
  I tried...
  
  ```
  ffmpeg -loop 4 -i input.mp4 -c copy output.mp4
  
  ```
  
  ...but I get the error "Option loop not found."
  
  **Tags:** ffmpeg, mp4, h.264
  
  > **Comments:**
  > **username_1**: Use quicktime 7 pro and mov container. So you won't get a bigger file size, than with opensource one.  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_15 on 2014-10-28. Score: 157 | Accepted answer
  
  # `-stream_loop` option
  
  ```
  ffmpeg -stream_loop 3 -i input.mp4 -c copy output.mp4
  
  ```
  
  * This can avoid re-encoding because it can use [stream copy](https://ffmpeg.org/ffmpeg.html#Stream-copy).
  * `0` means no loop, `-1` means infinite loop.
  * This may not work with anything older than FFmpeg 4.0.
  
  ---
  
  # concat demuxer
  
  The [concat demuxer](https://ffmpeg.org/ffmpeg-formats.html#concat) allows you to loop an input without needing to re-encode because it can use [stream copy](https://ffmpeg.org/ffmpeg.html#Stream-copy).
  
  1. Make a text file. Contents of an example text file to repeat 4 times.
  
     ```
      file 'input.mp4'
      file 'input.mp4'
      file 'input.mp4'
      file 'input.mp4'
  
     ```
  2. Then run `ffmpeg`:
  
     ```
      ffmpeg -f concat -i list.txt -c copy output.mp4
  
     ```
  
  If you want to add additional inputs make sure they all have the same attributes.
  
  ### Automatically make `list.txt` in Linux/macOS
  
  This example is the same as above but you don't have to manually make `list.txt`:
  
  ```
  for i in {1..4}; do printf "file '%s'\n" input.mp4 >> list.txt; done
  ffmpeg -f concat -i list.txt -c copy output.mp4
  
  ```
  
  With most commonly-used modern shells, you can even avoid the creation of the `list.txt` file entirely. For example, with bash:
  
  ```
  ffmpeg -f concat -i <(for i in {1..4}; do printf "file '%s'\n" input.mp4; done) -c copy output.mp4
  
  ```
  
  ### Also see:
  
  * [FFmpeg concat demuxer documentation](https://ffmpeg.org/ffmpeg-formats.html#concat)
  * [FFmpeg Wiki: Concatenate](https://trac.ffmpeg.org/wiki/Concatenate)
  
  ---
  
  # loop filter
  
  Example using the [loop filter](https://ffmpeg.org/ffmpeg-filters.html#loop) to loop 4 times, each loop is 75 frames, each loop skips the first 25 frames of the input:
  
  ```
  ffmpeg -i input.mp4 -filter_complex "loop=loop=3:size=75:start=25" output.mp4
  
  ```
  
  * Or use the shorthand: `loop=3:75:25`
  * Filtering requires re-encoding.
  * This filter [places all frames into memory](https://ffmpeg.org/ffmpeg-filters.html#movie).
  * Using `loop=3` will loop 4 times.
  * To loop infinitely use `-1`.
  * You must list the number of frames to loop (shown as 75 in the example above). Max value is 32767.
  * Also see `ffmpeg -h filter=loop`.
  
  ---
  
  # movie filter
  
  The [movie](https://ffmpeg.org/ffmpeg-filters.html#movie) and amovie filters have a loop option:
  
  ```
  ffmpeg -f lavfi -i "movie=filename=input.mp4:loop=4,setpts=N/FRAME_RATE/TB" -f lavfi -i "amovie=filename=input.mp4:loop=4,asetpts=N/SR/TB" output.mp4
  
  ```
  
  * Filtering requires re-encoding.
  * `1` means no loop, `0` means infinite loop.
  
  ---
  
  # `-loop` option
  
  The `-loop` option is specific to the [image file demuxer](https://ffmpeg.org/ffmpeg-formats.html#image2-1) and [gif muxer](https://ffmpeg.org/ffmpeg-formats.html#gif-2), so it can't be used for typical video files. But it can be used to infinitely loop a single image or a series of images.
  
  ### single image
  
  This example will loop a single image over and over but the `-t 30` will limit the output duration to 30 seconds:
  
  ```
  ffmpeg -loop 1 -i input.png -t 30 -vf format=yuv420p output.mp4
  
  ```
  
  `-vf format=yuv420p` is for compatibility reasons.
  
  ### series of images
  
  ```
  ffmpeg -loop 1 -i %03d.jpg -t 30 -vf format=yuv420p output.mp4
  
  ```
  
  ### GIF output
  
  Or to loop a GIF:
  
  ```
  ffmpeg -i input -loop 3 output.gif
  
  ```
  
  For GIF output also see [How do I convert a video to GIF using ffmpeg, with reasonable quality?](https://superuser.com/a/556031/)
  
  > **Comments:**
  > **username_0**: Does this work fine with mp4 files?  
  > **username_16**: I get this error `> <(for i in {1..4}; do printf "file '%s'\n" input.mp4; done) -bash: /dev/fd/63: Permission denied`  
  > **username_17**: @jamesfzhang - I think that's because you need an absolute path to the file (as explained here: https://trac.ffmpeg.org/wiki/Concatenate). To fulfill that, you could write:  ffmpeg -safe 0 -f concat -i <(for i in {1..4}; do printf "file '$PWD'/'%s'\n" input.mp4; done) -c copy output.mp4  
  > **username_18**: As for me this works to repeat **full time** video without skipping fames for 4 times `ffmpeg -i video.mp4 -filter_complex "loop=4:32767" output.mp4`  
  > **username_19**: This issue is 4 years old and noone noticed that the link to the second issue in the `-stream_loop` section is pointing to the same ticket as the first one...  
  > **username_20**: When working on images, is there any difference between `-i %03d.png -t 30` and `-t 30 -i %03d.png`? I know that when working on video, you usually want `-t` (and `-ss`) before the input to save on decode time, but does this matter for images? I've recently run some commands with `-t` before the input and it worked fine.  
  > **username_15**: @DigiVisionMedia Shouldn't make a difference.  
  > **username_21**: Does the looped parts occupy extra size on output video? For example if the original video size is 1MB loop=loop=3 equals 3MB?  
  > **username_22**: Thanks! Only place where I got clarification for difference between `-stream_loop` and `-loop`. I was wondering why the ffmpeg manpage doesn't show the `-loop` option. Now I understand it's because that doesn't give the options for filters or muxers.  
  
  ---
  
  ### Answer by username_2 on 2016-01-13. Score: 32
  
  With ffmpeg 2.8.4, the following command creates output.mp4 that is a repeating copy of input.mp4 until the ffmpeg process is stopped:
  
  ```
  ffmpeg -stream_loop -1 -i input.mp4 -c copy output.mp4
  
  ```
  
  This command won't terminate on its own, and the output file will grow infinitely.
  
  > **Comments:**
  > **username_3**: Seems to be the fastest method  
  > **username_4**: Fastest method is an understatement, this method ramps up to multi-hour videos in a matter of seconds.  
  > **username_5**: This is a great convenient method, because there is no need to create a file with repeating lines.  
  > **username_6**: People need to change the value for -stream_loop parameter from `-1` some positive integer according to theirs requirement. Otherwise, the file grows and the system throws `No space left on device` error.  
  > **username_7**: This should be best answer works from first try .  
  > **username_8**: If you want to specify a time, add **-t 30** this will generate a looped video with 30 sec  
  
  ---
  
  ### Answer by username_9 on 2015-11-18. Score: 16
  
  At least on FFmpeg 2.8.x (but oldie should works too) you can use `lavfi` as input format and complex filter graph using `movie` and `setpts` filters as a argument for `-i` option.
  
  Next command doing this work for you:
  
  ```
  ffmpeg -re -f lavfi -i "movie=filename=input.mp4:loop=0, setpts=N/(FRAME_RATE*TB)" output.mp4
  
  ```
  
  Zero `loop=` arguments means infinity loop. Values greater zero sets repeat counts. `setpts` filters required for PTS adjusting for second and later repeats, otherwise most output muxers will fails with non-monotonic PTS increasing: loop does not recalc PTS.
  
  **Note, that using filters assuming that bypass frames without decoding/encoding is impossible: by design filters deals with decoded frames only.**
  
  At the FFmpeg 2.8.2 new input option `-stream_loop` inroduced. I first look it works more simple and allows copy content without transcoding:
  
  ```
  ffmpeg -re -stream_loop -1 -i input.mp4 -c copy -y output.mp4
  
  ```
  
  But it does not recalculate PTS and output file is wrong. If you add filter to fix PTS (see `setpts`) you must remove `-c copy` too. Only bitstream filters can deals with encoded packets, but there is no any bitstream filters to fix PTS (see: <https://ffmpeg.org/ffmpeg-bitstream-filters.html>)
  
  In any case ffmpeg on second pass fails with error:
  
  ```
  input.mp4: Resource temporarily unavailable
  
  ```
  
  **Known work around for me**: use container for input file without PTS limits (streaming container). One of them, known me, is MPEG-TS. So, you can simple convert your MP4 file to the MPEG-TS:
  
  ```
  ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input.ts
  
  ```
  
  And use next command to compose infinity file:
  
  ```
  ffmpeg -re -stream_loop -1 -i input.ts -c copy -strict -2 -bsf:a aac_adtstoasc -y output.mp4
  
  ```
  
  (bitstream filters should be used only if needed, on my samples it is required)
  
  FFmpeg >= 2.8.2 is required in this case.
  
  > **Comments:**
  > **username_10**: Running that command gives me error : "[mp4 @ 00000000053fa1a0] Could not find tag for codec rawvideo in stream #0, codec not currently supported in container". If I add -vcodec h264 before the input, that error disappears, but the encoder doesn't exit. Supplying a non-zero loop count produces a lot of errors but does exit. The file is not a valid output.  
  > **username_10**: The documentation for stream_loop says "Loop 0 means no loop, loop -1 means infinite loop."  
  > **username_9**: Seems incorrect input files. Could you pleas share it? "Loop 0 means no loop, loop -1 means infinite loop." - seems I see old docs :-)  
  > **username_10**: Mine were valid MP4s but can't share the ones I used .You can generate one using ffmpeg and then use that. Paste the console output if it works.  
  > **username_9**: I forgot: filters assuming transcoding (decode/encode). By design. So you must remove `-c copy`. Answer fixed.  
  > **username_10**: Nice to know, but that's a significant limitation if you have a large loop to generate.  
  > **username_9**: Add info about stream_loop and WA to fix PTS issue without re-encode. FFmpeg >= 2.8.2 is required.  
  > **username_11**: @username_9 I find the loop filter works much  better than stream_loop (which causes a brief pause for any file I tried), with one exception: the moment I add the loop filter the audio disappears?  
  > **username_9**: @username_11, you should check files. Time to time different tracks in file has a little bit different length or offset it can affect muxing. Issues in never versions of FFmpeg also can be occured. Also, most working case - use MPEG TS container as input and output.  
  
  ---
  
  ### Answer by username_12 on 2020-11-29. Score: 0
  
  ```
  @echo off
  
  setlocal ENABLEDELAYEDEXPANSION
  
  REM When not there gives file not found message
  for /f "tokens=*" %%I in ('dir /b "*.mkv"') do (
      if exist "%%~nI.nl.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      )
      if exist "%%~nI.en.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      ) 
  )
  for /f "tokens=*" %%I in ('dir /b "*.mp4"') do (
      if exist "%%~nI.nl.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      )
      if exist "%%~nI.en.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      ) 
  )
  for /f "tokens=*" %%I in ('dir /b "*.webm"') do (
      if exist "%%~nI.nl.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      )
      if exist "%%~nI.en.srt" (
          call :BURN_FILE "%%~nI" "%%I"
      ) 
  )
  
  pause
  
  if not exist ORIGINAL mkdir ORIGINAL
  move "%%I" ORIGINAL >NUL
  move "%%~nI.*" ORIGINAL >NUL
  
  exit /b
  
  :BURN_FILE
  
      set hoppa=%1
      set input=%2
      echo hoppa=!hoppa!
      echo input=!input!
  
      ffprobe.exe -v error -select_streams v:0 -show_entries format=bit_rate -of default=nw=1 !input! > bit_rate2.txt
      ffprobe.exe -v error -show_entries format=duration -of default=nw=1 !input! > duration2.txt
      ffprobe.exe -v error -show_entries format=duration -of default=nw=1 intro.wav > duration_intro.txt
  
      for /F "tokens=*" %%R in (bit_rate2.txt) do (
          for /f "tokens=1,2 delims==" %%a in ("%%R") do set NAME=%%a & set bit_rate=%%b
      )
      for /F "tokens=*" %%R in (duration2.txt) do (
          for /f "tokens=1,2 delims==" %%a in ("%%R") do set NAME=%%a & set duration=%%b
      )
      for /F "tokens=*" %%R in (duration_intro.txt) do (
          for /f "tokens=1,2 delims==" %%a in ("%%R") do set NAME=%%a & set duration_intro=%%b
      )
      for /f "tokens=1 delims=." %%a in ('echo !duration!') do set /a number=%%a
      for /f "tokens=1 delims=." %%a in ('echo !duration_intro!') do set /a number_intro=%%a
  
      set /A number_offset = !number! - !number_intro! - 1
      set /A number_offset = !number_offset! * 1000
  
      sof.exe "!hoppa!.nl.srt"
  
      if not exist DUTCH mkdir DUTCH
  
      for %%x in ("!hoppa!.nl.srt.fixed") do (
          if not %%~zx == 0 (
              if not  exist "DUTCH/!hoppa!.nl.mp4" (
  
              ffmpeg -y -hide_banner -i !input! -i intro.wav -i intro.wav -i pacman2.mp4 -loop 20 -filter_complex "[1]adelay=500|500[s1];[1]adelay=!number_offset!|!number_offset![s2];[0][s1][s2]amix=inputs=3;[0:v]scale=1920:1080[j];[3:v]split[m][a];[a]geq='lum(X,Y)',hue=s=0[al];[m][al]alphamerge[ovr];[ovr]scale=150:-1[sml];[j][sml]overlay=main_w-overlay_w-2:main_h-overlay_h-2[l];[l]subtitles='!hoppa!.nl.srt.fixed':force_style='FontName=Mada Black,FontSize=32,BackColour=&HA0000000,BorderStyle=4'[k]" -map "[k]" -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac -shortest "DUTCH/!hoppa!.nl.PART.mp4"
  
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex "[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed':force_style='FontName=Mada Black,FontSize=32'[k]" -map "[k]" -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac "DUTCH/!hoppa!.nl.PART.mp4"
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex "[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed'[k]" -map "[k]" -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac "DUTCH/!hoppa!.nl.PART.mp4"
  rem             ffmpeg -y -hide_banner -i !input! -filter_complex "[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.nl.srt.fixed'[k]" -map "[k]" -map 0:a -strict -2 -c:v libx264 -preset slow -crf 23 -pix_fmt yuv420p -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac "DUTCH/!hoppa!.nl.PART.mp4"
  
              ) else (
                  echo Already exists: "DUTCH/!hoppa!.nl.mp4" 
              )
          ) else (
              echo Subtitle file empty: !hoppa!.nl.srt.fixed
          )
      )
  
      if exist "DUTCH/!hoppa!.nl.PART.mp4" rename "DUTCH\!hoppa!.nl.PART.mp4" "!hoppa!.nl.mp4"
  
  rem if not exist SUBTITLES mkdir SUBTITLES
  rem if exist "!hoppa!.nl.srt.fixed" move "!hoppa!.nl.srt.fixed" SUBTITLES
  rem if exist "!hoppa!.nl.srt" move "!hoppa!.nl.srt" SUBTITLES
  
  rem remark (rem) goto for making second language
  goto :ENDING
  
  sof.exe "!hoppa!.en.srt"
  
  if not exist ENGLISH mkdir ENGLISH
  
  for %%x in ("!hoppa!.en.srt.fixed") do (
      if not %%~zx == 0 (
          if not  exist "ENGLISH/!hoppa!.en.mp4" (
              ffmpeg -y -hide_banner -i !input! -filter_complex "[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.en.srt.fixed'[k]" -map "[k]" -map 0:a -strict -2 -c:v h264_nvenc -pix_fmt yuv420p -rc-lookahead 32 -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac "ENGLISH/!hoppa!.en.PART.mp4"
  rem                 ffmpeg -y -hide_banner -i !input! -filter_complex "[0:v]scale=1920:1080[j];[j]subtitles='!hoppa!.en.srt.fixed'[k]" -map "[k]" -map 0:a -strict -2 -c:v libx264 -preset slow -crf 23 -pix_fmt yuv420p -b:v !bit_rate! -ac 2 -ar 44100 -acodec aac "ENGLISH/!hoppa!.en.PART.mp4"
          ) else (
              echo Already exists: "DUTCH/!hoppa!.en.mp4" 
          )
      ) else (
          echo Subtitle file empty: !hoppa!.en.srt.fixed
      )
  )
  
  if exist "ENGLISH/!hoppa!.en.PART.mp4" rename "ENGLISH\!hoppa!.en.PART.mp4" "!hoppa!.en.mp4"
  
  rem     if exist "!hoppa!.en.srt.fixed" move "!hoppa!.en.srt.fixed" SUBTITLES >NUL
  rem     if exist "!hoppa!.en.srt" move "!hoppa!.en.srt" SUBTITLES >NUL
  
  :ENDING
  
  if not exist ORIGINAL mkdir ORIGINAL
  move !input! ORIGINAL >NUL
  move "!hoppa!.*" ORIGINAL >NUL
  
  exit /b
  
  ```
  
  
  ---
  
  ### Answer by username_13 on 2022-07-02. Score: 0
  
  If you have MP4 files, these could be losslessly concatenated by first re-wrapping them to MPEG-2 transport streams. With H.264 video and AAC audio, the following can be used:
  
  ```
  ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate.ts
  ffmpeg -i "concat:intermediate.ts|intermediate.ts|intermediate.ts|intermediate.ts" -c copy -bsf:a aac_adtstoasc output.mp4
  
  ```
  
  
  ---
  
  ### Answer by username_14 on 2017-03-11. Score: -1
  
  The simple method that avoids problems of which Commands work with which version is the 'trivial solution':
  
  ```
  ffmpeg -i input.mp4 -i input.mp4 -i input.mp4 -i input.mp4 -c copy output.mp4
  
  ```
  
  See also: <https://trac.ffmpeg.org/wiki/Concatenate> for many examples.
  
  > **Comments:**
  > **username_10**: This does not do *any* concatenation.  At least one of the concat methods has to be used: protocol, filter or demuxer. In this command, ffmpeg's auto mapping will select one video, one audio and one subtitle stream from among the inputs. Since they're identical,  it's equivalent to the OP's first command.  
  > **username_14**: Thanks for testing that Mulvya, as it differs from the behavior described in the Docs: https://ffmpeg.org/ffmpeg.html#Description - If there's similarity in the File names using "-i -i /tmp/test%d.mp4" (et. al) is also possible.  
  
  ---
  
  