diff --git a/videostreamer.c b/videostreamer.c index 6ba171e..a037c3c 100644 --- a/videostreamer.c +++ b/videostreamer.c @@ -436,8 +436,12 @@ vs_write_packet(const struct VSInput * const input, // av_interleaved_write_frame() works too, but I don't think it is needed. // Using av_write_frame() skips buffering. - if (av_write_frame(output->format_ctx, pkt) != 0) { - printf("unable to write frame\n"); + const int write_res = av_write_frame(output->format_ctx, pkt); + if (write_res != 0) { + char error_buf[256]; + memset(error_buf, 0, 256); + av_strerror(write_res, error_buf, 256); + printf("unable to write frame: %s\n", error_buf); return -1; } diff --git a/videostreamer.go b/videostreamer.go index 71be170..ce2f422 100644 --- a/videostreamer.go +++ b/videostreamer.go @@ -143,6 +143,7 @@ func encoder(inputFormat, inputURL string, verbose bool, for { // If there are no clients, then block waiting for one. if len(clients) == 0 { + log.Printf("encoder: Waiting for clients...") client := <-clientChan log.Printf("encoder: New client") clients = append(clients, client) @@ -152,7 +153,13 @@ func encoder(inputFormat, inputURL string, verbose bool, // There is at least one client. // Get any new clients, but don't block. + clientCountBefore := len(clients) clients = acceptClients(clientChan, clients) + clientCountAfter := len(clients) + + if clientCountBefore != clientCountAfter { + log.Printf("encoder: %d clients", clientCountAfter) + } // Open the input if it is not open yet. if input == nil { @@ -184,7 +191,13 @@ func encoder(inputFormat, inputURL string, verbose bool, } // Write the packet to all clients. + clientCountBefore = len(clients) clients = writePacketToClients(input, &pkt, clients, verbose) + clientCountAfter = len(clients) + + if clientCountBefore != clientCountAfter { + log.Printf("encoder: %d clients", clientCountAfter) + } C.av_packet_unref(&pkt) @@ -192,6 +205,7 @@ func encoder(inputFormat, inputURL string, verbose bool, if len(clients) == 0 { C.vs_destroy_input(input) input = nil + log.Printf("encoder: Closed input") } } }