简体   繁体   English

当我的音频持续时间小于视频视频持续时间时,如何循环播放音轨ffmpeg

[英]how to loop audio track ffmpeg when my audio duration is less than video video duration

I'm using the follow command to generate a video from images: 我正在使用follow命令从图像生成视频:

"ffmpeg - framerate 1/2 -i storage/emulated/0/myapp/temp/picutre%0d.png" + " -i /storage/emulated/0/myapp/music.mp3 -strict experimental -s " + getScreenResolution() + " -r 30 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 -shortest " + filename; “ ffmpeg-帧率1/2 -i storage / emulated / 0 / myapp / temp / picutre%0d.png” +“ -i /storage/emulated/0/myapp/music.mp3 -strict实验-s” + getScreenResolution( )+“ -r 30 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050-最短” +文件名;

My audio duration time is 30s and my total video duration time is 1min. 我的音频持续时间为30秒,我的视频总持续时间为1分钟。 There's a way to loop my audio to complete my video duration? 有没有一种方法可以循环播放我的音频以完成我的视频时长? I'm using a lib ffmpeg for android to generate a vídeo on my application. 我正在为Android使用lib ffmpeg在我的应用程序上生成视频。

You have to generate the 1 min audio file. 您必须生成1分钟的音频文件。 That mean you have to calculate the number of repetition, then create a concat.txt file like this: 这意味着您必须计算重复次数,然后创建如下的concat.txt文件:

file '/path/to/original.mp3'
file '/path/to/original.mp3'

In your case the duration of original audio is 30s, and you need 1 min. 在您的情况下,原始音频的持续时间为30秒,需要1分钟。 So there are only 2 lines in concat.txt file. 因此, concat.txt文件中只有2行。

Then generate the new audio file: 然后生成新的音频文件:

ffmpeg -t 60 -f concat -i concat.txt -c copy -t 60 output.mp3

Final step is adding new audio file to your video. 最后一步是向视频添加新的音频文件。 More details please read the answer of Eugen Rieck here 更多详细信息,请在这里阅读Eugen Rieck的答案

您可以使用环路滤波器。

"ffmpeg - framerate 1/2 -i storage/emulated/0/myapp/temp/picutre%0d.png" + "-f lavfi -i amovie=/storage/emulated/0/myapp/music.mp3:loop=999 -strict experimental -s " + getScreenResolution() + " -r 30 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 -shortest " + filename;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM