]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
transcode: improve logging of packet transcode errors
authorJames Hutchinson <jahutchinson99@googlemail.com>
Fri, 16 May 2025 15:09:11 +0000 (16:09 +0100)
committerFlole <Flole998@users.noreply.github.com>
Mon, 2 Jun 2025 19:54:56 +0000 (21:54 +0200)
Improve visibility of decoding failures during transcoding by logging
the error code, a human-readable description, and the packet PTS when
the hardware decoder fails to process a packet.

Previously, these errors would silently trigger `tvh_stream_stop()` on
the affected stream, with minimal context about the underlying cause.
This made it difficult to diagnose issues such as hardware acceleration
glitches or codec-specific decode failures.

With this change, such errors are logged at warning level, and full
packet details are included if trace logging is enabled. This provides
valuable diagnostic information when investigating stream interruptions
or video dropout.

This commit does not alter transcoder behavior; errors are still
filtered or handled by other components as before. It simply makes
decoder error conditions more transparent for debugging purposes.

src/transcoding/transcode/stream.c
src/transcoding/transcode/transcoder.c

index ff10fdb598b3e731fdce6e931f64b84a5dd04d38..b2b5d20de21f73520a6b562b44b7516590b51dd2 100644 (file)
@@ -164,7 +164,7 @@ int
 tvh_stream_handle(TVHStream *self, th_pkt_t *pkt)
 {
     if (pkt->pkt_payload && self->context) {
-        return (tvh_context_handle(self->context, pkt) < 0) ? -1 : 0;
+        return tvh_context_handle(self->context, pkt);
     }
     pkt_ref_inc(pkt);
     return tvh_transcoder_deliver(self->transcoder, pkt);
index e19ccfff1c4ba4aa1cae740a248a8d1e499518ea..d3657681d93368ace26db98ffe6f0c2d947b37b1 100644 (file)
@@ -88,11 +88,23 @@ static void
 tvh_transcoder_handle(TVHTranscoder *self, th_pkt_t *pkt)
 {
     TVHStream *stream = NULL;
+    int err = 0;
+    char averr_buf[256];
 
     SLIST_FOREACH(stream, &self->streams, link) {
         if (pkt->pkt_componentindex == stream->index) {
-            if (tvh_stream_handle(stream, pkt)) {
+            err = tvh_stream_handle(stream, pkt);
+            if (err) {
                 tvh_stream_stop(stream, 0);
+                if (av_strerror(err, averr_buf, sizeof(averr_buf)) < 0) {
+                    snprintf(averr_buf, sizeof(averr_buf), "unknown error");
+                }
+                tvh_context_log(stream->context, LOG_WARNING,
+                               "failed to transcode packet at pts: %"PRId64" error %d: %s",
+                                pkt->pkt_pts, err, averr_buf);
+                if (tvhtrace_enabled()) {
+                    pkt_trace(LS_TRANSCODE, pkt, "packet details");
+                }
             }
             break;
         }