2

I've found a good command to convert an image to a video in FFMPEG, but each image is going to be concatenated into a longer set of videos and images, and I need concat to concatenate the audio tracks too. (Right now it's disregarding all audio tracks, probably because the images converted to videos don't have audio tracks.)

Here's the command I'm running:

ffmpeg -y -loop 1 -f image2 -i /image.jpg -vf 'scale=640:-1' -r 30 -t 10 -pix_fmt yuvj420p out.mp4

How can I add just a simple, silent audio track in this command, or for any videos that don't have an audio track?

Thanks in advance!

4
  • You could possibly do everything in one command instead of making temporary videos beforehand. Can you explain the bigger picture? Are you sure the method you are pursuing is what you really need to do? The XY problem may be making an appearance here.
    – llogan
    Nov 21, 2015 at 2:18
  • @LordNeckbeard, yes definitely. The bigger picture is that I have a set of images and videos to concatenate into one bigger video - some videos have audio tracks, some don't, images need to be played for differing durations, and there's a predefined order to the pieces of content. If there's one awesome way to do a command like this that preserves audio on video clips and keeps it all in high resolution, that would solve the problem! (Also would be great to avoid saving a bunch of temporary files, if not needed) Nov 21, 2015 at 16:06
  • Can you show some info from all inputs from a typical command? Please show the complete console output of ffmpeg -i image.jpg -i middle -i end, etc.
    – llogan
    Nov 21, 2015 at 20:18
  • @LordNeckbeard That's what I'm not completely sure on.. For example, would be like ffmpeg -i image1.jpg -i image2.jpg -i video1noaudio.mp4 -i video2withaudio.mp4 -i image3.jpg and somewhere in there would be concat, and directions for images to use -loop 1 -f image2 -vf "scale=640:-1". It would also need to preserve audio from the videos with audio. Nov 21, 2015 at 20:27

1 Answer 1

1

just add -i audio.mp3 to parameters, so the command will look like: ffmpeg -y -loop 1 -f image2 -i /image.jpg -vf 'scale=640:-1' -r 30 -t 10 -pix_fmt yuvj420p-i audio.mp3out.mp4


Also, here is a good answer: https://stackoverflow.com/questions/11779490/ffmpeg-how-to-add-new-audio-not-mixing-in-video

And here is a ffmpeg-audio manual: http://trac.ffmpeg.org/wiki/Encode/MP3

2
  • This would require making audio.mp3 first which is unnecessary because ffmpeg can general silent audio with the anullsrc filter. Also, placement matters: you're attempting to apply -vf 'scale=640:-1' -r 30 -t 10 -pix_fmt yuvj420p as input options to audio.mp3.
    – llogan
    Nov 21, 2015 at 2:56
  • 1
    Figured it out with using anullsrc. Here's the command: ffmpeg -y -f lavfi -i anullsrc -loop 1 -f image2 -i input1.jpg -r 30 -t 10 -pix_fmt yuvj420p -map 0:a -map 1:v input1.mp4 Dec 4, 2015 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .