From: yu.dongliang <18588496441@163.com> Date: Fri, 14 Apr 2023 12:55:21 +0000 (+0800) Subject: tmp X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=0e66741aee56c24f7b65fdf5be7e426e59218876;p=simplay.git tmp --- diff --git a/Makefile b/Makefile index b7c4948..37b2e30 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CFLAGS += -g -O3 CFLAGS += -I./ CFLAGS += `pkg-config --cflags gtk+-3.0` -LDFLAGS += -lavformat -lavcodec -lavfilter -lavutil +LDFLAGS += -lavdevice -lavformat -lavcodec -lavfilter -lavutil LDFLAGS += -lGL LDFLAGS += `pkg-config --libs gtk+-3.0` diff --git a/main.c b/main.c index 4dac9f1..7fb7d73 100644 --- a/main.c +++ b/main.c @@ -12,9 +12,12 @@ int main(int argc, char* argv[]) return -1; } - simp_filter_t* f = NULL; - simp_avio_t* in = NULL; - simp_avio_t* out = NULL; + avdevice_register_all(); + + simp_filter_t* f = NULL; + simp_avio_t* in = NULL; + simp_avio_t* out = NULL; + simp_avio_t* alsa = NULL; if (simp_avio_open(&in, "ffmpeg_input", argv[1], NULL) < 0) { scf_loge("\n"); @@ -26,6 +29,11 @@ int main(int argc, char* argv[]) return -1; } + if (simp_avio_open(&alsa, "ffmpeg_alsa", NULL, "hw:0") < 0) { + scf_loge("\n"); + return -1; + } + if (simp_filter_open(&f) < 0) { scf_loge("\n"); return -1; @@ -33,8 +41,9 @@ int main(int argc, char* argv[]) simp_filter_add_input (f, in); simp_filter_add_output(f, out); + simp_filter_add_output(f, alsa); - f->speed.num = 200; + f->speed.num = 1; f->speed.den = 1; if (simp_filter_run(f) < 0) { @@ -42,6 +51,11 @@ int main(int argc, char* argv[]) return -1; } + if (simp_avio_run(alsa) < 0) { + scf_loge("\n"); + return -1; + } + if (simp_avio_run(out) < 0) { scf_loge("\n"); return -1; diff --git a/simp.c b/simp.c index 2b8acda..5fa4a6d 100644 --- a/simp.c +++ b/simp.c @@ -2,11 +2,13 @@ extern simp_avio_ops_t simp_avio_ffmpeg_input; extern simp_avio_ops_t simp_avio_ffmpeg_output; +extern simp_avio_ops_t simp_avio_ffmpeg_alsa; static simp_avio_ops_t* avio_array[] = { &simp_avio_ffmpeg_input, &simp_avio_ffmpeg_output, + &simp_avio_ffmpeg_alsa, NULL, }; diff --git a/simp.h b/simp.h index 3cab8e7..cf706c6 100644 --- a/simp.h +++ b/simp.h @@ -6,6 +6,7 @@ #include "libavformat/avformat.h" #include "libavcodec/avcodec.h" +#include "libavdevice/avdevice.h" #include "libavutil/avutil.h" #include "libavutil/opt.h" #include "libavfilter/avfilter.h" diff --git a/simp_ffmpeg_alsa.c b/simp_ffmpeg_alsa.c index eb51552..91bca41 100644 --- a/simp_ffmpeg_alsa.c +++ b/simp_ffmpeg_alsa.c @@ -70,9 +70,13 @@ static int _audio_output_init(simp_audio_t* priv, const char* path) AVStream* s = NULL; AVCodec* c; + scf_loge("out: %p\n", out); + avformat_alloc_output_context2(&priv->ctx_out, out, NULL, path); - if (!priv->ctx_out) + if (!priv->ctx_out) { + scf_loge("\n"); return -ENOMEM; + } c = avcodec_find_encoder(priv->codec_in->codec_id); if (!c) @@ -185,12 +189,14 @@ static int _ffmpeg_alsa_open(simp_avio_t* io, const char* in, const char* out) priv->idx_out = -1; if (in) { + scf_loge("in: %s\n", in); ret = _audio_input_init(priv, in); if (ret < 0) goto error; } if (out) { + scf_loge("out: %s\n", out); ret = _audio_output_init(priv, out); if (ret < 0) goto error;