diff mbox series

[FFmpeg-devel,07/12] lavf/concatdec: add stream_codec directive

Message ID 20210831180739.873390-7-george@nsup.org
State Accepted
Commit 0a267bc5e20a8e7b1b79a501eed99c284ee00b4c
Headers show
Series [FFmpeg-devel,01/12] lavf/concat: refactor parsing | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Nicolas George Aug. 31, 2021, 6:07 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 doc/demuxers.texi       |  3 +++
 libavformat/concatdec.c | 13 +++++++++++++
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 87e4d0319a..6bb0574e94 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -181,6 +181,9 @@  streams is not reliable.
 Metadata for the stream.
 Can be present multiple times.
 
+@item @code{stream_codec @var{value}}
+Codec for the stream.
+
 @end table
 
 @subsection Options
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 6e91fd1826..a0d68d51cc 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -431,6 +431,7 @@  typedef enum ParseDirective {
    DIR_STREAM,
    DIR_EXSID,
    DIR_STMETA,
+   DIR_STCODEC,
 } ParseDirective;
 
 static const ParseSyntax syntax[] = {
@@ -445,6 +446,7 @@  static const ParseSyntax syntax[] = {
     [DIR_STREAM   ] = { "stream",               "",     0 },
     [DIR_EXSID    ] = { "exact_stream_id",      "i",    NEEDS_STREAM },
     [DIR_STMETA   ] = { "stream_meta",          "ks",   NEEDS_STREAM },
+    [DIR_STCODEC  ] = { "stream_codec",         "k",    NEEDS_STREAM },
 };
 
 static int concat_parse_script(AVFormatContext *avf)
@@ -596,6 +598,17 @@  static int concat_parse_script(AVFormatContext *avf)
                 FAIL(ret);
             break;
 
+        case DIR_STCODEC: {
+            const AVCodecDescriptor *codec = avcodec_descriptor_get_by_name(arg_kw[0]);
+            if (!codec) {
+                av_log(avf, AV_LOG_ERROR, "Line %d: codec '%s' not found\n", line, arg_kw[0]);
+                FAIL(AVERROR_DECODER_NOT_FOUND);
+            }
+            stream->codecpar->codec_type = codec->type;
+            stream->codecpar->codec_id = codec->id;
+            break;
+        }
+
         default:
             FAIL(AVERROR_BUG);
         }