Of course, I forgot the attachments. ________________________________ From: Libav-user <[email protected]> on behalf of Coulter, Sam via Libav-user <[email protected]> Sent: Wednesday, November 6, 2019 5:07 PM To: [email protected] Cc: Coulter, Sam Subject: [Libav-user] Trouble with afade filter on Android x86 Device
Hello All, I am having some trouble getting an af_afade filter to work on in a native (c++) android program. Swapping out the afade filter for a "volume" filter allows me to change the frame volume as expected, but no configuration of the afade filter seems to modify the frame at all. I am cross compiling ffmpeg from linux with the configure options shown in ffmpeg_configure.sh, setting up the filter graph as shown in ffmpeg_filterSetup.c, and passing the frame in as shown in ffmpeg_useFilter.c (After having received it from an AVCodecContext object, and before resampling it with "swr_convert_frame"). Would really appreciate any help anyone can provide! Thanks, Sam
auto frame = inputFrame.get();
auto error = av_buffersrc_add_frame_flags(m_filterInput, frame, AV_BUFFERSRC_FLAG_PUSH);
if (error < 0) {
std::cout << "add_frame_error\n";
}
error = av_buffersink_get_frame(m_filterOutput, frame);
if (error < 0) {
std::cout << "get frame error\n";
}
m_filterGraph = std::shared_ptr<AVFilterGraph>(avfilter_graph_alloc(), AVFilterGraphDeleter());
if (!m_filterGraph) {
LOG_ERROR_AND_RETURN("unable to allocate filter graph");
}
// We do not own the AVFilter objects so we don't need to free them on error or destruction.
// The AVFilterContext objects are allocated as part of the AVFilterGraph and so will be freed
// when the graph is.
// First allocated and initialize the abuffer filter which is used to buffer input to the graph
const AVFilter* abufferFilter = avfilter_get_by_name("abuffer");
if (!abufferFilter) {
LOG_ERROR_AND_RETURN("unable to find abuffer filter");
}
m_filterInput = avfilter_graph_alloc_filter(m_filterGraph.get(), abufferFilter, "abufferFilter");
if (!m_filterInput) {
LOG_ERROR_AND_RETURN("unable to allocate abuffer context");
}
std::bitset<64> bits(m_codecContext->channel_layout);
av_opt_set_int(m_filterInput, "channels", bits.count(), AV_OPT_SEARCH_CHILDREN);
char layoutBuffer[64];
av_get_channel_layout_string(layoutBuffer, sizeof(layoutBuffer), bits.count(), m_codecContext->channel_layout);
av_opt_set(m_filterInput, "channel_layout", layoutBuffer, AV_OPT_SEARCH_CHILDREN);
av_opt_set_sample_fmt(m_filterInput, "sample_fmt", m_codecContext->sample_fmt, AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(m_filterInput, "sample_rate", m_codecContext->sample_rate, AV_OPT_SEARCH_CHILDREN);
if (avfilter_init_str(m_filterInput, nullptr) < 0) {
LOG_ERROR_AND_RETURN("unable to initialize abuffer context");
}
// Next, allocate and initialize the afade filter which performs the fade
const AVFilter* afadeFilter = avfilter_get_by_name("afade");
if (!afadeFilter) {
LOG_ERROR_AND_RETURN("unable to find afade filter");
}
AVFilterContext* afadeContext = avfilter_graph_alloc_filter(m_filterGraph.get(), afadeFilter, "afadeFilter");
if (!afadeContext) {
LOG_ERROR_AND_RETURN("unable to allocate afade filter context");
}
if (avfilter_init_str(afadeContext, "duration=0.5") < 0) {
LOG_ERROR_AND_RETURN("unable to initialize afade filter context");
}
// Next allocate the buffer sink filter
const AVFilter* abuffersinkFilter = avfilter_get_by_name("abuffersink");
if (!abuffersinkFilter) {
LOG_ERROR_AND_RETURN("unable to find abuffersink filter");
}
m_filterOutput = avfilter_graph_alloc_filter(m_filterGraph.get(), abuffersinkFilter, "abuffersinkFilter");
if (!m_filterOutput) {
LOG_ERROR_AND_RETURN("unable to allocate abuffersink context");
}
if (avfilter_init_str(m_filterOutput, nullptr) < 0) {
LOG_ERROR_AND_RETURN("unable to initialize abuffersink context");
}
// Connect all filters in the graph
if (avfilter_link(m_filterInput, 0, afadeContext, 0) < 0 ||
avfilter_link(afadeContext, 0, m_filterOutput, 0) < 0) {
LOG_ERROR_AND_RETURN("unable to link filter graph");
}
if (avfilter_graph_config(m_filterGraph.get(), NULL) < 0) {
LOG_ERROR_AND_RETURN("unable to configure filter graph");
}
ffmpeg_configure.sh
Description: ffmpeg_configure.sh
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
