Body: <p>I have a folder with video files. Some are <code>.mov</code>, some are <code>.mp4</code>. As a first step I am converting the <code>.mov</code>-files into <code>.mp4</code> with:</p>
  <pre class="lang-bash prettyprint-override"><code>while read mov; do
     mp4=$(echo &quot;$mov&quot;|sed -e 's|\.mov$|.mp4|i')
     if [ &quot;$mov&quot; == &quot;$mp4&quot; ]; then
       echo &quot;Failed to generate unique MP4 filename for file $mov&quot;
     fi
     ffmpeg -i &quot;$mov&quot; -c:v libx264 -f mp4 &quot;$mp4&quot;
   done &lt; &lt;(find . -type f -iname '*.mov')
  </code></pre>
  <p>This works technically fine.</p>
  <p>As a second step I need to merge two video files: the first one is always the same (<code>intro.mp4</code> with audio), the second file is the either converted <code>.mov</code> or the <code>.mp4</code> from the folder (also with audio).
  Additionally I need a screenshot of the first frame from the second video, which shall be the very first frame and visible for e.g. half a second (for e.g. youtube-shorts to differentiate the videos).</p>
  <p>I create the screenshot with</p>
  <pre class="lang-bash prettyprint-override"><code>ffmpeg -i ${fzbVideo} -ss 1 -vframes 1 ${cover}&quot;_%01d.jpg&quot;
  </code></pre>
  <p>which works perfectly fine.</p>
  <p>As far as I could I followed the example shown <a href="https://stackoverflow.com/questions/43958438/merge-videos-and-images-using-ffmpeg">here</a> and the <a href="https://trac.ffmpeg.org/wiki/Concatenate#filter" rel="nofollow noreferrer">documentation of ffmpeg</a>
  and created a loop for all the videos and the steps of merge screenshot and videos:</p>
  <pre class="lang-bash prettyprint-override"><code>for fzbVideo in *.mp4; do
      # intro should be at the beginning of each video
      intro=&quot;intro/fzb-intro.mp4&quot;
      # getting a cover imge
      cover=&quot;$(basename ${fzbVideo} .mp4)_cover&quot;
      # naming the output file
      fzbVideoOutput=&quot;$(basename ${fzbVideo} .mp4)_output.mp4&quot;
      #   create a cover image from the first frame of the video
      ffmpeg -i ${fzbVideo} -ss 1 -vframes 1 ${cover}&quot;_%01d.jpg&quot;
      # combine the cover image with the intro and the actual video file
      ffmpeg \
  -loop 1 -framerate 1 -t 1 -i ${cover}&quot;_1.jpg&quot; \
  -i ${intro} \
  -i ${fzbVideo} \
  -f lavfi -t 0.1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \
  -filter_complex '[0:v:0][0:a:0][1:v:0][1:a:0][2:a:0][2:a:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}
  done
  </code></pre>
  <p>But this creates the error:</p>
  <pre class="lang-bash prettyprint-override"><code>Stream specifier ':a:0' in filtergraph description [0:v:0][0:a:0][1:v:0][1:a:0][2:a:0][2:a:0]concat=n=3:v=1:a=1 matches no streams.
  </code></pre>
  <p>What do I need to change?
  Additionally, is there a way to combine the converstion from <code>.mov</code> to <code>.mp4</code> also in the loop (if necessary)?</p>
  <hr />
  <p>Meta information: content from the CLI, in case this is important information:</p>
  <pre class="lang-bash prettyprint-override"><code>ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
    built with Apple clang version 14.0.3 (clang-1403.0.22.14.1)
    configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
    libavutil      58.  2.100 / 58.  2.100
    libavcodec     60.  3.100 / 60.  3.100
    libavformat    60.  3.100 / 60.  3.100
    libavdevice    60.  1.100 / 60.  1.100
    libavfilter     9.  3.100 /  9.  3.100
    libswscale      7.  1.100 /  7.  1.100
    libswresample   4. 10.100 /  4. 10.100
    libpostproc    57.  1.100 / 57.  1.100
  Input #0, image2, from 'IMG_5546_cover_1.jpg':
    Duration: 00:00:01.00, start: 0.000000, bitrate: 836 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1080x1920, 1 fps, 1 tbr, 1 tbn
  Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'intro/fzb-intro.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      creation_time   : 2023-11-24T21:59:10.000000Z
    Duration: 00:00:00.83, start: 0.000000, bitrate: 1247 kb/s
    Stream #1:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 602x1070, 1191 kb/s, 30 fps, 30 tbr, 600 tbn (default)
      Metadata:
        creation_time   : 2023-11-24T21:59:10.000000Z
        handler_name    : Core Media Video
        vendor_id       : [0][0][0][0]
    Stream #1:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 38 kb/s (default)
      Metadata:
        creation_time   : 2023-11-24T21:59:10.000000Z
        handler_name    : Core Media Audio
        vendor_id       : [0][0][0][0]
  Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_5546.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf60.3.100
    Duration: 00:00:28.37, start: 0.000000, bitrate: 3126 kb/s
    Stream #2:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, 2989 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        handler_name    : Core Media Video
        vendor_id       : [0][0][0][0]
        encoder         : Lavc60.3.100 libx264
    Stream #2:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : Core Media Audio
        vendor_id       : [0][0][0][0]
  Stream specifier ':a' in filtergraph description [0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a] matches no streams.
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-29T04:33:15.087Z
Comments.Text: `[2:v:0][2:a:0]`
Comments.UserDisplayName: Баяр Гончикжапов
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-29T20:44:02.480Z
Comments.Text: uf, good catch [Баяр Гончикжапов](https://video.stackexchange.com/users/40740/%d0%91%d0%b0%d1%8f%d1%80-%d0%93%d0%be%d0%bd%d1%87%d0%b8%d0%ba%d0%b6%d0%b0%d0%bf%d0%be%d0%b2), but even when I change it, I get the error `Stream specifier ':a:0' in filtergraph description [0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1 matches no streams.`
Comments.UserDisplayName: lukascbossert
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-30T09:18:30.537Z
Comments.Text: change `-loop 1 -framerate 30 -t 1 -i ${cover}"_1.jpg"` and `-f lavfi -t 1 -i anullsrc...` and `[0:v:0][3:a:0]...`
Comments.UserDisplayName: Баяр Гончикжапов
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-30T10:18:25.890Z
Comments.Text: Thanks. I did all the changes, especially this line `-filter_complex '[0:v:0][3:a:0][1:v:0][1:a:0][2:a:0][2:v:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}`, but again I get `Stream specifier ':a:0' in filtergraph description [0:v:0][3:a:0][1:v:0][1:a:0][2:a:0][2:v:0]concat=n=3:v=1:a=1 matches no streams.`. Any idea?
Comments.UserDisplayName: lukascbossert
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-01T05:24:05.317Z
Comments.Text: it is strange. it works for me: `... ffmpeg \
  -loop 1 -framerate 30 -t 1 -i ${cover}"_1.jpg" \
  -t 3 -i ${intro} \
  -i ${fzbVideo} \
  -f lavfi -t 1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \
  -filter_complex '[0:v:0][3:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}`
Comments.UserDisplayName: Баяр Гончикжапов
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-01T07:03:09.543Z
Comments.Text: It seems to be due to the format of the different videos? I get the following error 
  `Stream mapping:
    Stream #0:0 (mjpeg) -> concat
    Stream #1:0 (h264) -> concat
    Stream #1:1 (aac) -> concat
    Stream #2:0 (h264) -> concat
    Stream #2:1 (aac) -> concat
    Stream #3:0 (pcm_u8) -> concat
    concat -> Stream #0:0 (libx264)
    concat -> Stream #0:1 (aac)
  .....`
Comments.UserDisplayName: lukascbossert
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-01T07:03:23.737Z
Comments.Text: part two `Press [q] to stop, [?] for help
  [swscaler @ 0x151480000] deprecated pixel format used, make sure you did set range correctly
  [Parsed_concat_0 @ 0x6000001b80b0] Input link in0:v0 parameters (size 602x1070, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1080x1920, SAR 0:1)
  [Parsed_concat_0 @ 0x6000001b80b0] Failed to configure output pad on Parsed_concat_0
  Error reinitializing filters!
  Failed to inject frame into filter network: Invalid argument
  Error while processing the decoded data for stream #2:0
  Conversion failed!`
Comments.UserDisplayName: lukascbossert
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-02T10:01:18.500Z
Comments.Text: `scale` and `pad` before `concat`
Comments.UserDisplayName: Баяр Гончикжапов
Tags: <ffmpeg>
Title: How can I combine a screenshot and two video files with ffmpeg?
UserDisplayName: lukascbossert
ThreadText: # How can I combine a screenshot and two video files with ffmpeg?
  
  (Asked by: username_0 on 2023-11-27)
  
  I have a folder with video files. Some are `.mov`, some are `.mp4`. As a first step I am converting the `.mov`-files into `.mp4` with:
  
  ```bash
  while read mov; do
     mp4=$(echo "$mov"|sed -e 's|\.mov$|.mp4|i')
     if [ "$mov" == "$mp4" ]; then
       echo "Failed to generate unique MP4 filename for file $mov"
     fi
     ffmpeg -i "$mov" -c:v libx264 -f mp4 "$mp4"
   done < <(find . -type f -iname '*.mov')
  
  ```
  
  This works technically fine.
  
  As a second step I need to merge two video files: the first one is always the same (`intro.mp4` with audio), the second file is the either converted `.mov` or the `.mp4` from the folder (also with audio).
  Additionally I need a screenshot of the first frame from the second video, which shall be the very first frame and visible for e.g. half a second (for e.g. youtube-shorts to differentiate the videos).
  
  I create the screenshot with
  
  ```bash
  ffmpeg -i ${fzbVideo} -ss 1 -vframes 1 ${cover}"_%01d.jpg"
  
  ```
  
  which works perfectly fine.
  
  As far as I could I followed the example shown [here](https://stackoverflow.com/questions/43958438/merge-videos-and-images-using-ffmpeg) and the [documentation of ffmpeg](https://trac.ffmpeg.org/wiki/Concatenate#filter)
  and created a loop for all the videos and the steps of merge screenshot and videos:
  
  ```bash
  for fzbVideo in *.mp4; do
      # intro should be at the beginning of each video
      intro="intro/fzb-intro.mp4"
      # getting a cover imge
      cover="$(basename ${fzbVideo} .mp4)_cover"
      # naming the output file
      fzbVideoOutput="$(basename ${fzbVideo} .mp4)_output.mp4"
      #   create a cover image from the first frame of the video
      ffmpeg -i ${fzbVideo} -ss 1 -vframes 1 ${cover}"_%01d.jpg"
      # combine the cover image with the intro and the actual video file
      ffmpeg \
  -loop 1 -framerate 1 -t 1 -i ${cover}"_1.jpg" \
  -i ${intro} \
  -i ${fzbVideo} \
  -f lavfi -t 0.1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \
  -filter_complex '[0:v:0][0:a:0][1:v:0][1:a:0][2:a:0][2:a:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}
  done
  
  ```
  
  But this creates the error:
  
  ```bash
  Stream specifier ':a:0' in filtergraph description [0:v:0][0:a:0][1:v:0][1:a:0][2:a:0][2:a:0]concat=n=3:v=1:a=1 matches no streams.
  
  ```
  
  What do I need to change?
  Additionally, is there a way to combine the converstion from `.mov` to `.mp4` also in the loop (if necessary)?
  
  ---
  
  Meta information: content from the CLI, in case this is important information:
  
  ```bash
  ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
    built with Apple clang version 14.0.3 (clang-1403.0.22.14.1)
    configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
    libavutil      58.  2.100 / 58.  2.100
    libavcodec     60.  3.100 / 60.  3.100
    libavformat    60.  3.100 / 60.  3.100
    libavdevice    60.  1.100 / 60.  1.100
    libavfilter     9.  3.100 /  9.  3.100
    libswscale      7.  1.100 /  7.  1.100
    libswresample   4. 10.100 /  4. 10.100
    libpostproc    57.  1.100 / 57.  1.100
  Input #0, image2, from 'IMG_5546_cover_1.jpg':
    Duration: 00:00:01.00, start: 0.000000, bitrate: 836 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1080x1920, 1 fps, 1 tbr, 1 tbn
  Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'intro/fzb-intro.mp4':
    Metadata:
      major_brand     : mp42
      minor_version   : 1
      compatible_brands: isommp41mp42
      creation_time   : 2023-11-24T21:59:10.000000Z
    Duration: 00:00:00.83, start: 0.000000, bitrate: 1247 kb/s
    Stream #1:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 602x1070, 1191 kb/s, 30 fps, 30 tbr, 600 tbn (default)
      Metadata:
        creation_time   : 2023-11-24T21:59:10.000000Z
        handler_name    : Core Media Video
        vendor_id       : [0][0][0][0]
    Stream #1:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 38 kb/s (default)
      Metadata:
        creation_time   : 2023-11-24T21:59:10.000000Z
        handler_name    : Core Media Audio
        vendor_id       : [0][0][0][0]
  Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_5546.mp4':
    Metadata:
      major_brand     : isom
      minor_version   : 512
      compatible_brands: isomiso2avc1mp41
      encoder         : Lavf60.3.100
    Duration: 00:00:28.37, start: 0.000000, bitrate: 3126 kb/s
    Stream #2:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1080x1920, 2989 kb/s, 29.97 fps, 29.97 tbr, 30k tbn (default)
      Metadata:
        handler_name    : Core Media Video
        vendor_id       : [0][0][0][0]
        encoder         : Lavc60.3.100 libx264
    Stream #2:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : Core Media Audio
        vendor_id       : [0][0][0][0]
  Stream specifier ':a' in filtergraph description [0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a] matches no streams.
  
  ```
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: `[2:v:0][2:a:0]`  
  > **username_0**: uf, good catch [username_1 username_1](https://video.stackexchange.com/users/40740/%d0%91%d0%b0%d1%8f%d1%80-%d0%93%d0%be%d0%bd%d1%87%d0%b8%d0%ba%d0%b6%d0%b0%d0%bf%d0%be%d0%b2), but even when I change it, I get the error `Stream specifier ':a:0' in filtergraph description [0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1 matches no streams.`  
  > **username_1**: change `-loop 1 -framerate 30 -t 1 -i ${cover}"_1.jpg"` and `-f lavfi -t 1 -i anullsrc...` and `[0:v:0][3:a:0]...`  
  > **username_0**: Thanks. I did all the changes, especially this line `-filter_complex '[0:v:0][3:a:0][1:v:0][1:a:0][2:a:0][2:v:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}`, but again I get `Stream specifier ':a:0' in filtergraph description [0:v:0][3:a:0][1:v:0][1:a:0][2:a:0][2:v:0]concat=n=3:v=1:a=1 matches no streams.`. Any idea?  
  > **username_1**: it is strange. it works for me: `... ffmpeg \ -loop 1 -framerate 30 -t 1 -i ${cover}"_1.jpg" \ -t 3 -i ${intro} \ -i ${fzbVideo} \ -f lavfi -t 1 -i anullsrc=channel_layout=stereo:sample_rate=44100 \ -filter_complex '[0:v:0][3:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1' ${fzbVideoOutput}`  
  > **username_0**: It seems to be due to the format of the different videos? I get the following error  `Stream mapping:   Stream #0:0 (mjpeg) -> concat   Stream #1:0 (h264) -> concat   Stream #1:1 (aac) -> concat   Stream #2:0 (h264) -> concat   Stream #2:1 (aac) -> concat   Stream #3:0 (pcm_u8) -> concat   concat -> Stream #0:0 (libx264)   concat -> Stream #0:1 (aac) .....`  
  > **username_0**: part two `Press [q] to stop, [?] for help [swscaler @ 0x151480000] deprecated pixel format used, make sure you did set range correctly [Parsed_concat_0 @ 0x6000001b80b0] Input link in0:v0 parameters (size 602x1070, SAR 0:1) do not match the corresponding output link in0:v0 parameters (1080x1920, SAR 0:1) [Parsed_concat_0 @ 0x6000001b80b0] Failed to configure output pad on Parsed_concat_0 Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #2:0 Conversion failed!`  
  > **username_1**: `scale` and `pad` before `concat`  
  
  ---
  
  ## 0 answers
  
  