Closed TheTawnyFool closed 2 months ago
I appreciate the suggestion, but with the way I'm handling the processing of the audio file (using a volume envelope, not splitting together and reassembling an audio file) I just don't see how it would work without major rewriting that I'm not interested in taking on right now. If somebody else wanted to tackle this I'd consider reviewing it as a PR, but otherwise I think I'll have to decline this one.
Thank you for taking the time to respond. I beleive it can be done with fmpeg -i input.mp3 -af "volume=enable='between(t,5,10)':volume=0[main];sine=d=5:f=800,adelay=5s,pan=stereo|FL=c0|FR=c0[beep];[main][beep]amix=inputs=2, volume=enable='between(t,15,20)':volume=0[main];sine=d=5:f=800,adelay=15s,pan=stereo|FL=c0|FR=c0[beep];[main][beep]amix=inputs=2, volume=enable='between(t,40,50)':volume=0[main];sine=d=10:f=800,adelay=40s,pan=stereo|FL=c0|FR=c0[beep];[main][beep]amix=inputs=2" output.wav
FFmpeg sine. I might fork the project and see if I can get it working. If I can, I will submit it for submission into your code. Again, thank you so much for responding and the code for this utility.
Ah, I didn't realize it could be done inline like that with that sine filter. In that case, I don't see why not. It wouldn't support the custom .wav file, but for a beep it should be doable. Thanks for the suggestion. Reopening.
Awesome, excited to see it! I am not sure about custom .wav also, I just really need the Beeping, so this will be great for my needs. Thank you so much!
Things are pretty busy for me right now but I'll try to get to it as soon as I can, probably in the next couple of weeks.
Yeah, this would change my life. Very happy to see it was asked for and discovered. Been wondering for a while and I too suspected it would be a 'no' at first.
I think I've got this working. I'm going to do a new release, test it out and let me know what you think.
The only thing that's a bit weird with it is it seems like the volume of the entire file starts out lower, then gets louder. I'm not exactly sure how that is happening, though. My debug output shows that my command looks like this, for this example audio (apologies, this is really hard to read):
$ monkeyplug -v -i boys.ogg -o newboys --beep --pad-milliseconds-pre=100 --pad-milliseconds-post=250
['ffmpeg', '-nostdin', '-hide_banner', '-nostats', '-loglevel', 'error', '-y', '-i', 'boys.ogg', '-vn', '-sn', '-dn', '-filter_complex', "[0:a]volume=enable='between(t,18.100,18.750)':volume=0,volume=enable='between(t,24.380,24.910)':volume=0,volume=enable='between(t,28.780,29.370)':volume=0,volume=enable='between(t,53.400,53.950)':volume=0[mute];sine=f=1000:duration=0.650[beep1];sine=f=1000:duration=0.530[beep2];sine=f=1000:duration=0.590[beep3];sine=f=1000:duration=0.550[beep4];[beep1]atrim=0:0.650,adelay=18100|18100[beep1_delayed];[beep2]atrim=0:0.530,adelay=24380|24380[beep2_delayed];[beep3]atrim=0:0.590,adelay=28780|28780[beep3_delayed];[beep4]atrim=0:0.550,adelay=53400|53400[beep4_delayed];[mute][beep1_delayed][beep2_delayed][beep3_delayed][beep4_delayed]amix=inputs=5", '-c:a', 'libvorbis', '-qscale:a', '5', '-ar', '44100', '-ac', '2', 'newboys.ogg']
The beeping works correctly, but for some reason it seems like the file starts out quieter and gets louder towards the end. But I can't see anything in that command to explain it, the only thing I'm doing with volume is volume=0
for the duration of the words, I'm never setting it to some other higher or lower level.
I've just released v2.1.0, please try it out and report back here how it works for you.
Ah, it might be due to how the amix is normalizing the inputs, I'm going to try something.
You caught me juuust before bed and had me giddy to try this, haha. Yeah I can confirm the low volume and gradual increase issue. However, man am I pleased with the bleep effect!
Great to see an idea and potential fix already on the way. Standing by.
So essentially now what I've done is just surfaced all of options to the ffmpeg amix
filter (and, from what I'm learning, this volume normalization "issue" if we want to call it that is something that not only I am struggling with 😅 ) as configurable for the user:
-b [true|false], --beep [true|false]
Beep instead of silence
-h <int>, --beep-hertz <int>
Beep frequency hertz (default: 1000)
--beep-mix-normalize [true|false]
Normalize mix of audio and beeps (default: True)
--beep-audio-weight <int>
Mix weight for non-beeped audio (default: 4)
--beep-sine-weight <int>
Mix weight for beep (default: 1)
--beep-dropout-transition <int>
Dropout transition for beep (default: 0)
I've been playing with it, and think that using some combination of the non-beeped audio and the beep weights and/or turning normalization on/off we should be able to work around it. I'm not 100% sure what that combination is but I think the answer is in there somewhere, so I'm going to push it as a release and then we can tweak the defaults later if we need to.
That's all I can do on it for now, I may get to carve out some time in the next couple of weeks. Adjusting those parameters definitely adjusts the mix, if any of you all watching this issue wants to experiment (and/or Google) and let me know what works best for you I'd appreciate it.
Fantastic. Gonna head to sleep and start tweaking options very soon.
So, I noticed that v2.1.1 & v2.1.2 definitely starts at a louder volume than a v2.1.0 file, but still noticeably lower than the original file by default. Just a note to anyone, for whatever that's worth.
Anyway THANK YOU very much, my man. And God bless. This tool is such a gamechanger going into the future.
Alright, a few minutes of tweaks revealed that:
--beep-mix-normalize true
was the reason for the low volume (at least with the default weight settings of 4
and 1
, other combinations still yet to be tested). Setting to false
restored the volume levels throughout.--beep-audio-weight
and --beep-sine-weight
both need to be set to 1
(or perhaps just equal values?). If left at the default values with normalization also turned off, I noticed audio distortion in the first 7 seconds of my chosen youtube video, just before the first censor.So for example:
monkeyplug -i video.mp4 -o newvideo --beep --beep-mix-normalize false --beep-audio-weight 1 --beep-sine-weight 1
would produce audio that was just about identical to the original file. Beeps don't seem especially sharp or bothersome to my ears either.
Cool, thanks. Maybe I'll set those as the defaults then but leave it customizable if people want to fiddle with it. Thanks!
Closing with v2.1.3, let me know if you run across any issues with it.
I was wondering if you could add a flag to add a generic cursing BLEEP sound, perhaps allow a custom .wav to be used, instead of muting?