I need to add an image (1 frame maybe) for one millisecond at the start of the mp4 video.

The final video should contain audio in the AAC system.

I expect no delay in the audio while the video plays. I would like to have silence at first for one millisecond to avoid lagging video.

OS: Linux/Debian


I converted the first image to an mp4 video with ffmpeg -i <static_picture.jpg> -c:v libx264 -s 256x144 -r 30 -t 0.03 -pix_fmt yuv420p image.mp4

I merged the two videos by concat demuxer but the video submitted has no sound.

The result of ffprobe -hide_banner -i Video.mp4 is:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Video.mp4':
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:03:52.40, start: 0.000000, bitrate: 96 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 256x144 [SAR 1:1 DAR 16:9], 94 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
      handler_name    : VideoHandler

1 Answer 1


I am not sure I understand your question correctly but you can extract the video and audio stream, format them the way you want and then re-multiplex them all with ffmpeg.

ffmpeg -i input.mp4 -c:v copy -an video_only.mp4

The -an option is disabling the audio -c:v copy is copying your video stream to video_only.mp4.

ffmpeg -i input.mp4 -c:a copy -vn audio_only.mp4

Here you do the same but for the audio.

Please note that 1 frame is different than 1 millisecond. The duration of your frame depends on the frame rate but usually is between 16,(6)ms for 60fps (1/60) content and 41,(6)ms for 24fps (1/24) You can have 1ms frame only if your video is 1000fps which I really doubt it is. The audio, on the other hand, has a normally 44100Hz or 48000Hz sampling rate, which means that the minimum sample duration with 48KHz is 2.08(3)E-5 seconds.

When you are done you can multiplex the new video and new audio together by:

ffmpeg -i new_video.mp4 -i new_audio.mp4 -c copy audio_and_video.mp4

In order for this to work you need to have the same duration of both input streams though.

You can also concatenate a static picture to the video file. You can create your image.mp4 file with:

ffmpeg -i <static_picture.jpg> -c:v libx264 -s 1920x1080 -r 50 -t 0.02 -pix_fmt yuv420p image.mp4

This will create an image.mp4 video with a duration of 20 ms (1-frame) with a frame rate of 50, encoded with libx264 and resolution 1920x1080 using pixel format YUV420p which you most likely need.

Then you can concatenate both files by:

ffmpeg -i "concat:image.mp4|original_video.mp4" -c copy output.mp4

Make sure that the frame rate, resolution and pixel format of the image.mp4 and original_video.mp4 match otherwise it won't work.

[EDIT 17.11.2019] Apparently in your case you need to use the concat filter which also will require re-encoding of the audio and video. So the commands are the following:

ffmpeg -i <static_picture.jpg> -f lavfi -i anullsrc -c:v libx264 -s 256x144 -r 25 -t 0.04 -pix_fmt yuv420p -c:a aac -ac 2 -ar 44100 -shortest <image.mp4>

This command will create one frame long video with an empty audio stream, presuming that the second video is having 25fps. Please note that in your question the ffmpeg output of your input file is 25fps (tbr) and not 30fps, as you have presumed. I am also setting the number of channels to two: -ac 2 and the sample rate to 44.1KHz. The number of channels and the sample rate should match between both videos. More information about the anullsrc can be found here: https://trac.ffmpeg.org/wiki/Null Then you can concatenate and encode the video with the following command:

ffmpeg -i <image.mp4> -i <second_video.mp4> -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=2:v=1:a=1[v][a]" -c:v libx264 -b:v 100k -map "[v]" -map "[a]" <output.mp4>

Here I am taking both the video and audio streams from both video files and I am merging them to the output file and setting the video encoding bitrate to 100Kbps, the bitrate of your original video is 96Kbps and I have let ffmpeg decide how to encode the audio. You can change that if you want by defining codec, number of channels, sample rate. More information about the concat filter could be found here: https://trac.ffmpeg.org/wiki/Concatenate

  • "Make sure that the frame rate, resolution and pixel format match" How do I do this for a low-quality video 140p and a 30fps? Can you give an example of pixel format? I think all I need to do is to convert pic.png to pic.mp4 then concatinate it with the video, right?
    – Joe
    Commented Nov 12, 2019 at 16:13
  • 2
    The concat protocol is not recommended for MP4 (the second video will likely not play). Use the concat demuxer instead.
    – llogan
    Commented Nov 12, 2019 at 23:10
  • @YoussofH. It is not trivial, but it is possible (disregarding any possible issues from such a short duration requirement). You need to match all of the attributes. Updating your question with the complete log of ffmpeg -i input will show the information needed to provide an answer for rote usage.
    – llogan
    Commented Nov 12, 2019 at 23:13
  • As @llogan said the concat protocol is not the solution here. Although I tried 3 different concatinations from a previos post but none worked although when I used demuxer the videos were merged but had no sound sadly. Any hints?
    – Joe
    Commented Nov 13, 2019 at 9:03
  • please post your whole line in the main topic as well as the output of ffprobe -hide_banner -i <output.mp4> where `<output.mp4> is the name of your merged file. Commented Nov 13, 2019 at 11:05

Your Answer

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

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