1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/rtsp: add satip_raw flag to receive raw mpegts stream

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:

    SATIP_URL='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'
    ffmpeg -i $SATIP_URL -map 0 -c copy -f mpegts -y remux.ts

Whereas this command will simply write out the raw stream, with
the original PAT/PMT/PIDs intact:

    ffmpeg -rtsp_flags satip_raw -i $SATIP_URL -map 0 -c copy -f data -y raw.ts

Signed-off-by: Aman Karmani <aman@tmm1.net>
This commit is contained in:
Aman Karmani 2020-12-21 15:53:55 -08:00
parent 98b76bb11f
commit d20f059fb9
2 changed files with 15 additions and 3 deletions

View File

@ -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 },
@ -265,9 +266,19 @@ static int init_satip_stream(AVFormatContext *s)
av_strlcpy(rtsp_st->control_url,
rt->control_uri, sizeof(rtsp_st->control_url));
rtsp_st->stream_index = -1;
init_rtp_handler(&ff_mpegts_dynamic_handler, rtsp_st, NULL);
finalize_rtp_handler_init(s, rtsp_st, NULL);
if (rt->rtsp_flags & RTSP_FLAG_SATIP_RAW) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->id = rt->nb_rtsp_streams - 1;
rtsp_st->stream_index = st->index;
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
} else {
rtsp_st->stream_index = -1;
init_rtp_handler(&ff_mpegts_dynamic_handler, rtsp_st, NULL);
finalize_rtp_handler_init(s, rtsp_st, NULL);
}
return 0;
}

View File

@ -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) */