diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index ebf3c397934b5d79c7b4d763b13830bdc353f66a..82227feef5859217155d986602be595e1049e313 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -177,7 +177,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int
     MpegTSSectionFilter *sec;
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "Filter: pid=0x%x\n", pid);
+    av_log(ts->stream, AV_LOG_DEBUG, "Filter: pid=0x%x\n", pid);
 #endif
     if (pid >= NB_PID_MAX || ts->pids[pid])
         return NULL;
@@ -372,7 +372,7 @@ static MpegTSService *new_service(MpegTSContext *ts, int sid,
     MpegTSService *service;
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "new_service: "
+    av_log(ts->stream, AV_LOG_DEBUG, "new_service: "
            "sid=0x%04x provider='%s' name='%s'\n",
            sid, provider_name, name);
 #endif
@@ -400,7 +400,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
     char language[4];
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "PMT: len %i\n", section_len);
+    av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len);
     av_hex_dump(stdout, (uint8_t *)section, section_len);
 #endif
     p_end = section + section_len - 4;
@@ -408,7 +408,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
     if (parse_section_header(h, &p, p_end) < 0)
         return;
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n",
+    av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n",
            h->id, h->sec_num, h->last_sec_num);
 #endif
     if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) )
@@ -419,7 +419,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
         return;
     ts->pcr_pid = pcr_pid;
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid);
+    av_log(ts->stream, AV_LOG_DEBUG, "pcr_pid=0x%x\n", pcr_pid);
 #endif
     program_info_length = get16(&p, p_end) & 0xfff;
     if (program_info_length < 0)
@@ -460,7 +460,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
             if (desc_end > desc_list_end)
                 break;
 #ifdef DEBUG_SI
-            av_log(NULL, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
+            av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
                    desc_tag, desc_len);
 #endif
             switch(desc_tag) {
@@ -491,7 +491,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
         p = desc_list_end;
 
 #ifdef DEBUG_SI
-        av_log(NULL, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n",
+        av_log(ts->stream, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n",
                stream_type, pid);
 #endif
 
@@ -543,7 +543,7 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len)
     int sid, pmt_pid;
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "PAT:\n");
+    av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n");
     av_hex_dump(stdout, (uint8_t *)section, section_len);
 #endif
     p_end = section + section_len - 4;
@@ -561,7 +561,7 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len)
         if (pmt_pid < 0)
             break;
 #ifdef DEBUG_SI
-        av_log(NULL, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
+        av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
 #endif
         if (sid == 0x0000) {
             /* NIT info */
@@ -592,7 +592,7 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len)
     char buf[256];
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "PAT:\n");
+    av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n");
     av_hex_dump(stdout, (uint8_t *)section, section_len);
 #endif
     p_end = section + section_len - 4;
@@ -610,7 +610,7 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len)
         if (pmt_pid < 0)
             break;
 #ifdef DEBUG_SI
-        av_log(NULL, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
+        av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
 #endif
         if (sid == 0x0000) {
             /* NIT info */
@@ -653,7 +653,7 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len)
     char *name, *provider_name;
 
 #ifdef DEBUG_SI
-    av_log(NULL, AV_LOG_DEBUG, "SDT:\n");
+    av_log(ts->stream, AV_LOG_DEBUG, "SDT:\n");
     av_hex_dump(stdout, (uint8_t *)section, section_len);
 #endif
 
@@ -691,7 +691,7 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len)
             if (desc_end > desc_list_end)
                 break;
 #ifdef DEBUG_SI
-            av_log(NULL, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
+            av_log(ts->stream, AV_LOG_DEBUG, "tag: 0x%02x len=%d\n",
                    desc_tag, desc_len);
 #endif
             switch(desc_tag) {
@@ -1254,7 +1254,7 @@ goto_auto_guess:
                 service = ts->services[i];
                 sid = service->sid;
 #ifdef DEBUG_SI
-                av_log(NULL, AV_LOG_DEBUG, "tuning to '%s'\n", service->name);
+                av_log(ts->stream, AV_LOG_DEBUG, "tuning to '%s'\n", service->name);
 #endif
 
                 /* now find the info for the first service if we found any,
@@ -1278,7 +1278,7 @@ goto_auto_guess:
             }
 
 #ifdef DEBUG_SI
-            av_log(NULL, AV_LOG_DEBUG, "tuning done\n");
+            av_log(ts->stream, AV_LOG_DEBUG, "tuning done\n");
 #endif
         }
         s->ctx_flags |= AVFMTCTX_NOHEADER;
@@ -1329,7 +1329,7 @@ goto_auto_guess:
         st->codec->bit_rate = s->bit_rate;
         st->start_time = ts->cur_pcr;
 #if 0
-        av_log(NULL, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n",
+        av_log(ts->stream, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n",
                st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
 #endif
     }