[FFmpeg-devel] -async

Clément Bœsch ubitux at gmail.com
Sat May 19 20:11:50 CEST 2012


On Sat, May 19, 2012 at 07:59:24PM +0200, Michael Niedermayer wrote:
> Hi everyone
> 
> async is finally back. The new implementation is different from both
> our old and libavs.
> I sadly couldnt just take libavs as it
> 1. it didnt work in ffmpeg for unknown reasons
> 2. it needs a seperate resampler meaning half speed and
> 3. twice the quality loss
> these would have been steps backward from ffmpegs previous -async
> 
> our new async is implemented completely in libswresample which means
> its also trivially available to all other projects that use
> libswresample. Just pass timestamps into swr and the user can via
> AVOptions configure swr to do the ts sync compensation as he prefers.
> -async X is also turned into an appropriate filter injection by
> ffmpeg.c
> 

Nice. What's going to happen to asyncts filter? is it still required?

Also, some documentation updates on the aresample filter (in
doc/filters.texi) would be very welcome :)

BTW, do you mind the attached patch? (the macro might need some
improvement if we really want to print the user argument)

Thanks!

-- 
Clément B.
-------------- next part --------------
From be42cdbe487e676d21b7d1c4e58c8e94c21fa3d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Sat, 19 May 2012 20:08:25 +0200
Subject: [PATCH] ffmpeg: use AUTO_INSERT_FILTER() for -async option.

---
 ffmpeg.c |   32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 860dad7..85d6ea9 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -867,29 +867,6 @@ static int configure_audio_filters(FilterGraph *fg, AVFilterContext **in_filter,
         *out_filter = format;
     }
 
-    if (audio_sync_method > 0) {
-        AVFilterContext *aswr;
-        char args[256] = {0};
-
-        av_strlcatf(args, sizeof(args), "min_comp=0.001:min_hard_comp=%f", audio_drift_threshold);
-
-        if (audio_sync_method > 1)
-            av_strlcatf(args, sizeof(args), ":max_soft_comp=%f", audio_sync_method/(double)icodec->sample_rate);
-
-        av_log(NULL, AV_LOG_INFO, "-async %d is forwarded to lavfi similarly to -af aresample=%s\n", audio_sync_method, args);
-
-        ret = avfilter_graph_create_filter(&aswr, avfilter_get_by_name("aresample"),
-                                           "aresample", args, NULL, fg->graph);
-        if (ret < 0)
-            return ret;
-
-        ret = avfilter_link(*in_filter, 0, aswr, 0);
-        if (ret < 0)
-            return ret;
-
-        *in_filter = aswr;
-    }
-
 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do {                 \
     AVFilterContext *filt_ctx;                                              \
                                                                             \
@@ -909,6 +886,15 @@ static int configure_audio_filters(FilterGraph *fg, AVFilterContext **in_filter,
     *in_filter = filt_ctx;                                                  \
 } while (0)
 
+    if (audio_sync_method > 0) {
+        char args[256] = {0};
+
+        av_strlcatf(args, sizeof(args), "min_comp=0.001:min_hard_comp=%f", audio_drift_threshold);
+        if (audio_sync_method > 1)
+            av_strlcatf(args, sizeof(args), ":max_soft_comp=%f", audio_sync_method/(double)icodec->sample_rate);
+        AUTO_INSERT_FILTER("-async", "aresample", args);
+    }
+
     if (ost->audio_channels_mapped) {
         int i;
         AVBPrint pan_buf;
-- 
1.7.10.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120519/38b6a545/attachment.asc>


More information about the ffmpeg-devel mailing list