You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,13 @@ vod:
119
119
- "-tune:v=ull"# can be passed either as combined args, and will be split
120
120
- "-rc:v"# or parameter ...
121
121
- "cbr"# ... and value on separate lines
122
+
# Optional filtergraph, start each chain with the special `[vin]` pad and end them in `[vout]`
123
+
filtergraph:
124
+
- "[vin]split=2[v1][v2]"# duplicate input
125
+
- "[v1]crop=iw/2:ih:0:0,hflip[left]"# left half mirrored horizontally
126
+
- "[v2]crop=iw/2:ih:iw/2:0,vflip[right]"# right half flipped vertically
127
+
- "[left][right]hstack[vout]"# join halves back together
128
+
122
129
# HLS-VOD segment behaviour (optional)
123
130
segment-length: 4# nominal segment length in seconds
124
131
segment-offset: 1# allowed +/- tolerance in seconds
@@ -133,6 +140,9 @@ vod:
133
140
audio-profile:
134
141
encoder: aac # default "aac", but "copy" is an alternative
135
142
bitrate: 192# kbps
143
+
# Optional filtergraph, start each chain with the special `[ain]` pad and end them in `[aout]`
144
+
# filtergraph:
145
+
# - "[ain]asetrate=48000*1.5,aresample=48000[aout]" # Pitch the audio up by ~50 % (makes everyone sound like that famous mouse!)
136
146
# If cache is enabled
137
147
cache: true
138
148
# If dir is empty, cache will be stored in the same directory as media source
@@ -147,6 +157,57 @@ hls-proxy:
147
157
my_server: http://192.168.1.34:9981
148
158
```
149
159
160
+
## Defining filter graphs on video and audio streams
161
+
162
+
You can optionally define filtergraphs on video and audio profiles. This
163
+
allows you to modify the streams during the transcoding process.
164
+
165
+
If you don't specify any filtergraphs, you get the video scaled to the
166
+
dimensions you specified and the first audio track from the input video.
167
+
168
+
When you do supply a filtergraph:
169
+
170
+
* start the chain at the source pads `[vin]` (video) or `[ain]` (audio)
171
+
* end the chain at `[vout]` or `[aout]` – these pads are what `-map` picks up
172
+
173
+
Examples:
174
+
175
+
```yaml
176
+
vod:
177
+
video-profiles:
178
+
1080p:
179
+
width: 1920
180
+
height: 1080
181
+
bitrate: 5000
182
+
filtergraph:
183
+
- "[vin]format=pix_fmts=yuv420p[vout]" # change pixel format to yuv420p
184
+
```
185
+
186
+
```yaml
187
+
vod:
188
+
audio-profile:
189
+
filtergraph:
190
+
- "[ain][0:a:1]amix=inputs=2[aout]" # mix second audio track into the first
191
+
```
192
+
193
+
### Implementation
194
+
195
+
The transcoder always assembles a single FFmpeg `-filter_complex` that already contains **one video and one audio chain**:
196
+
197
+
1. `[0:v]scale=…[vin]` – scales the first video stream and stores the result in pad `[vin]`.
198
+
2. `[0:a]anull[ain]` – passes the first audio stream through unchanged into pad `[ain]`.
199
+
3. If *no* extra filtergraph is supplied the code auto-adds `[vin]null[vout] ; [ain]anull[aout]` so the outputs exist.
200
+
201
+
Both pads are then selected with:
202
+
203
+
```sh
204
+
-map [vout] -map [aout]?
205
+
```
206
+
207
+
`-map`tells FFmpeg exactly which streams (by pad name or by input index) should
208
+
be written to the current output file. Being explicit prevents surprises when
209
+
inputs carry multiple audio/video streams.
210
+
150
211
## Transcoding profiles for live streams
151
212
152
213
go-transcode supports any formats that ffmpeg likes. We provide profiles out-of-the-box for h264+aac (mp4 container) for 360p, 540p, 720p and 1080p resolutions: `h264_360p`, `h264_540p`, `h264_720p` and `h264_1080p`. Profiles can have any name, but must match regex: `^[0-9A-Za-z_-]+$`
0 commit comments