Trim part of an Mp3 file in C++
extern “C” { #include <libavformat/avformat.h> } void trimMp3(const char* input, const char* output, int start, int duration) { av_register_all(); AVFormatContext *inCtx = nullptr, *outCtx = nullptr; avformat_open_input(&inCtx, input, nullptr, nullptr); avformat_find_stream_info(inCtx, nullptr); avformat_alloc_output_context2(&outCtx, nullptr, nullptr, output); int audioIndex = av_find_best_stream(inCtx, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0); AVStream *inStream = inCtx->streams[audioIndex]; AVStream *outStream = avformat_new_stream(outCtx, nullptr); avcodec_parameters_copy(outStream->codecpar, …