Skip to content

Commit 79e9261

Browse files
committed
av ops using ffmpeg
1 parent 324f834 commit 79e9261

6 files changed

Lines changed: 69 additions & 10 deletions

File tree

.vitepress/sidebar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ export const sidebar = [
287287
{
288288
"text": "Ffmpeg",
289289
"items": [
290+
{
291+
"text": "Audio/Video Ops",
292+
"link": "/ffmpeg/av-ops"
293+
},
290294
{
291295
"text": "Converting videos to High quality GIFs",
292296
"link": "/ffmpeg/converting-videos-to-high-quality-gif"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</tr>
4444
<tr>
4545
<td><a href="#distributed-computing">Distributed Computing</a><sup>[3]</sup></td>
46-
<td><a href="#ffmpeg">Ffmpeg</a><sup>[3]</sup></td>
46+
<td><a href="#ffmpeg">Ffmpeg</a><sup>[4]</sup></td>
4747
<td><a href="#flutter">Flutter</a><sup>[3]</sup></td>
4848
</tr>
4949
<tr>
@@ -246,6 +246,7 @@
246246
### Ffmpeg
247247

248248
<ul>
249+
<li><a target="_blank" href="https://github.com/Bhupesh-V/til/blob/master/ffmpeg/av-ops.md">Audio/Video Ops</a></li>
249250
<li><a target="_blank" href="https://github.com/Bhupesh-V/til/blob/master/ffmpeg/converting-videos-to-high-quality-gif.md">Converting videos to High quality GIFs</a></li>
250251
<li><a target="_blank" href="https://github.com/Bhupesh-V/til/blob/master/ffmpeg/generate-video-thumbnail-using-ffmpeg.md">Generate Video thumbnail using ffmpeg</a></li>
251252
<li><a target="_blank" href="https://github.com/Bhupesh-V/til/blob/master/ffmpeg/record-your-desktop-using-ffmpeg-on-linux.md">Record your Desktop using ffmpeg</a></li>

count.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"count": 184
2+
"count": 185
33
}

ffmpeg/av-ops.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Audio/Video Ops
2+
3+
## Reducing Background Noise
4+
5+
```sh
6+
ffmpeg -i input.mp4 -af "afftdn=nr=12:nf=-25" -c:v copy output.mp4
7+
ffmpeg -i input.mp4 -af "anlmdn=s=0.001" -c:v copy output.mp4
8+
```
9+
10+
- `afftdn`: Activates the FFT denoise filter.
11+
- `nr=12`: Noise reduction strength in dB (default is 12). Increase this value for stronger noise removal, but values too high may distort human speech.
12+
- `nf=-25`: Noise floor in dB (default is -25). Adjusts the threshold below which audio is treated as noise.
13+
- `-c:v copy`: Copies the video stream directly without re-encoding to save processing time and preserve original video quality.
14+
15+
16+
## Video to Audio
17+
18+
```
19+
ffmpeg -i input.mp4 -b:a 192k output.mp3
20+
```
21+
22+
- `-b:a` is bitrate, use 192k or 320k.
23+
24+
## Waveform Videos
25+
26+
This creates a white colored wave form on a black background
27+
```
28+
ffmpeg -i audio.mp3 -filter_complex "[0:a]showwaves=s=1280x720:mode=line:colors=white" -c:v libx264 -preset fast -crf 23 -c:a copy output.mp4
29+
```
30+
31+
ffmpeg -y -i final.mp3 -loop 1 -i bg.jpg -filter_complex "[0:a]showwaves=s=1920x300:colors=0x00A8E8:mode=cline,format=rgba[v];[1:v][v]overlay=0:780[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a aac -shortest -pix_fmt yuv420p final_podcast.mp4
32+
33+
ffmpeg -y -i final.mp3 -loop 1 -i bg.jpeg -filter_complex "[0:a]showwaves=s=1080x100:colors=0x00A8E8:mode=cline,format=rgba[wave];[1:v][wave]overlay=0:260:shortest=1[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a aac -pix_fmt yuv420p final_podcast.mp4
34+
35+
ffmpeg -y -i final.mp3 -loop 1 -i bg.jpeg -filter_complex "[0:a]showwaves=s=1080x200:colors=0xFFD700:mode=cline,format=rgba[wave];[1:v][wave]overlay=0:160:shortest=1[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a aac -pix_fmt yuv420p final_podcast.mp4
36+
37+
<!-- ffmpeg -i input -filter_complex "[0:a]showwaves=s=1280x720:mode=line,format=yuv420p[v]" -map "[v]" -map 0:a -c:v libx264 -c:a copy output.mkv -->
38+
39+
<!-- ffmpeg -i final.mp3 -loop 1 -i bg.jpeg -filter_complex "[0:a]showwaves=s=1080x200:colors=0xFFD700:mode=line,format=yuv420p[v];[1:v][wave]overlay=0:160:shortest=1[outv]" -map "[outv]" -map 0:a -c:v libx264 -c:a aac -pix_fmt yuv420p final_podcast.mp4 -->
40+
41+
### Circular Waveform
42+
43+
```
44+
ffmpeg -i ../final.mp3 -loop 1 -i ../bg.jpeg -filter_complex "[0:a]aformat=channel_layouts=mono,showwaves=s=400x400:mode=line:colors=0xff1646:draw=full,geq='p(mod(W/PI*(PI+atan2(H/2-Y,X-W/2)),W), H-2*hypot(H/2-Y,X-W/2))':a='alpha(mod(W/PI*(PI+atan2(H/2-Y,X-W/2)),W), H-2*hypot(H/2-Y,X-W/2))'" -c:v libx264 -pix_fmt yuv420p -c:a aac circular.mp4 -y
45+
```
46+
47+
[source](https://www.reddit.com/r/ffmpeg/comments/1fwvjb2/comment/lqlx4hd/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)
48+
49+
Variations
50+
51+
```
52+
ffmpeg -i ../final.mp3 -loop 1 -i ../bg.jpeg -filter_complex "[0:a]aformat=channel_layouts=mono,showwaves=s=650x650:mode=line:colors=0xFFD700:draw=full,geq='p(mod(W/PI*(PI+atan2(H/2-Y,X-W/2)),W), H-2*hypot(H/2-Y,X-W/2))':a='alpha(mod(W/PI*(PI+atan2(H/2-Y,X-W/2)),W), H-2*hypot(H/2-Y,X-W/2))'[wave]; [1:v][wave]overlay=(W-w)/2:(H-h)/2" -c:v libx264 -pix_fmt yuv420p -c:a aac -shortest -t 10 circular.mp4 -y
53+
```

index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</tr>
3131
<tr>
3232
<td><a href="#distributed-computing">Distributed Computing</a><sup>[3]</sup></td>
33-
<td><a href="#ffmpeg">Ffmpeg</a><sup>[3]</sup></td>
33+
<td><a href="#ffmpeg">Ffmpeg</a><sup>[4]</sup></td>
3434
<td><a href="#flutter">Flutter</a><sup>[3]</sup></td>
3535
</tr>
3636
<tr>
@@ -72,6 +72,9 @@
7272
<table align="center">
7373
<tbody>
7474
<tr>
75+
<td><a href="https://til.bhupesh.me/arts/sketching">Sketching</a></td>
76+
</tr>
77+
<tr>
7578
<td><a href="https://til.bhupesh.me/databases/acid">ACID</a></td>
7679
</tr>
7780
<tr>
@@ -98,9 +101,6 @@
98101
<tr>
99102
<td><a href="https://til.bhupesh.me/databases/postgres-backup-restore">Taking & Restoring Postgres Backups</a></td>
100103
</tr>
101-
<tr>
102-
<td><a href="https://til.bhupesh.me/devops/running-nomad-cluster">How to run a Local Nomad Cluster</a></td>
103-
</tr>
104104
</tbody>
105105
</table>
106106

@@ -271,6 +271,7 @@
271271
### Ffmpeg
272272

273273
<ul>
274+
<li><a href="/ffmpeg/av-ops">Audio/Video Ops</a></li>
274275
<li><a href="/ffmpeg/converting-videos-to-high-quality-gif">Converting videos to High quality GIFs</a></li>
275276
<li><a href="/ffmpeg/generate-video-thumbnail-using-ffmpeg">Generate Video thumbnail using ffmpeg</a></li>
276277
<li><a href="/ffmpeg/record-your-desktop-using-ffmpeg-on-linux">Record your Desktop using ffmpeg</a></li>

recent_tils.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[
2+
{
3+
"title": "Sketching",
4+
"url": "https://til.bhupesh.me/arts/sketching"
5+
},
26
{
37
"title": "ACID",
48
"url": "https://til.bhupesh.me/databases/acid"
@@ -34,9 +38,5 @@
3438
{
3539
"title": "Taking & Restoring Postgres Backups",
3640
"url": "https://til.bhupesh.me/databases/postgres-backup-restore"
37-
},
38-
{
39-
"title": "How to run a Local Nomad Cluster",
40-
"url": "https://til.bhupesh.me/devops/running-nomad-cluster"
4141
}
4242
]

0 commit comments

Comments
 (0)