<p>Use this:</p>

<pre><code>ffmpeg -r 25 -loop 1 -t 3 -i "image" -i "video" -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -encoding_parameters -map "[v]" -map "[a]" output.mp4
</code></pre>

<p>Ideally set 'r' of image to frame rate of video. The 'r' will be the framerate of the output as well.</p>

<p>The 't' before the image input and the dummy audio input should be the same and represents the image hold in seconds.</p>

<p>The image should be the same resolution as the video. Else, scale (and pad) one or the other in the filter chain before the concat operation.</p>

<p><strong>Edit</strong>: Here's a commandline with some common encoding parameters set</p>

<pre><code>ffmpeg -r 25 -loop 1 -t 3 -i "image" -i "video" -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4 
</code></pre>

CC BY-SA 3.0
2015-11-06T08:34:00.257Z
I ran it in cmd and got this error: "Unrecognized option: 'encoding paramters'. Error splitting the argument list: Option not found. I only changed the "video", "image" and "output.mp4" from your line, everything else was the same
jdoe
CC BY-SA 3.0
2015-11-06T08:37:33.857Z
Sorry, looks like you're new to ffmpeg. That was a placeholder text to substitute your actual encoding parameters there. I'll update my answer with some common settings.
Gyan
CC BY-SA 3.0
2015-11-06T08:39:12.443Z
Wow that's embarrassing, I diden't realise what it actually said... Thanks :)
jdoe
CC BY-SA 3.0
2015-11-06T08:51:09.997Z
Thank you alot it works, how can I get frame rate of the video?
jdoe
CC BY-SA 3.0
2015-11-06T09:13:34.820Z
If you run ffprobe "video", the console output will show file details and in the video stream, there will be something like 'X fps'. X is your framerate.
Gyan
CC BY-SA 3.0
2015-11-07T21:49:01.620Z
@jdoe and Mulvya: ideally you could generate the still-image part of the video and merge it with the already-encoded video, so you don't have to re-encode the entire video.  That's slow and lossy.  If your videos are all in the same format, it shouldn't be too hard.  If you have to detect wmv vs mp4 vs avi, or arbitrary codecs within those containers, it would be messy.
Peter Cordes
CC BY-SA 3.0
2015-11-07T21:49:59.693Z
Also, instead of duplicating the image for n frames, you could make a VFR video that just had the one image frame displayed for whatever time period you want, before the rest of the video.
Peter Cordes
CC BY-SA 3.0
2015-11-08T04:51:10.993Z
Depending on the codec/format of the video, maybe concat copy wouldn't be possible. About the VFR issue, I'm unsure if ffmpeg outputs VFR MP4.
Gyan
CC BY-SA 3.0
2015-11-15T01:03:25.860Z
Just a few nits: the image file demuxer should use `-framerate` instead of `-r`, `anullsrc` is faster than `aevalsrc` (but that's insignificant), and the `-t` does not need to match; it only needs to be very short as long as it is shorter than the related video stream because `concat` will pad the rest automatically.
llogan
CC BY-SA 3.0
2015-11-06T06:14:04.907Z
2015-11-06T08:38:50.590Z
2015-11-06T08:38:50.590Z
Gyan
<p>I need to put an image before a video with FFMPEG. The image should not be instead of the video but before. The best is if I can choose a number of frames to show the image, instead of seconds. I'm going to run the command via PHP exec.</p>

<p>I tried some commands but could not get them to properly work via exec or directly via CMD.</p>

<p>So tips on how this could be achieved is appreciated.</p>

<p><strong>How can I make the output an .mxf file? When I only change the extension of output file I get:</strong></p>

<pre><code>    Could not write header for output file #0 &lt;incorrect code parameters ?&gt;: Error number -1 occurred
</code></pre>

<p>Command used:</p>

<pre><code>    ffmpeg -r 30 -loop 1 -t 3 -i image.jpg -i video.mxf -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" out.mxf
</code></pre>

<p>FFprobe output:</p>

<pre><code>    ffprobe version N-74751-gb54e03c Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 59.100 / 56. 59.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.100 /  5. 40.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mxf @ 000000000310b8a0] broken or empty index
Input #0, mxf, from 'C:/video.mxf':
  Metadata:
    uid             : 8206ba85-3954-2f4a-9d3c-c4e8d5ba793a
    generation_uid  : de90d87a-f4a7-944c-b6c1-368903cb7a3f
    company_name    : Rhozet
    product_name    : Carbon
    product_version : 1.00
    product_uid     : 060e2b34-0401-0101-0e00-000000000000
    modification_date: 2015-10-30 15:45:05
    material_package_umid: 0x060A2B340101010501010D33130000009BC9C7D36B3F43438EAECC12C87EB630
    timecode        : 00:00:00:00
  Duration: 00:00:42.04, start: 0.000000, bitrate: 36660 kb/s
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 59.94 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:1: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:2: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:3: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:4: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:5: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:6: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:7: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:8: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:9: Data: none
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
      data_type       : vbi_vanc_smpte_436M
Unsupported codec with id 0 for input stream 9
</code></pre>

CC BY-SA 3.0
2015-11-30T09:50:55.600Z
Please paste the full command you're using for MXF output.
Gyan
CC BY-SA 3.0
2015-11-30T10:51:22.700Z
MXF has restrictions on the audio and video streams it can contain, so what's the info about the source MXF. Paste the output of ffprobe.
Gyan
CC BY-SA 3.0
2015-11-30T12:28:11.377Z
Looks like ffmpeg may not be able to mux all streams into a new MXF but ffmbc might. I'll check later.
Gyan
<ffmpeg>
FFMPEG - Image before video
jdoe
# FFMPEG - Image before video

(Asked by: username_0 on 2015-11-05)

I need to put an image before a video with FFMPEG. The image should not be instead of the video but before. The best is if I can choose a number of frames to show the image, instead of seconds. I'm going to run the command via PHP exec.
I tried some commands but could not get them to properly work via exec or directly via CMD.
So tips on how this could be achieved is appreciated.
How can I make the output an .mxf file? When I only change the extension of output file I get:
    Could not write header for output file #0 : Error number -1 occurred

Command used:
    ffmpeg -r 30 -loop 1 -t 3 -i image.jpg -i video.mxf -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" out.mxf

FFprobe output:
    ffprobe version N-74751-gb54e03c Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 4.9.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 59.100 / 56. 59.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.100 /  5. 40.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mxf @ 000000000310b8a0] broken or empty index
Input #0, mxf, from 'C:/video.mxf':
  Metadata:
    uid             : 8206ba85-3954-2f4a-9d3c-c4e8d5ba793a
    generation_uid  : de90d87a-f4a7-944c-b6c1-368903cb7a3f
    company_name    : Rhozet
    product_name    : Carbon
    product_version : 1.00
    product_uid     : 060e2b34-0401-0101-0e00-000000000000
    modification_date: 2015-10-30 15:45:05
    material_package_umid: 0x060A2B340101010501010D33130000009BC9C7D36B3F43438EAECC12C87EB630
    timecode        : 00:00:00:00
  Duration: 00:00:42.04, start: 0.000000, bitrate: 36660 kb/s
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 59.94 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:1: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:2: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:3: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:4: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:5: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:6: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:7: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:8: Audio: pcm_s24le, 48000 Hz, 1 channels, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
    Stream #0:9: Data: none
    Metadata:
      file_package_umid: 0x060A2B340101010501010D3313000000B70F9172F67EE340AE91E11FC1BA4B0B
      data_type       : vbi_vanc_smpte_436M
Unsupported codec with id 0 for input stream 9

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Please paste the full command you're using for MXF output.  
> **username_1**: MXF has restrictions on the audio and video streams it can contain, so what's the info about the source MXF. Paste the output of ffprobe.  
> **username_1**: Looks like ffmpeg may not be able to mux all streams into a new MXF but ffmbc might. I'll check later.  

---

## 1 answers

### Answer by username_1 on 2015-11-06. Score: 2 | Accepted answer

Use this:
ffmpeg -r 25 -loop 1 -t 3 -i "image" -i "video" -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -encoding_parameters -map "[v]" -map "[a]" output.mp4

Ideally set 'r' of image to frame rate of video. The 'r' will be the framerate of the output as well.
The 't' before the image input and the dummy audio input should be the same and represents the image hold in seconds.
The image should be the same resolution as the video. Else, scale (and pad) one or the other in the filter chain before the concat operation.
Edit: Here's a commandline with some common encoding parameters set
ffmpeg -r 25 -loop 1 -t 3 -i "image" -i "video" -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4

> **Comments:**
> **username_0**: I ran it in cmd and got this error: "Unrecognized option: 'encoding paramters'. Error splitting the argument list: Option not found. I only changed the "video", "image" and "output.mp4" from your line, everything else was the same  
> **username_1**: Sorry, looks like you're new to ffmpeg. That was a placeholder text to substitute your actual encoding parameters there. I'll update my answer with some common settings.  
> **username_0**: Wow that's embarrassing, I diden't realise what it actually said... Thanks :)  
> **username_0**: Thank you alot it works, how can I get frame rate of the video?  
> **username_1**: If you run ffprobe "video", the console output will show file details and in the video stream, there will be something like 'X fps'. X is your framerate.  
> **username_2**: @username_0 and Mulvya: ideally you could generate the still-image part of the video and merge it with the already-encoded video, so you don't have to re-encode the entire video.  That's slow and lossy.  If your videos are all in the same format, it shouldn't be too hard.  If you have to detect wmv vs mp4 vs avi, or arbitrary codecs within those containers, it would be messy.  
> **username_2**: Also, instead of duplicating the image for n frames, you could make a VFR video that just had the one image frame displayed for whatever time period you want, before the rest of the video.  
> **username_1**: Depending on the codec/format of the video, maybe concat copy wouldn't be possible. About the VFR issue, I'm unsure if ffmpeg outputs VFR MP4.  
> **username_3**: Just a few nits: the image file demuxer should use `-framerate` instead of `-r`, `anullsrc` is faster than `aevalsrc` (but that's insignificant), and the `-t` does not need to match; it only needs to be very short as long as it is shorter than the related video stream because `concat` will pad the rest automatically.  

---

