Compare commits

..

3 Commits

Author SHA1 Message Date
Romain Beauxis c75ada5040 ffplay: print new metadata 2025-11-22 18:38:40 +00:00
Anders Rein 32f73138f5 fate/filter-audio: Added test for aselect 2025-11-22 18:36:41 +00:00
Anders Rein 7411e902da avfilter/f_select: Added activate for aselect
During migration to the activation filter API the aselect filter was
accidentally turned into a no-op filter.
2025-11-22 18:36:41 +00:00
6 changed files with 75 additions and 1 deletions

View File

@ -1613,3 +1613,28 @@ int check_avoptions(AVDictionary *m)
return 0;
}
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level)
{
const AVDictionaryEntry *tag = NULL;
if (!m)
return;
av_log(ctx, log_level, "%s%s:\n", indent, name);
while ((tag = av_dict_iterate(m, tag))) {
const char *p = tag->value;
av_log(ctx, log_level, "%s %-16s: ", indent, tag->key);
while (*p) {
size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
p += len;
if (*p == 0xd) av_log(ctx, log_level, " ");
if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
if (*p) p++;
}
av_log(ctx, log_level, "\n");
}
}

View File

@ -549,4 +549,12 @@ int check_avoptions(AVDictionary *m);
int cmdutils_isalnum(char c);
/**
* This does the same as libavformat/dump.c corresponding function
* and should probably be kept in sync when the other one changes.
*/
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level);
#endif /* FFTOOLS_CMDUTILS_H */

View File

@ -2843,6 +2843,7 @@ static int read_thread(void *arg)
int st_index[AVMEDIA_TYPE_NB];
AVPacket *pkt = NULL;
int64_t stream_start_time;
char metadata_description[96];
int pkt_in_play_range = 0;
const AVDictionaryEntry *t;
SDL_mutex *wait_mutex = SDL_CreateMutex();
@ -2950,8 +2951,10 @@ static int read_thread(void *arg)
is->realtime = is_realtime(ic);
if (show_status)
if (show_status) {
fprintf(stderr, "\x1b[2K\r");
av_dump_format(ic, 0, is->filename, 0);
}
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
@ -2960,6 +2963,9 @@ static int read_thread(void *arg)
if (type >= 0 && wanted_stream_spec[type] && st_index[type] == -1)
if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0)
st_index[type] = i;
// Clear all pre-existing metadata update flags to avoid printing
// initial metadata as update.
st->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
}
for (i = 0; i < AVMEDIA_TYPE_NB; i++) {
if (wanted_stream_spec[i] && st_index[i] == -1) {
@ -3128,6 +3134,19 @@ static int read_thread(void *arg)
} else {
is->eof = 0;
}
if (show_status && ic->streams[pkt->stream_index]->event_flags &
AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
fprintf(stderr, "\x1b[2K\r");
snprintf(metadata_description,
sizeof(metadata_description),
"\r New metadata for stream %d",
pkt->stream_index);
dump_dictionary(NULL, ic->streams[pkt->stream_index]->metadata,
metadata_description, " ", AV_LOG_INFO);
}
ic->streams[pkt->stream_index]->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
/* check if packet is in play range specified by user, then queue, otherwise discard */
stream_start_time = ic->streams[pkt->stream_index]->start_time;
pkt_ts = pkt->pts == AV_NOPTS_VALUE ? pkt->dts : pkt->pts;

View File

@ -504,6 +504,7 @@ const FFFilter ff_af_aselect = {
.p.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
.init = aselect_init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(SelectContext),
FILTER_INPUTS(avfilter_af_aselect_inputs),
};

View File

@ -259,6 +259,11 @@ fate-filter-aresample: CMD = pcm -analyzeduration 10000000 -i $(SRC) -af aresamp
fate-filter-aresample: CMP = oneoff
fate-filter-aresample: REF = $(SAMPLES)/nellymoser/nellymoser-discont.pcm
FATE_AFILTER-$(call FILTERDEMDECENCMUX, ASELECT, WAV, PCM_S16LE, PCM_S16LE, WAV) += fate-filter-aselect
fate-filter-aselect: tests/data/asynth-44100-2.wav
fate-filter-aselect: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
fate-filter-aselect: CMD = framecrc -i $(SRC) -af "aselect=gte(t\,1)*lt(t\,2)"
FATE_ATRIM += fate-filter-atrim-duration
fate-filter-atrim-duration: CMD = framecrc -i $(SRC) -af atrim=start=0.1:duration=0.01
FATE_ATRIM += fate-filter-atrim-mixed

View File

@ -0,0 +1,16 @@
#tb 0: 1/44100
#media_type 0: audio
#codec_id 0: pcm_s16le
#sample_rate 0: 44100
#channel_layout_name 0: stereo
0, 45056, 45056, 4096, 16384, 0xe92bd835
0, 49152, 49152, 4096, 16384, 0x1126dca3
0, 53248, 53248, 4096, 16384, 0x9647edcf
0, 57344, 57344, 4096, 16384, 0x5cc345aa
0, 61440, 61440, 4096, 16384, 0x19d7bd51
0, 65536, 65536, 4096, 16384, 0x19eccef7
0, 69632, 69632, 4096, 16384, 0x4b68eeed
0, 73728, 73728, 4096, 16384, 0x0b3d1bfc
0, 77824, 77824, 4096, 16384, 0xe9b2e069
0, 81920, 81920, 4096, 16384, 0xcaa5590e
0, 86016, 86016, 4096, 16384, 0x47d0b227