-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg.rb
More file actions
314 lines (291 loc) · 12.1 KB
/
Copy pathffmpeg.rb
File metadata and controls
314 lines (291 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
class Ffmpeg < Formula
desc "Alternative FFmpeg formula with options"
homepage "https://ffmpeg.org/"
license "GPL-2.0-or-later"
head "https://github.com/FFmpeg/FFmpeg.git", branch: "master"
stable do
url "https://ffmpeg.org/releases/ffmpeg-9.0.2.tar.xz"
sha256 "8c3850283eb25fa026482078a04051e0be17347b09ef81a0849bec15a96e002e"
# Fix build with openapv >= 1.0
patch :DATA
end
option "with-aribb24", "Enable ARIB STD-B24, decoding JIS 8 bit characters and parsing MPEG-TS"
option "with-aribcaption", "Enable ARIB STD-B24 based broadcast captions"
option "with-bluray", "Enable Blu-Ray Discs playback"
option "with-bs2b", "Enable Bauer stereophonic-to-binaural DSP"
option "with-chromaprint", "Enable Chromaprint audio fingerprinting library"
option "with-decklink", "Enable DeckLink support"
option "with-dvd", "Enable DVD-Video demuxer, powered by libdvdnav and libdvdread"
option "with-frei0r", "Enable frei0r filters, mixers and generators"
option "with-game-music-emu", "Enable Game Music Emu (GME)"
option "with-ggml", "Enable Tensor library for machine learning"
option "with-jack", "Enable Jack"
option "with-jpeg-xl", "Enable JPEG XL image format"
option "with-libcaca", "Enable libcaca"
option "with-libflite", "Enable text to speech synthesis support via Flite"
option "with-libgsm", "Enable lossy speech compression"
option "with-libmodplug", "Enable module/tracker files as inputs via libmodplug"
option "with-libopenmpt", "Enable module/tracker files as inputs via libopenmpt"
option "with-libplacebo", "Enable GPU-accelerated image/video processing primitives"
option "with-librist", "Enable Reliable Internet Stream Transport (RIST)"
option "with-librsvg", "Enable SVG files as inputs via librsvg"
option "with-libsoxr", "Enable SoX Resampler library"
option "with-libssh", "Enable SFTP protocol via libssh"
option "with-libvidstab", "Enable vid.stab, a video stabilisation library"
option "with-libvmaf", "Enable libvmaf scoring library"
option "with-libxml2", "Enable libxml2 library for parsing XML documents"
option "with-libzvbi", "Enable decoding of DVB teletext pages and DVB teletext subtitles"
option "with-openal-soft", "Enable OpenAL (Open Audio Library) for macOS targets"
option "with-openapv", "Enable OpenAPV (Open Advanced Professional Video Codec)"
option "with-opencore-amr", "Enable Opencore AMR NR/WB audio format"
option "with-openh264", "Enable OpenH264 library"
option "with-openjpeg", "Enable OpenJPEG, the reference implementation of JPEG 2000"
option "with-openssl", "Enable SSL"
option "with-openvino", "Enable OpenVINO for Deep Neural Network (DNN) based filters"
option "with-qrencode", "Enable QR Code generation"
option "with-rav1e", "Enable AV1 encoding via librav1e"
option "with-rtmpdump", "Enable RTMP dumping"
option "with-rubberband", "Enable Rubber Band library"
option "with-speex", "Enable an audio codec designed for speech"
option "with-srt", "Enable Secure Reliable Transport (SRT)"
option "with-two-lame", "Enable TwoLAME, an optimised MPEG Audio Layer 2 (MP2) encoder"
option "with-tensorflow", "Enable TensorFlow as a module backend for DNN-based filters"
option "with-tesseract", "Enable the Tesseract OCR engine"
option "with-webp", "Enable libwebp to encode and decode images in WebP format"
option "with-whisper.cpp", "Enable OpenAI's Whisper speech recognition model"
option "with-xvid", "Enable Xvid"
option "with-zeromq", "Enable libzeromq to receive commands sent through a libzeromq client"
option "with-zimg", "Enable zimg for scaling, colorspace conversion and dithering"
depends_on "pkgconf" => :build
depends_on "xz"
depends_on "aom" => :recommended
depends_on "dav1d" => :recommended
depends_on "fontconfig" => :recommended
depends_on "freetype" => :recommended
depends_on "harfbuzz" => :recommended
depends_on "lame" => :recommended
depends_on "libass" => :recommended
depends_on "libvorbis" => :recommended
depends_on "libvpx" => :recommended
depends_on "opus" => :recommended
depends_on "sdl2" => :recommended
depends_on "snappy" => :recommended
depends_on "svt-av1" => :recommended
depends_on "theora" => :recommended
depends_on "x264" => :recommended
depends_on "x265" => :recommended
depends_on "aribb24" => :optional
depends_on "chromaprint" => :optional
depends_on "frei0r" => [:optional, :no_linkage]
depends_on "game-music-emu" => :optional
depends_on "ggml" => :optional
depends_on "jack" => :optional
depends_on "jpeg-xl" => :optional
depends_on "libaribcaption" => :optional
depends_on "libbluray" => :optional
depends_on "libbs2b" => :optional
depends_on "libcaca" => :optional
depends_on "libgsm" => :optional
depends_on "libmodplug" => :optional
depends_on "libopenmpt" => :optional
depends_on "libplacebo" => :optional
depends_on "librist" => :optional
depends_on "librsvg" => :optional
depends_on "libsoxr" => :optional
depends_on "libssh" => :optional
depends_on "libtensorflow" => :optional
depends_on "libvidstab" => :optional
depends_on "libvmaf" => :optional
depends_on "openal-soft" => :optional
depends_on "openapv" => :optional
depends_on "opencore-amr" => :optional
depends_on "openh264" => :optional
depends_on "openjpeg" => :optional
depends_on "openssl@3" => :optional
depends_on "openvino" => :optional
depends_on "qrencode" => :optional
depends_on "rav1e" => :optional
depends_on "rtmpdump" => :optional
depends_on "rubberband" => :optional
depends_on "speex" => :optional
depends_on "srt" => :optional
depends_on "tesseract" => :optional
depends_on "two-lame" => :optional
depends_on "webp" => :optional
depends_on "whisper.cpp" => :optional
depends_on "xvid" => :optional
depends_on "zeromq" => :optional
depends_on "zimg" => :optional
# `--with-dvd` needs the DVD libraries — plus libdvdcss, a dependency of
# libdvdread — installed and discoverable via pkg-config at build time.
if build.with? "dvd"
depends_on "libdvdcss"
depends_on "libdvdnav"
depends_on "libdvdread"
end
uses_from_macos "bzip2"
uses_from_macos "zlib"
uses_from_macos "libxml2" => :optional
on_macos do
depends_on "libarchive"
depends_on "libogg"
depends_on "libsamplerate"
end
on_linux do
depends_on "gcc" => :build
depends_on "alsa-lib"
depends_on "libdrm"
depends_on "libxext"
depends_on "libxv"
depends_on "libx11" => :recommended
depends_on "libxcb" => :recommended
end
on_intel do
depends_on "nasm" => :build
end
fails_with gcc: "5"
def install
ohai "Installing FFmpeg with options..."
args = %W[
--prefix=#{prefix}
--enable-shared
--enable-pthreads
--cc=#{ENV.cc}
--host-cflags=#{ENV.cflags}
--host-ldflags=#{ENV.ldflags}
--enable-demuxer=dash
--enable-gpl
--enable-libaom
--enable-libdav1d
--enable-libharfbuzz
--enable-libmp3lame
--enable-libopus
--enable-libsnappy
--enable-libsvtav1
--enable-libtheora
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-libx265
--enable-libfontconfig
--enable-libfreetype
--enable-libass
--disable-htmlpages
--extra-version=AVpres
]
args << "--enable-neon" if Hardware::CPU.arm?
if OS.mac?
args << "--enable-openal" if build.with? "openal-soft"
args << "--enable-opencl"
args << "--enable-audiotoolbox"
args << "--enable-avfoundation"
args << "--enable-videotoolbox"
end
args << "--enable-chromaprint" if build.with? "chromaprint"
if build.with? "decklink"
args << "--enable-nonfree"
args << "--enable-decklink"
args << "--extra-cflags=-I#{HOMEBREW_PREFIX}/include"
args << "--extra-ldflags=-L#{HOMEBREW_PREFIX}/include"
mv "VERSION", "VERSION.txt"
end
if build.with? "dvd"
ENV.prepend_path "PKG_CONFIG_PATH", formula_opt_lib("libdvdnav")/"pkgconfig"
ENV.prepend_path "PKG_CONFIG_PATH", formula_opt_lib("libdvdread")/"pkgconfig"
ENV.prepend_path "PKG_CONFIG_PATH", formula_opt_lib("libdvdcss")/"pkgconfig"
args << "--enable-libdvdnav"
args << "--enable-libdvdread"
end
args << "--enable-libflite" if build.with? "libflite"
args << "--enable-libgme" if build.with? "game-music-emu"
if build.with? "jack"
ENV.prepend_path "PKG_CONFIG_PATH", formula_opt_lib("jack")/"pkgconfig"
args << "--enable-libjack"
args << "--enable-indev=jack"
end
args << "--enable-libjxl" if build.with? "jpeg-xl"
args << "--enable-libaribb24" if build.with? "aribb24"
args << "--enable-libaribcaption" if build.with? "aribcaption"
args << "--enable-libbluray" if build.with? "bluray"
args << "--enable-libbs2b" if build.with? "bs2b"
args << "--enable-libcaca" if build.with? "libcaca"
args << "--enable-frei0r" if build.with? "frei0r"
args << "--enable-libgsm" if build.with? "libgsm"
args << "--enable-libmodplug" if build.with? "libmodplug"
args << "--enable-libopenmpt" if build.with? "libopenmpt"
args << "--enable-libsoxr" if build.with? "libsoxr"
args << "--enable-libssh" if build.with? "libssh"
args << "--enable-librist" if build.with? "librist"
args << "--enable-librsvg" if build.with? "librsvg"
args << "--enable-libvidstab" if build.with? "libvidstab"
if build.with? "libvmaf"
args << "--enable-version3"
args << "--enable-libvmaf"
end
if build.with? "opencore-amr"
args << "--enable-version3"
args << "--enable-libopencore-amrnb"
args << "--enable-libopencore-amrwb"
end
args << "--enable-liboapv" if build.with? "openapv"
args << "--enable-libopenh264" if build.with? "openh264"
args << "--enable-libopenjpeg" if build.with? "openjpeg"
args << "--enable-libopenvino" if build.with? "openvino"
args << "--enable-libplacebo" if build.with? "libplacebo"
args << "--enable-libqrencode" if build.with? "qrencode"
args << "--enable-librav1e" if build.with? "rav1e"
args << "--enable-librtmp" if build.with? "rtmpdump"
args << "--enable-librubberband" if build.with? "rubberband"
args << "--enable-libspeex" if build.with? "speex"
args << "--enable-libsrt" if build.with? "srt"
args << "--enable-libtensorflow" if build.with? "tensorflow"
args << "--enable-libtesseract" if build.with? "tesseract"
args << "--enable-libtwolame" if build.with? "two-lame"
if build.with? "openssl@3"
args << "--enable-nonfree"
args << "--enable-openssl"
end
args << "--enable-libwebp" if build.with? "webp"
args << "--enable-libxml2" if build.with? "libxml2"
args << "--enable-whisper" if build.with? "whisper.cpp"
args << "--enable-libxvid" if build.with? "xvid"
args << "--enable-libzimg" if build.with? "zimg"
args << "--enable-libzmq" if build.with? "zeromq"
if build.with? "zvbi"
ENV.prepend_path "PKG_CONFIG_PATH", formula_opt_lib("zvbi")/"pkgconfig"
args << "--enable-libzvbi"
end
system "./configure", *args
system "make", "install"
system "make", "alltools"
bin.install (buildpath/"tools").children.select { |f| f.file? && f.executable? }
pkgshare.install buildpath/"tools/python"
end
test do
# Create a 5 second test MP4
mp4out = testpath/"video.mp4"
system bin/"ffmpeg", "-filter_complex", "testsrc=rate=1:duration=5", mp4out
assert_match(/Duration: 00:00:05\.00,.*Video: h264/m, shell_output("#{bin}/ffprobe -hide_banner #{mp4out} 2>&1"))
# Re-encode it in HEVC/Matroska
mkvout = testpath/"video.mkv"
system bin/"ffmpeg", "-i", mp4out, "-c:v", "hevc", mkvout
assert_match(/Duration: 00:00:05\.00,.*Video: hevc/m, shell_output("#{bin}/ffprobe -hide_banner #{mkvout} 2>&1"))
end
end
__END__
--- a/libavcodec/liboapvenc.c
+++ b/libavcodec/liboapvenc.c
@@ -509,7 +509,14 @@
}
/* create metadata handler */
+#if OAPV_VER_APISET >= 1
+ {
+ oapvm_cdesc_t mcdesc = { 0 };
+ apv->mid = oapvm_create(&mcdesc, &ret);
+ }
+#else
apv->mid = oapvm_create(&ret);
+#endif
if (apv->mid == NULL || OAPV_FAILED(ret)) {
av_log(avctx, AV_LOG_ERROR, "cannot create OAPV metadata handler\n");
return AVERROR_EXTERNAL;