1

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 <incorrect code parameters ?>: 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
3
  • Please paste the full command you're using for MXF output.
    – Gyan
    Nov 30, 2015 at 9:50
  • 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
    Nov 30, 2015 at 10:51
  • Looks like ffmpeg may not be able to mux all streams into a new MXF but ffmbc might. I'll check later.
    – Gyan
    Nov 30, 2015 at 12:28

1 Answer 1

2

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 
9
  • 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
    Nov 6, 2015 at 8:34
  • 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
    Nov 6, 2015 at 8:37
  • Wow that's embarrassing, I diden't realise what it actually said... Thanks :)
    – jdoe
    Nov 6, 2015 at 8:39
  • Thank you alot it works, how can I get frame rate of the video?
    – jdoe
    Nov 6, 2015 at 8:51
  • 2
    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
    Nov 15, 2015 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.