Skip to content

Commit

Permalink
Update to FFmpeg 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Jun 26, 2024
1 parent 5407209 commit 137f095
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
6 changes: 3 additions & 3 deletions c_src/xav/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 *));
Expand Down
8 changes: 4 additions & 4 deletions c_src/xav/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 =
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 137f095

Please sign in to comment.