diff mbox

[FFmpeg-devel] ffmpeg: explicitly write headers for files with no streams

Message ID 20161007134614.2116-1-h.leppkes@gmail.com
State Accepted
Headers show

Commit Message

Hendrik Leppkes Oct. 7, 2016, 1:46 p.m. UTC
Recent changes to ffmpeg.c tied output file init to stream init, which broke
stream-less files, specifically ffmetadata output.
---
 ffmpeg.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Hendrik Leppkes Oct. 7, 2016, 1:52 p.m. UTC | #1
On Fri, Oct 7, 2016 at 3:46 PM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> Recent changes to ffmpeg.c tied output file init to stream init, which broke
> stream-less files, specifically ffmetadata output.
> ---
>  ffmpeg.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 454e193..b3e23ef 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -3460,6 +3460,16 @@ static int transcode_init(void)
>          }
>      }
>
> +    /* write headers for files with no streams */
> +    for (i = 0; i < nb_output_files; i++) {
> +        oc = output_files[i]->ctx;
> +        if (oc->oformat->flags & AVFMT_NOSTREAMS) {

Locally added a check here that nb_streams is actually 0, because
AVFMT_NOSTREAMS doesn't forbid having streams, just allows zero.
Once it has a single stream, its initialized with the stream.

> +            ret = check_init_output_file(output_files[i], i);
> +            if (ret < 0)
> +                goto dump_format;
> +        }
> +    }
> +
>   dump_format:
>      /* dump the stream mapping */
>      av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
> --
> 2.10.0.windows.1
>
Michael Niedermayer Oct. 7, 2016, 2 p.m. UTC | #2
On Fri, Oct 07, 2016 at 03:46:14PM +0200, Hendrik Leppkes wrote:
> Recent changes to ffmpeg.c tied output file init to stream init, which broke
> stream-less files, specifically ffmetadata output.
> ---
>  ffmpeg.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

LGTM

thx

[...]
Hendrik Leppkes Oct. 7, 2016, 2:08 p.m. UTC | #3
On Fri, Oct 7, 2016 at 4:00 PM, Michael Niedermayer
<michael@niedermayer.cc> wrote:
> On Fri, Oct 07, 2016 at 03:46:14PM +0200, Hendrik Leppkes wrote:
>> Recent changes to ffmpeg.c tied output file init to stream init, which broke
>> stream-less files, specifically ffmetadata output.
>> ---
>>  ffmpeg.c | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>
> LGTM
>

Applied, since it fixes a recent regression.

- Hendrik
diff mbox

Patch

diff --git a/ffmpeg.c b/ffmpeg.c
index 454e193..b3e23ef 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3460,6 +3460,16 @@  static int transcode_init(void)
         }
     }
 
+    /* write headers for files with no streams */
+    for (i = 0; i < nb_output_files; i++) {
+        oc = output_files[i]->ctx;
+        if (oc->oformat->flags & AVFMT_NOSTREAMS) {
+            ret = check_init_output_file(output_files[i], i);
+            if (ret < 0)
+                goto dump_format;
+        }
+    }
+
  dump_format:
     /* dump the stream mapping */
     av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");