avconv: make output -ss insert trim/atrim filters.
authorAnton Khirnov <anton@khirnov.net>
Wed, 10 Apr 2013 13:02:01 +0000 (15:02 +0200)
committerAnton Khirnov <anton@khirnov.net>
Tue, 30 Apr 2013 10:00:55 +0000 (12:00 +0200)
This makes output -ss sample-accurate for audio and will allow further
simplication in the future.

Changelog
avconv.c
avconv_filter.c

index ca5dbac..76af6ac 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -14,7 +14,8 @@ version 10:
 - JPEG 2000 decoder
 - new asetpts filter (same as setpts, but for audio)
 - new trim and atrim filters
 - JPEG 2000 decoder
 - new asetpts filter (same as setpts, but for audio)
 - new trim and atrim filters
-- avconv -t option is now sample-accurate when transcoding audio
+- avconv -t and -ss (output-only) options are now sample-accurate when
+  transcoding audio
 
 
 version 9:
 
 
 version 9:
index 3b50f20..3b4d2f6 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -681,11 +681,6 @@ static int poll_filter(OutputStream *ost)
                               av_rescale_q(of->start_time,
                                            AV_TIME_BASE_Q,
                                            ost->st->codec->time_base);
                               av_rescale_q(of->start_time,
                                            AV_TIME_BASE_Q,
                                            ost->st->codec->time_base);
-
-        if (of->start_time && filtered_frame->pts < 0) {
-            av_frame_unref(filtered_frame);
-            return 0;
-        }
     }
 
     switch (ost->filter->filter->inputs[0]->type) {
     }
 
     switch (ost->filter->filter->inputs[0]->type) {
index 0a47c95..1d8044d 100644 (file)
@@ -183,7 +183,7 @@ static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pa
     char filter_name[128];
     int ret = 0;
 
     char filter_name[128];
     int ret = 0;
 
-    if (of->recording_time == INT64_MAX)
+    if (of->recording_time == INT64_MAX && !of->start_time)
         return 0;
 
     trim = avfilter_get_by_name(name);
         return 0;
 
     trim = avfilter_get_by_name(name);
@@ -199,8 +199,14 @@ static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pa
     if (!ctx)
         return AVERROR(ENOMEM);
 
     if (!ctx)
         return AVERROR(ENOMEM);
 
-    ret = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6,
-                            AV_OPT_SEARCH_CHILDREN);
+    if (of->recording_time != INT64_MAX) {
+        ret = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6,
+                                AV_OPT_SEARCH_CHILDREN);
+    }
+    if (ret >= 0 && of->start_time) {
+        ret = av_opt_set_double(ctx, "start", (double)of->start_time / 1e6,
+                                AV_OPT_SEARCH_CHILDREN);
+    }
     if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name);
         return ret;
     if (ret < 0) {
         av_log(ctx, AV_LOG_ERROR, "Error configuring the %s filter", name);
         return ret;