diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index f05deb7950..54bfc96c38 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -326,6 +326,13 @@ enum AVPacketSideDataType {
      */
      AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,

+    /**
+     * Attributes found in the SDP, associated with the stream. This is 
a list
+     * of zero terminated key/value strings. There is no end marker for the
+     * list, so it is required to rely on the side data size to stop.
+     */
+    AV_PKT_DATA_SDP_ATTRIBUTES,
+
      /**
       * The number of side data types.
       * This is not part of the public API/ABI in the sense that it may
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index db78735c7a..dfc1e1c9bb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -283,6 +283,91 @@ static int init_satip_stream(AVFormatContext *s)
  }
  #endif

+
+static int sdp_add_attribute_to_stream_side_data(AVFormatContext *s, 
AVStream *st,
+                                                 const char 
*attribute_line)
+{
+    AVPacketSideData *side_data = NULL;
+    AVDictionary* attributes_dict = NULL;
+    char *key = NULL, *value = NULL;
+    int ret = 0;
+
+    /* Get the stream's attributes dictionary.
+     * If the stream has no attributes dictionary, it will be automatically
+     * created by av_dict_set. */
+    side_data = av_packet_side_data_get(st->codecpar->coded_side_data,
+                                        st->codecpar->nb_coded_side_data,
+                                        AV_PKT_DATA_SDP_ATTRIBUTES);
+    if (side_data) {
+        ret = av_packet_unpack_dictionary(side_data->data, side_data->size,
+                                          &attributes_dict);
+        if (ret) {
+            av_log(s, AV_LOG_WARNING,
+                   "Unable to unpack SDP attributes dictionary.\n");
+            return -1;
+        }
+    }
+
+    /* The attribute can either be a value attribute (key:value) or 
property
+     * attribute (just the key).
+     * Look for the ':' separator, and create the 'key' and 'value'
+     * appropriately. */
+    const char *separator = strchr(attribute_line, ':');
+    if (separator) {
+        /* Make a copy of the key and value. */
+        key = av_strndup(attribute_line, separator - attribute_line);
+        value = av_strdup(separator + 1);
+    } else {
+        /* Copy the key and create an empty value. */
+        key = av_strdup(attribute_line);
+        value = av_mallocz(1);
+    }
+    if (!key || !value) {
+        av_dict_free(&attributes_dict);
+        av_free(value);
+        av_free(key);
+        return -1;
+    }
+
+    /* Add the attribute, then pack the dictionary again. */
+    ret = av_dict_set(&attributes_dict, key, value,
+                      AV_DICT_DONT_STRDUP_KEY |
+                      AV_DICT_DONT_STRDUP_VAL |
+                      AV_DICT_MULTIKEY);
+    if (ret) {
+        av_log(s, AV_LOG_WARNING,
+               "Unable to add SDL attribute to dictionary.\n");
+        av_dict_free(&attributes_dict);
+        return -1;
+    }
+    size_t packed_dict_size = 0u;
+    uint8_t *packed_dict = av_packet_pack_dictionary(attributes_dict,
+                                                     &packed_dict_size);
+
+    /* Free the dictionary, which is not needed any longer. */
+    av_dict_free(&attributes_dict);
+
+    /* Make sure the dictionary was packet successfully, then add it 
back to
+     * the stream's side data. */
+    if (!packed_dict) {
+        av_log(s, AV_LOG_WARNING,
+               "Unable to pack SDP attributes dictionary.\n");
+        return -1;
+    }
+    side_data = av_packet_side_data_add(&st->codecpar->coded_side_data,
+                                        &st->codecpar->nb_coded_side_data,
+                                        AV_PKT_DATA_SDP_ATTRIBUTES,
+                                        packed_dict, packed_dict_size,
+                                        0);
+    if (!side_data) {
+        av_log(s, AV_LOG_WARNING,
+               "Unable to add SDP attributes side data to stream.\n");
+        return -1;
+    }
+
+    return 0;
+}
