ffmpeg命令来组合音频和图像 [英] ffmpeg command to combine audio and images

查看:131
本文介绍了ffmpeg命令来组合音频和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一些我以前认为应该是一个简单的任务。
是否有一个ffmpeg命令可以执行以下操作:



将audio.wav文件转换为视频
添加大约100图片(img %d.png)到视频,所以他们自动拉伸以填充视频的整个长度。



我不想手动设置帧率,因为我们也不希望以下情况发生,当我使用loop_input时,发生了这种情况:



创建了一个简短的图像视频,播放速度很快,然后在音频的整个持续时间内重复播放。



请让我知道这个命令。



我目前尝试过以下操作,但这些都没有给我所需的结果:



这是一个,但是视频播放速度很快,而音频没有播放:

  ffmpeg -i img%d.png -i audio.wav -acodec copy output.mpg 

这是一个简短的视频,重复为fu音频时长:

  ffmpeg -loop_input -shortest -i img%d.png -i audio.wav -acodec copy output。 mpg 

这个作品几乎可以,但-r 4使视频缓慢,音频进行。如果我使用-r 5,音频会变慢,视频就会进行:

  ffmpeg -r 4 -i img% d.png -i audio.wav -acodec copy -r 30 output.mpg 


解决方案

测量音轨的时间,然后使用-t $ audio_duration。



此参数与-loop 1一起将停止mp4



您也可以尝试使用2路技术,包括-vcodec libx264,因为它可以很好地产生mp4。



,并考虑以下调整后的输入和记录率:

  -b:v 200k  - bt 50k 


I'm trying to achieve something which I earlier thought should be a simple task. Is there a ffmpeg command that can do the following:

convert an audio.wav file to a video, Add some 100 pics (img%d.png) to the video so they "automatically" stretch to fill the entire length of the video.

I don't want to set the frame rate manually because it's either making the audio go ahead or lack behind.

I also don't want the following to happen, which happenned when I used "loop_input":

A short video of images got created, which played fast and then repeated itself for the entire duration of the audio.

Please let me know the command.

I've currently tried the following, but these are not giving me the desired results:

This one makes, but video goes fast and audio is not full:

ffmpeg -i img%d.png -i audio.wav -acodec copy output.mpg

This one makes short video which repeats for full audio duration:

ffmpeg -loop_input -shortest -i img%d.png -i audio.wav -acodec copy output.mpg

This one works nearly, but "-r 4" makes video go slow and audio goes ahead. If I use "-r 5" then audio goes slow, and video goes ahead:

ffmpeg -r 4 -i img%d.png -i audio.wav -acodec copy -r 30 output.mpg

解决方案

measure the time of the audio track and then use -t $audio_duration.

this arg, along with "-loop 1" will stop the mp4 at a time that matches the audio.

you might also try 2 pass technique , including -vcodec libx264 as it works well producing mp4.

and think about the following adjusted for your inputs and record rates:

    -b:v 200k -bt 50k

这篇关于ffmpeg命令来组合音频和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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