diff --git a/libavformat/udp.c b/libavformat/udp.c
index 65c7a5549d7537760785431e761f9bd012e065d8..91b411e679a288450a6d717cc07d1c612b2c2dc6 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -62,6 +62,7 @@ typedef struct {
     int ttl;
     int buffer_size;
     int is_multicast;
+    int is_broadcast;
     int local_port;
     int reuse_socket;
     int overrun_nonfatal;
@@ -96,6 +97,7 @@ static const AVOption options[] = {
 {"localaddr", "choose local IP address", OFFSET(local_addr), AV_OPT_TYPE_STRING, {.str = ""}, 0, 0, D|E },
 {"pkt_size", "set size of UDP packets", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = 1472}, 0, INT_MAX, D|E },
 {"reuse", "explicitly allow or disallow reusing UDP sockets", OFFSET(reuse_socket), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
+{"broadcast", "explicitly allow or disallow broadcast destination", OFFSET(is_broadcast), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
 {"ttl", "set the time to live value (for multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, {.i64 = 16}, 0, INT_MAX, E },
 {"connect", "set if connect() should be called on socket", OFFSET(is_connected), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
 /* TODO 'sources', 'block' option */
@@ -602,6 +604,8 @@ static int udp_open(URLContext *h, const char *uri, int flags)
         }
         if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
             s->timeout = strtol(buf, NULL, 10);
+        if (is_output && av_find_info_tag(buf, sizeof(buf), "broadcast", p))
+            s->is_broadcast = strtol(buf, NULL, 10);
     }
     /* handling needed to support options picking from both AVOption and URL */
     s->circular_buffer_size *= 188;
@@ -642,6 +646,11 @@ static int udp_open(URLContext *h, const char *uri, int flags)
             goto fail;
     }
 
+    if (s->is_broadcast) {
+        if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), sizeof(s->is_broadcast)) != 0)
+           goto fail;
+    }
+
     /* If multicast, try binding the multicast address first, to avoid
      * receiving UDP packets from other sources aimed at the same UDP
      * port. This fails on windows. This makes sending to the same address