diff mbox

[FFmpeg-devel,2/2] ffmpeg: do not finish output streams manually on eof even if no input is provided

Message ID 20180318190909.31057-2-cus@passwd.hu
State New
Headers show

Commit Message

Marton Balint March 18, 2018, 7:09 p.m. UTC
The generic code should be able to finish the streams just fine initializing
and flushing the filters and codecs properly.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 fftools/ffmpeg.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

Comments

Michael Niedermayer March 19, 2018, 12:08 a.m. UTC | #1
On Sun, Mar 18, 2018 at 08:09:09PM +0100, Marton Balint wrote:
> The generic code should be able to finish the streams just fine initializing
> and flushing the filters and codecs properly.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  fftools/ffmpeg.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)

This changes:
./ffmpeg -i ~/tickets/3015/test_video -filter:a apad -f flv -vcodec flv -ar 22050 -shortest test.flv

Didnt investigate beyond a quick look which didnt tell me anything.
If the change is good this could be turned into a fate test

[...]
Marton Balint March 19, 2018, 8:56 p.m. UTC | #2
On Mon, 19 Mar 2018, Michael Niedermayer wrote:

> On Sun, Mar 18, 2018 at 08:09:09PM +0100, Marton Balint wrote:
>> The generic code should be able to finish the streams just fine initializing
>> and flushing the filters and codecs properly.
>>
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  fftools/ffmpeg.c | 12 +-----------
>>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> This changes:
> ./ffmpeg -i ~/tickets/3015/test_video -filter:a apad -f flv -vcodec flv -ar 22050 -shortest test.flv
>
> Didnt investigate beyond a quick look which didnt tell me anything.
> If the change is good this could be turned into a fate test

Change seems good, before the change no audio stream was written, after 
the change an audio stream is written with the same length as the video, 
so the command line (using -shortest with apad filter) actually starting 
to make sense.

Regards,
Marton
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8876c99560..5399397c6e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2186,7 +2186,7 @@  static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
 
 static int ifilter_send_eof(InputFilter *ifilter, int64_t pts)
 {
-    int i, j, ret;
+    int ret;
 
     ifilter->eof = 1;
 
@@ -2213,16 +2213,6 @@  static int ifilter_send_eof(InputFilter *ifilter, int64_t pts)
             av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input %d, stream %d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);
             return AVERROR_INVALIDDATA;
         }
-        for (i = 0; i < fg->nb_inputs; i++)
-            if (!fg->inputs[i]->eof)
-                break;
-        if (i == fg->nb_inputs) {
-            // All the input streams have finished without the filtergraph
-            // ever being configured.
-            // Mark the output streams as finished.
-            for (j = 0; j < fg->nb_outputs; j++)
-                finish_output_stream(fg->outputs[j]->ost);
-        }
     }
 
     return 0;