1 /*
2 * Chromaprint fingerprinting muxer
3 * Copyright (c) 2015 rcombs
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
26 #include <chromaprint.h>
27
28 #define CPR_VERSION_INT AV_VERSION_INT(CHROMAPRINT_VERSION_MAJOR, \
29 CHROMAPRINT_VERSION_MINOR, \
30 CHROMAPRINT_VERSION_PATCH)
31
37
43 #if CPR_VERSION_INT >= AV_VERSION_INT(1, 4, 0)
44 ChromaprintContext *
ctx;
45 #else
46 ChromaprintContext
ctx;
47 #endif
49
51 {
53
56 chromaprint_free(cpr->
ctx);
58 }
59 }
60
62 {
65
69
73 }
74
76 #if CPR_VERSION_INT >= AV_VERSION_INT(0, 7, 0)
78 av_log(
s,
AV_LOG_ERROR,
"Failed to set silence threshold. Setting silence_threshold requires -algorithm 3 option.\n");
80 }
81 #else
83 "version 0.7.0 or later.\n");
85 #endif
86 }
87
88 if (
s->nb_streams != 1) {
91 }
92
94
98 }
99
103 }
104
108 }
109
110 return 0;
111 }
112
114 {
117 }
118
120 {
126
127 if (!chromaprint_finish(cpr->
ctx)) {
130 }
131
132 if (!chromaprint_get_raw_fingerprint(cpr->
ctx, (uint32_t **)&
fp, &
size)) {
135 }
136
140 break;
143 if (!chromaprint_encode_fingerprint(
fp,
size, cpr->
algorithm, &enc_fp, &enc_size,
147 }
149 break;
150 }
151
155 chromaprint_dealloc(
fp);
156 if (enc_fp)
157 chromaprint_dealloc(enc_fp);
159 }
160
161 #define OFFSET(x) offsetof(ChromaprintMuxContext, x)
162 #define FLAGS AV_OPT_FLAG_ENCODING_PARAM
164 {
"silence_threshold",
"threshold for detecting silence",
OFFSET(silence_threshold),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 32767,
FLAGS },
165 {
"algorithm",
"version of the fingerprint algorithm",
OFFSET(algorithm),
AV_OPT_TYPE_INT, { .i64 = CHROMAPRINT_ALGORITHM_DEFAULT }, CHROMAPRINT_ALGORITHM_TEST1, INT_MAX,
FLAGS },
171 };
172
178 };
179
181 .
p.
name =
"chromaprint",
191 };