Catalin
Catalin

Reputation: 803

How to mix images and movies with ffmpeg

I have a bunch if h264 encoded mp4 files (of about 10-15 seconds) and I want to mix them with another bunch of jpegs (which should be displayed for x seconds each). So I've setup the concat.txt file :

file slide_1.jpg
duration 3
file movie_1.mp4
file slide_2.jpg
duration 5
file movie_2.mp4

and I am trying to run

yes | scripts/ffmpeg -f concat -i concat.txt -vcodec copy -c:a copy final.mp4

which generates a movie with the length of 6 hours (6:48:34) and in which I can only see the 1st picture.

How do I fix this ?

Upvotes: 1

Views: 119

Answers (1)

Catalin
Catalin

Reputation: 803

As LordNeckbeard said, the slides should first be converted to movies first.

So in my case I convert the slide to movie like this (slide 1 will be a 3 seconds clip):

yes | scripts/ffmpeg -loop 1 -r 25 -i slide_1.jpg -t 00:00:03 -vcodec libx264 -pix_fmt yuv420p -an slide_1.mp4

Then the concat file looks like this:

file slide_1.mp4
file movie_1.mp4
file slide_2.mp4
file movie_2.mp4

and the concatenation command is:

yes | scripts/ffmpeg -f concat -i concat.txt -vcodec copy -c:a copy final.mp4

Note that all the movie pieces must be of the same width and height

Upvotes: 2

Related Questions