diff mbox

[FFmpeg-devel] avformat/mpegts: tag video streams with still images

Message ID 20180515182947.59629-1-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Karmani May 15, 2018, 6:29 p.m. UTC
From: Aman Gupta <aman@tmm1.net>

Parses the video_stream_descriptor (H.222 2.6.2) to look
for the still_picture_flag. This is exposed to the user
via a new AV_DISPOSITION_STILL_IMAGE.

See for example https://tmm1.s3.amazonaws.com/music-choice.ts,
whose video stream only updates every ~6 seconds.

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavformat/avformat.h | 1 +
 libavformat/dump.c     | 2 ++
 libavformat/mpegts.c   | 5 +++++
 3 files changed, 8 insertions(+)

Comments

Michael Niedermayer May 16, 2018, 8:25 p.m. UTC | #1
On Tue, May 15, 2018 at 11:29:47AM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman@tmm1.net>
> 
> Parses the video_stream_descriptor (H.222 2.6.2) to look
> for the still_picture_flag. This is exposed to the user
> via a new AV_DISPOSITION_STILL_IMAGE.
> 
> See for example https://tmm1.s3.amazonaws.com/music-choice.ts,
> whose video stream only updates every ~6 seconds.
> 
> Signed-off-by: Aman Gupta <aman@tmm1.net>
> ---
>  libavformat/avformat.h | 1 +
>  libavformat/dump.c     | 2 ++
>  libavformat/mpegts.c   | 5 +++++
>  3 files changed, 8 insertions(+)

 version needs to be updated also AV_DISPOSITION_STILL_IMAGE should be added 
 to APIChanges 
 
should be ok otherwise

thx

[...]
diff mbox

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a2fe7c6bb2..155da42ba3 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -846,6 +846,7 @@  typedef struct AVStreamInternal AVStreamInternal;
 #define AV_DISPOSITION_DESCRIPTIONS 0x20000
 #define AV_DISPOSITION_METADATA     0x40000
 #define AV_DISPOSITION_DEPENDENT    0x80000 ///< dependent audio stream (mix_type=0 in mpegts)
+#define AV_DISPOSITION_STILL_IMAGE 0x100000 ///< still images in video stream (still_picture_flag=1 in mpegts)
 
 /**
  * Options for behavior on timestamp wrap detection.
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 942e62a581..d1f98bf259 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -551,6 +551,8 @@  static void dump_stream_format(AVFormatContext *ic, int i,
         av_log(NULL, AV_LOG_INFO, " (descriptions)");
     if (st->disposition & AV_DISPOSITION_DEPENDENT)
         av_log(NULL, AV_LOG_INFO, " (dependent)");
+    if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
+        av_log(NULL, AV_LOG_INFO, " (still images)");
     av_log(NULL, AV_LOG_INFO, "\n");
 
     dump_metadata(NULL, st->metadata, "    ");
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 27b1c30a44..61df7f6cc6 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1683,6 +1683,11 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
         mpegts_find_stream_type(st, desc_tag, DESC_types);
 
     switch (desc_tag) {
+    case 0x02: /* video stream descriptor */
+        if (get8(pp, desc_end) & 0x1) {
+            st->disposition |= AV_DISPOSITION_STILL_IMAGE;
+        }
+        break;
     case 0x1E: /* SL descriptor */
         desc_es_id = get16(pp, desc_end);
         if (desc_es_id < 0)