mirror of
https://github.com/horgh/videostreamer.git
synced 2025-09-26 20:41:31 +08:00
Log error when writing frame fails
Also add some log output for when the number of clients change, and when we open the input. Looking at debugging for issue #2.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user