diff mbox

[FFmpeg-devel] avformat/mpegtsenc:

Message ID 5F93D188-F455-4DA5-8110-0358B4CD398A@mac.com
State New
Headers show

Commit Message

Oliver Collyer March 6, 2019, 3 p.m. UTC
Hi

I needed to be able to use the write_data_type callback when reading data from the mpegts muxer, to make my application aware of key frames in the data so I added support. I used the matroska implementation as a reference.

If this is accepted, I will format this as a proper patch after feedback.

Regards

Oliver

Comments

Oliver Collyer March 7, 2019, 8:34 p.m. UTC | #1
> Hi
> 
> I needed to be able to use the write_data_type callback when reading data from the mpegts muxer, to make my application aware of key frames in the data so I added support. I used the matroska implementation as a reference.
> 
> If this is accepted, I will format this as a proper patch after feedback.
> 
> Regards
> 
> Oliver
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea225c6..e5d1a64b4c 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
>         mpegts_write_flush(s);
>         return 1;
>     } else {
> +        if (s->pb && s->pb->write_data_type) {
> +            AVStream *st = s->streams[pkt->stream_index];
> +            avio_write_marker(s->pb,
> +                av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
> +                (pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
> +        }
>         return mpegts_write_packet_internal(s, pkt);
>     }
> }
> 

So I've created a patch for this.
Oliver Collyer March 8, 2019, 10:46 a.m. UTC | #2
[Apols for sending this again, but I realised the subject didn't describe the change, which was unhelpful)

This patch makes it possible to do stuff like write a custom in-memory TS segmenter, which was what I needed it for.

> Hi
> 
> I needed to be able to use the write_data_type callback when reading data from the mpegts muxer, to make my application aware of key frames in the data so I added support. I used the matroska implementation as a reference.
> 
> If this is accepted, I will format this as a proper patch after feedback.
> 
> Regards
> 
> Oliver
> 
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index fc0ea225c6..e5d1a64b4c 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
>        mpegts_write_flush(s);
>        return 1;
>    } else {
> +        if (s->pb && s->pb->write_data_type) {
> +            AVStream *st = s->streams[pkt->stream_index];
> +            avio_write_marker(s->pb,
> +                av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
> +                (pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
> +        }
>        return mpegts_write_packet_internal(s, pkt);
>    }
> }
> 

So I've created a patch for this.
Oliver Collyer March 15, 2019, 3:43 p.m. UTC | #3
> 
> This patch makes it possible to do stuff like write a custom in-memory TS segmenter, which was what I needed it for.
> 
>> Hi
>> 
>> I needed to be able to use the write_data_type callback when reading data from the mpegts muxer, to make my application aware of key frames in the data so I added support. I used the matroska implementation as a reference.
>> 
>> If this is accepted, I will format this as a proper patch after feedback.
>> 
>> Regards
>> 
>> Oliver
>> 
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index fc0ea225c6..e5d1a64b4c 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
>>       mpegts_write_flush(s);
>>       return 1;
>>   } else {
>> +        if (s->pb && s->pb->write_data_type) {
>> +            AVStream *st = s->streams[pkt->stream_index];
>> +            avio_write_marker(s->pb,
>> +                av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
>> +                (pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
>> +        }
>>       return mpegts_write_packet_internal(s, pkt);
>>   }
>> }
>> 
> 
> So I've created a patch for this.
> 
> <0001-mpegtsenc-added-support-for-the-write_data_type-call.patch>

And how about this one, can this be pushed too?

I'm unsure of the etiquette with a ping message like this, sorry if I offend anyone, but it's been over a week and I guess that means it was forgotten?
Diego Felix de Souza via ffmpeg-devel March 22, 2019, 10:48 a.m. UTC | #4
> 
> This patch makes it possible to do stuff like write a custom in-memory TS segmenter, which was what I needed it for.
> 
>> Hi
>> 
>> I needed to be able to use the write_data_type callback when reading data from the mpegts muxer, to make my application aware of key frames in the data so I added support. I used the matroska implementation as a reference.
>> 
>> If this is accepted, I will format this as a proper patch after feedback.
>> 
>> Regards
>> 
>> Oliver
>> 
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index fc0ea225c6..e5d1a64b4c 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -1815,6 +1815,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
>>      mpegts_write_flush(s);
>>      return 1;
>>  } else {
>> +        if (s->pb && s->pb->write_data_type) {
>> +            AVStream *st = s->streams[pkt->stream_index];
>> +            avio_write_marker(s->pb,
>> +                av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
>> +                (pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
>> +        }
>>      return mpegts_write_packet_internal(s, pkt);
>>  }
>> }
>> 
> 
> So I've created a patch for this.
> 
> <0001-mpegtsenc-added-support-for-the-write_data_type-call.patch>

Ping, for this really trivial patch.
diff mbox

Patch

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..e5d1a64b4c 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1815,6 +1815,12 @@  static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
         mpegts_write_flush(s);
         return 1;
     } else {
+        if (s->pb && s->pb->write_data_type) {
+            AVStream *st = s->streams[pkt->stream_index];
+            avio_write_marker(s->pb,
+                av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q),
+                (pkt->flags & AV_PKT_FLAG_KEY) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AVIO_DATA_MARKER_SYNC_POINT : AVIO_DATA_MARKER_BOUNDARY_POINT);
+        }
         return mpegts_write_packet_internal(s, pkt);
     }
 }