[FFmpeg-devel] [PATCH 3/3] avformat/rtsp: add satip_raw flag to receive raw mpegts stream
Aman Karmani
ffmpeg at tmm1.net
Tue Dec 22 02:36:00 EET 2020
From: Aman Karmani <aman at tmm1.net>
This can be used to receive the raw mpegts stream from a SAT>IP server, by letting avformat handle the RTSP/RTP/UDP negotiation and setup, but then simply passing the MP2T stream through instead of demuxing it further.
For example, this command would demux/remux the mpegts stream:
ffmpeg -i 'satip://192.168.1.99:554/?src=1&freq=12188&pol=h&ro=0.35&msys=dvbs&mtype=qpsk&plts=off&sr=27500&fec=34&pids=0,17,18,167,136,47,71' -map 0 -c copy -f mpegts -y remux.ts
Whereas this command would simply save the original stream with the original PIDs and PAT/PMT/etc:
ffmpeg -rtsp_flags satip_raw -i 'satip://192.168.1.99:554/?src=1&freq=12188&pol=h&ro=0.35&msys=dvbs&mtype=qpsk&plts=off&sr=27500&fec=34&pids=0,17,18,167,136,47,71' -map 0 -c copy -f mpegtsraw -y raw.ts
Signed-off-by: Aman Karmani <aman at tmm1.net>
---
libavformat/rtsp.c | 6 +++++-
libavformat/rtsp.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 4a863dbac3..d3864c0c67 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -89,6 +89,7 @@ const AVOption ff_rtsp_options[] = {
RTSP_FLAG_OPTS("rtsp_flags", "set RTSP flags"),
{ "listen", "wait for incoming connections", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_LISTEN}, 0, 0, DEC, "rtsp_flags" },
{ "prefer_tcp", "try RTP via TCP first, if available", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_PREFER_TCP}, 0, 0, DEC|ENC, "rtsp_flags" },
+ { "satip_raw", "export raw MPEG-TS stream instead of demuxing", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_SATIP_RAW}, 0, 0, DEC, "rtsp_flags" },
RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"),
{ "min_port", "set minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
{ "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
@@ -256,6 +257,9 @@ static int init_satip_stream(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
+ const RTPDynamicProtocolHandler *handler =
+ (rt->rtsp_flags & RTSP_FLAG_SATIP_RAW) ? &ff_mpegtsraw_dynamic_handler :
+ &ff_mpegts_dynamic_handler;
rtsp_st = av_mallocz(sizeof(RTSPStream));
if (!rtsp_st)
return AVERROR(ENOMEM);
@@ -265,7 +269,7 @@ static int init_satip_stream(AVFormatContext *s)
av_strlcpy(rtsp_st->control_url,
rt->control_uri, sizeof(rtsp_st->control_url));
rtsp_st->sdp_payload_type = 33; // MP2T
- init_rtp_handler(&ff_mpegts_dynamic_handler, rtsp_st, NULL);
+ init_rtp_handler(handler, rtsp_st, NULL);
finalize_rtp_handler_init(s, rtsp_st, NULL);
return 0;
}
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index c7c3b3cb52..8a9424a1c5 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -429,6 +429,7 @@ typedef struct RTSPState {
#define RTSP_FLAG_RTCP_TO_SOURCE 0x8 /**< Send RTCP packets to the source
address of received packets. */
#define RTSP_FLAG_PREFER_TCP 0x10 /**< Try RTP via TCP first if possible. */
+#define RTSP_FLAG_SATIP_RAW 0x20 /**< Export SAT>IP stream as raw MPEG-TS */
typedef struct RTSPSource {
char addr[128]; /**< Source-specific multicast include source IP address (from SDP content) */
--
2.29.2
More information about the ffmpeg-devel
mailing list