Browse code

Allow output formats without any streams.

Required for future metadata format.

Originally committed as revision 26100 to svn://svn.ffmpeg.org/ffmpeg/trunk

Anton Khirnov authored on 2010/12/27 16:46:44
Showing 3 changed files
... ...
@@ -1990,7 +1990,7 @@ static int transcode(AVFormatContext **output_files,
1990 1990
     nb_ostreams = 0;
1991 1991
     for(i=0;i<nb_output_files;i++) {
1992 1992
         os = output_files[i];
1993
-        if (!os->nb_streams) {
1993
+        if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {
1994 1994
             dump_format(output_files[i], i, output_files[i]->filename, 1);
1995 1995
             fprintf(stderr, "Output file #%d does not contain any stream\n", i);
1996 1996
             ret = AVERROR(EINVAL);
... ...
@@ -323,6 +323,7 @@ typedef struct AVFormatParameters {
323 323
 #define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */
324 324
 #define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
325 325
 #define AVFMT_NODIMENSIONS  0x0800 /**< Format does not need width/height */
326
+#define AVFMT_NOSTREAMS     0x1000 /**< Format does not require any streams */
326 327
 
327 328
 typedef struct AVOutputFormat {
328 329
     const char *name;
... ...
@@ -2709,7 +2709,7 @@ int av_write_header(AVFormatContext *s)
2709 2709
     AVStream *st;
2710 2710
 
2711 2711
     // some sanity checks
2712
-    if (s->nb_streams == 0) {
2712
+    if (s->nb_streams == 0 && !(s->oformat->flags & AVFMT_NOSTREAMS)) {
2713 2713
         av_log(s, AV_LOG_ERROR, "no streams\n");
2714 2714
         return AVERROR(EINVAL);
2715 2715
     }
... ...
@@ -2777,7 +2777,7 @@ int av_write_header(AVFormatContext *s)
2777 2777
 #endif
2778 2778
 
2779 2779
     /* set muxer identification string */
2780
-    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
2780
+    if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
2781 2781
         av_metadata_set2(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
2782 2782
     }
2783 2783