FFMPEG:根据时间进度,根据实际进度填充/更改(部分)音频波形颜色 [英] FFMPEG : Fill/Change (part of) audio waveform color as per actual progress with respect to time progress

查看:67
本文介绍了FFMPEG:根据时间进度,根据实际进度填充/更改(部分)音频波形颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行从mp3文件生成波形并在背景图片上显示并播放音频的命令.为此,我想根据整个视频时间的流逝从左到右更改波形颜色(类似于进度条).

I am trying to make command which is generating waveform from mp3 file and show on background image and play audio. Togethr with this, I want to change waveform color left to right (something like progressbar) as per overall video time elapses.

我创建了以下命令,该命令使用绘制框显示进度条以根据当前时间位置填充框的颜色.

I have created following command which shows progress bar using drawbox to fill box color as per current time position.

ffmpeg -y -loop 1-线程0 -i sample_background.png -i input.mp3 -filter_complex"color=red@0.5:s = 1280x100 [Color]; [0:v] drawbox = 0:155:1280:100:gray @ 1:t = fill [baserect]; [1:a] aformat = channel_layouts = mono,showwaves = s = 1280x100:rate = 7:mode = cline:scale = sqrt:colors = 0xffffff [waveform];[baserect] [waveform] overlay = 0:155 [v1]; [v1] [Color] overlay = x ='if(gte(t,0),-W +(t)* 64,NAN)':y = 155:format = yuv444 [v2]"-map" [v2]"-map 1:a -c:v libx264 -crf 35 -ss 0 -t 20 -c:a复制-最短-pix_fmt yuv420p -threads 0 output_withwave_and_progresbar.mp4

ffmpeg -y -loop 1 -threads 0 -i sample_background.png -i input.mp3 -filter_complex "color=red@0.5:s=1280x100[Color];[0:v]drawbox=0:155:1280:100:gray@1:t=fill[baserect];[1:a]aformat=channel_layouts=mono,showwaves=s=1280x100:rate=7:mode=cline:scale=sqrt:colors=0xffffff[waveform]; [baserect][waveform] overlay=0:155 [v1];[v1][Color] overlay=x='if(gte(t,0), -W+(t)*64, NAN)':y=155:format=yuv444[v2]" -map "[v2]" -map 1:a -c:v libx264 -crf 35 -ss 0 -t 20 -c:a copy -shortest -pix_fmt yuv420p -threads 0 output_withwave_and_progresbar.mp4

但是我想在生成的音频波形中显示进度,而不是使用绘制框制作/填充矩形.

But I want to show progress inside generated audio waveform instead of making / filling rectangle using drawbox.

因此,我试图制作2种具有2种不同颜色并彼此重叠的波形,我想展示一种方式,使顶部波形仅显示x位置(左侧)相对于当前时间的一部分.

So I have tried to make 2 waveform of 2 different color and overlay on each other and I wanted to show such a way that top waveform should display only part from x position (left) respective to current time.

ffmpeg -y -loop 1-线程0 -i sample_background.png -i input.mp3 -filter_complex"[0:v] drawbox = 0:155:1280:100:gray @ 1:t = fill [baserect]; [1:a] aformat = channel_layouts = mono,showwaves = s = 1280x100:rate = 7:mode = cline:scale = sqrt:colors = 0xff0000 [waveform]; [1:a] aformat = channel_layouts = mono,showwaves =s = 1280x100:rate = 7:mode = cline:scale = sqrt:colors = 0xffffff [waveform2]; [baserect] [waveform] overlay = 0:155 [v1]; [v1] [waveform2] overlay = x ='if(gte(t,0),-W +(t)* 64,NAN)':y = 155:format = yuv444 [v2]"-map" [v2]"-map 1:a -c:v libx264 -crf35 -ss 0 -t 20 -c:a副本-最短-pix_fmt yuv420p-线程0 test.mp4

ffmpeg -y -loop 1 -threads 0 -i sample_background.png -i input.mp3 -filter_complex "[0:v]drawbox=0:155:1280:100:gray@1:t=fill[baserect];[1:a]aformat=channel_layouts=mono,showwaves=s=1280x100:rate=7:mode=cline:scale=sqrt:colors=0xff0000[waveform];[1:a]aformat=channel_layouts=mono,showwaves=s=1280x100:rate=7:mode=cline:scale=sqrt:colors=0xffffff[waveform2]; [baserect][waveform] overlay=0:155 [v1];[v1][waveform2] overlay=x='if(gte(t,0), -W+(t)*64, NAN)':y=155:format=yuv444[v2]" -map "[v2]" -map 1:a -c:v libx264 -crf 35 -ss 0 -t 20 -c:a copy -shortest -pix_fmt yuv420p -threads 0 test.mp4

但是我无法找到从左到右执行擦除"效果的方法,当前它正在滑动(因为我正在更改叠加层的x)可以使用alpha合并并将所有其他像素设置为透明并仅显示小于x pos的像素来完成.但我找不到执行该操作的方法.

But I am not able to find way to do Wipe effect from left to right, currently it is sliding (as I am changing x of overlay) It might be done using alpha merge and setting all other pixel to transparent and only show pixels which are less than x pos. but I am not able to find how to do this.

背景图片:

我们可以使用任何mp3文件,目前我已将其设置为20秒.

we can use any mp3 file file, currently I have set 20 sec duration.

有人可以指导我们如何做到这一点吗?

Can someone please guide how we can do this?

谢谢.

推荐答案

使用混合过滤器,即

ffmpeg -y -loop 1 -threads 0 -i sample_background.png -i input.mp3 -filter_complex"[0:v] drawbox = 0:155:1280:100:gray @ 1:t = fill[baserect]; [1:a] aformat = channel_layouts = mono,asplit [red] [white]; [red] showwaves = s = 1280x100:rate = 7:mode = cline:scale = sqrt:colors = 0xff0000 [red]; [white] showwaves = s = 1280x100:rate = 7:mode = cline:scale = sqrt:colors = 0xffffff [white]; [red] [white] blend = all_expr ='if(lte(X/W,T/64),A,B)'[waveform]; [baserect] [waveform] overlay = 0:155:format = yuv444 [v]"-map" [v]"-map 1:a -c:v libx264 -crf35 -ss 0 -t 20 -c:一个副本-最短-pix_fmt yuv420p-线程0 test.mp4

其中 64 是音频的总持续时间.

where 64 is total duration of audio.

这篇关于FFMPEG:根据时间进度,根据实际进度填充/更改(部分)音频波形颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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