From 137f0954681e9fe0c9e1b4540013ec85177bb353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=9Aled=C5=BA?= Date: Wed, 26 Jun 2024 20:52:00 +0200 Subject: [PATCH] Update to FFmpeg 7.0 --- README.md | 4 ++-- c_src/xav/reader.c | 6 +++--- c_src/xav/utils.c | 8 ++++---- mix.exs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index df5e422..f5e2c63 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ See an interview with FFmpeg enthusiast: https://youtu.be/9kaIXkImCAM ## Installation -Make sure you have installed FFMpeg development packages on your system +Make sure you have installed FFMpeg (ver. 7.0) development packages on your system (see [here](INSTALL.md) for installation one-liners) and add Xav to the list of your dependencies: ```elixir def deps do [ - {:xav, "~> 0.2.1"} + {:xav, "~> 0.3.0"} ] end ``` diff --git a/c_src/xav/reader.c b/c_src/xav/reader.c index e3cfc99..1e9aa0d 100644 --- a/c_src/xav/reader.c +++ b/c_src/xav/reader.c @@ -70,8 +70,8 @@ int reader_init(struct Reader *reader, char *path, size_t path_size, int device_ if (reader->media_type == AVMEDIA_TYPE_AUDIO) { reader->swr_ctx = swr_alloc(); enum AVSampleFormat out_sample_fmt = av_get_alt_sample_fmt(reader->c->sample_fmt, 0); - av_opt_set_channel_layout(reader->swr_ctx, "in_channel_layout", reader->c->channel_layout, 0); - av_opt_set_channel_layout(reader->swr_ctx, "out_channel_layout", reader->c->channel_layout, 0); + av_opt_set_chlayout(reader->swr_ctx, "in_chlayout", &reader->c->ch_layout, 0); + av_opt_set_chlayout(reader->swr_ctx, "out_chlayout", &reader->c->ch_layout, 0); av_opt_set_int(reader->swr_ctx, "in_sample_rate", reader->c->sample_rate, 0); av_opt_set_int(reader->swr_ctx, "out_sample_rate", reader->c->sample_rate, 0); av_opt_set_sample_fmt(reader->swr_ctx, "in_sample_fmt", reader->c->sample_fmt, 0); @@ -203,7 +203,7 @@ int reader_next_frame(struct Reader *reader) { } else if (reader->media_type == AVMEDIA_TYPE_AUDIO && av_sample_fmt_is_planar(reader->frame->format) == 1) { // convert to interleaved - int channels = reader->frame->channels; + int channels = reader->frame->ch_layout.nb_channels; int samples_per_channel = reader->frame->nb_samples; // reader->frame_data = (uint8_t**)malloc(sizeof(uint8_t *)); diff --git a/c_src/xav/utils.c b/c_src/xav/utils.c index 7859553..9cf8621 100644 --- a/c_src/xav/utils.c +++ b/c_src/xav/utils.c @@ -13,8 +13,8 @@ void print_supported_pix_fmts(AVCodec *codec) { int init_swr_ctx_from_frame(SwrContext **swr_ctx, AVFrame *frame) { *swr_ctx = swr_alloc(); enum AVSampleFormat out_sample_fmt = av_get_alt_sample_fmt(frame->format, 0); - av_opt_set_channel_layout(*swr_ctx, "in_channel_layout", frame->channel_layout, 0); - av_opt_set_channel_layout(*swr_ctx, "out_channel_layout", frame->channel_layout, 0); + av_opt_set_chlayout(*swr_ctx, "in_chlayout", &frame->ch_layout, 0); + av_opt_set_chlayout(*swr_ctx, "out_chlayout", &frame->ch_layout, 0); av_opt_set_int(*swr_ctx, "in_sample_rate", frame->sample_rate, 0); av_opt_set_int(*swr_ctx, "out_sample_rate", frame->sample_rate, 0); av_opt_set_sample_fmt(*swr_ctx, "in_sample_fmt", frame->format, 0); @@ -37,7 +37,7 @@ void convert_to_rgb(AVFrame *src_frame, uint8_t *dst_data[], int dst_linesize[]) int convert_to_interleaved(SwrContext *swr_ctx, AVFrame *src_frame, uint8_t **dst_data, int *dst_linesize) { - int channels = src_frame->channels; + int channels = src_frame->ch_layout.nb_channels; int samples_per_channel = src_frame->nb_samples; int ret = @@ -76,7 +76,7 @@ ERL_NIF_TERM xav_nif_audio_frame_to_term(ErlNifEnv *env, AVFrame *frame, unsigne ERL_NIF_TERM data_term; size_t unpadded_linesize = - frame->nb_samples * av_get_bytes_per_sample(frame->format) * frame->channels; + frame->nb_samples * av_get_bytes_per_sample(frame->format) * frame->ch_layout.nb_channels; unsigned char *ptr = enif_make_new_binary(env, unpadded_linesize, &data_term); memcpy(ptr, data[0], unpadded_linesize); diff --git a/mix.exs b/mix.exs index 65a1cdd..22606d2 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule Xav.MixProject do def project do [ app: :xav, - version: "0.2.1", + version: "0.3.0", elixir: "~> 1.14", start_permanent: Mix.env() == :prod, description: "Elixir media library built on top of FFmpeg",