interrupt_callback not working

For the developers that use FFmpeg in Windows software.
Post Reply
sergman
Posts: 1
Joined: Sun Jul 16, 2017 3:50 am

interrupt_callback not working

Post by sergman » Sun Jul 16, 2017 3:58 am

Hi guys,

I am facing the problem described here:
https://trac.ffmpeg.org/ticket/2694

I used the latest version of ffmpeg.
When I open non-existing URL the call to avformat_open_input hangs and interrupt_callback is not called.

And here is the small code that demonstrates the problem (compiled in Visual Studio)

Code: Select all

#include <Windows.h>

#include <libavcodec\avcodec.h>
#include <libavformat\avformat.h>
#include <stdio.h>

static int interrupt_cb(void *ctx)
{
	printf("Interrupt callback called\n");

	return 0;
}

int main(int argc, char *argv[]) {
	AVFormatContext *pFormatCtx;

	if (argc < 2) {
		printf("Please provide a movie file\n");
		return -1;
	}
	// Register all formats and codecs
	av_register_all();
	avcodec_register_all();
	avformat_network_init();

	// Open video file
	pFormatCtx = avformat_alloc_context();
	pFormatCtx->interrupt_callback.callback = interrupt_cb;
	pFormatCtx->interrupt_callback.opaque = pFormatCtx;

	if (avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) != 0)
		return -1; // Couldn't open file

	printf("Exiting\n");
	return 0;
}
The parameter can be any non-existing URL for example:
rtmp://11.22.33.44:1935/live/channel1.sdp

Post Reply