加入图像和音频以产生视频 [英] Join images and audio to result video

查看:191
本文介绍了加入图像和音频以产生视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多不同大小的图像(即1024x768和900x942)和30秒的音频文件(audio.mp3),我需要从中创建一个视频。



我现在尝试:result%d.png(1到4)和audio.mp3

  ffmpeg -y -i result%d.png -i audio.mp3 -r 30 -b 2500k -vframes 900 
-acodec libvo_aacenc -ab 160k video.mp4
/ pre>

视频 video.mp4 有30秒,但最后一张图像保持到3音频。



每个图像需要在相同的时间显示,直到音频结束。任何人都知道如何做?



图像数量有时会有所变化。

解决方案

FFMPEG版本:3.2.1-1



UBUNTU 16.04.1



您有一个名为wow.mp3的mp3音频文件在这种情况下,以下命令将获得mp3的持续时间(以秒为单位)。

  ffprobe -v error -show_entries format = duration -of default = noprint_wrappers = 1:nokey = 1 wow.mp3 



一旦你持续了几秒钟(想象我有11.36秒)。现在我有3张图像,我想要运行每个图像(11.36 / 3 = 3.79),然后请使用以下内容:

  ffmpeg -y -framerate 1 / 3.79 -start_number 1 -i ./swissGenevaLake_%d.jpg -i ./akib.mp3 -c:v libx264 -r 25 -pix_fmt yuv420p -c:aac -strict experiment-shortest output.mp4 

这里的图片是./swissGenevaLake_1.jpg,./swissGenevaLake_2.jpg和。 /swissGenevaLake_3.jpg。



-framerate 1 / 3.784表示每张图片运行3.784秒。



- start_number 1表示从图像编号1开始,意思是./swissGenevaLake_1.jpg



-c:v libx264:视频编解码器H.264



-r 25:输出视频帧率25



-pix_fmt yuv420p:输出视频像素格式。



-c:aac:使用aac编码音频



-shortest:音频完成后立即结束视频。



output.mp4:输出文件名



免责声明:我没有t测试合并多个大小的图像。



参考文献:



https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images



https:// trac.ffmpeg.org/wiki/Encode/AAC



http://trac.ffmpeg.org/wiki/FFprobeTips


I have a lot of images with different sizes (i.e. 1024x768 and 900x942) and an audio file (audio.mp3) of 30 seconds and I need to create a video from them.

I'm trying it now with: result%d.png (1 to 4) and audio.mp3

ffmpeg -y -i result%d.png -i audio.mp3 -r 30 -b 2500k -vframes 900
-acodec libvo_aacenc -ab 160k video.mp4

The video video.mp4 has 30 seconds but the 3 first images is showed very quickly when the last image remains until the end of the audio.

Each image needs to be showed in a equal time until the end of the audio. Anyone knows how to do it?

The number of the images will vary sometimes.

解决方案

FFMPEG version: 3.2.1-1

UBUNTU 16.04.1

Imagine, you have an mp3 audio file named wow.mp3 In that case, the following command will get the duration of the mp3 in seconds.

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 wow.mp3

Once you have the duration in seconds (imagine I got 11.36 seconds). Now since I have 3 images, I want to run each image for (11.36/3 = 3.79), then please use the following:

ffmpeg -y -framerate 1/3.79 -start_number 1 -i ./swissGenevaLake_%d.jpg -i ./akib.mp3 -c:v libx264 -r 25 -pix_fmt yuv420p -c:a aac -strict experimental -shortest output.mp4

Here the images are ./swissGenevaLake_1.jpg, ./swissGenevaLake_2.jpg , and ./swissGenevaLake_3.jpg.

-framerate 1/3.784 means, each image runs for 3.784 seconds.

-start_number 1 means, starts with image number one, meaning ./swissGenevaLake_1.jpg

-c:v libx264: video codec H.264

-r 25: output video framerate 25

-pix_fmt yuv420p: output video pixel format.

-c:a aac: encode the audio using aac

-shortest: end the video as soon as the audio is done.

output.mp4: output file name

Disclaimer: I have not tested merging images of multiple sizes.

References:

https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images

https://trac.ffmpeg.org/wiki/Encode/AAC

http://trac.ffmpeg.org/wiki/FFprobeTips

这篇关于加入图像和音频以产生视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆