diff mbox

[FFmpeg-devel,2/2] ffmpeg: fix -stream_loop with multiple inputs

Message ID 20180627210523.22126-2-cus@passwd.hu
State Accepted
Commit da36bcbeb78c78e493d18d3cd3ac92ea401e7031
Headers show

Commit Message

Marton Balint June 27, 2018, 9:05 p.m. UTC
The input thread need to be properly cleaned up and re-initalized before we can
start reading again in threaded mode. (threaded input reading is used when
there are mode than one input file).

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 fftools/ffmpeg.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Gyan June 28, 2018, 3:50 a.m. UTC | #1
On 28-06-2018 02:35 AM, Marton Balint wrote:
> The input thread need to be properly cleaned up and re-initalized before we can
> start reading again in threaded mode. (threaded input reading is used when
> there are mode than one input file).

Commit message should reference tickets 6121 and 7043.

Regards,
Gyan
Moritz Barsnick June 28, 2018, 12:52 p.m. UTC | #2
On Wed, Jun 27, 2018 at 23:05:23 +0200, Marton Balint wrote:
> The input thread need to be properly cleaned up and re-initalized before we can
            ^ "threads need" or "thread needs"

> start reading again in threaded mode. (threaded input reading is used when
                                         ^ Threaded
> there are mode than one input file).
        ^ is more

Moritz
Marton Balint July 2, 2018, 11:45 a.m. UTC | #3
On Thu, 28 Jun 2018, Gyan Doshi wrote:

>
>
> On 28-06-2018 02:35 AM, Marton Balint wrote:
>> The input thread need to be properly cleaned up and re-initalized before we 
> can
>> start reading again in threaded mode. (threaded input reading is used when
>> there are mode than one input file).
>
> Commit message should reference tickets 6121 and 7043.

I was not aware of the tickets, thanks. Pushed.

Regards,
Marton
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8f94c5fff2..e2cd78fcd0 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4251,7 +4251,7 @@  static int process_input(int file_index)
     AVFormatContext *is;
     InputStream *ist;
     AVPacket pkt;
-    int ret, i, j;
+    int ret, thread_ret, i, j;
     int64_t duration;
     int64_t pkt_dts;
 
@@ -4274,7 +4274,15 @@  static int process_input(int file_index)
                 avcodec_flush_buffers(avctx);
             }
         }
+#if HAVE_THREADS
+        free_input_thread(file_index);
+#endif
         ret = seek_to_start(ifile, is);
+#if HAVE_THREADS
+        thread_ret = init_input_thread(file_index);
+        if (thread_ret < 0)
+            return thread_ret;
+#endif
         if (ret < 0)
             av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");
         else