Last active
April 12, 2020 15:39
-
-
Save ITotalJustice/04275c341a30e028c9eb9873cf1c242f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc main.c -lavformat -lavfilter -lavcodec -lavutil -lm -lpthread -lmbedtls -lswscale -lswresample -lz -lmbedx509 -lmbedcrypto -lmp3lame | |
/* | |
* To get the desired bug, compile ffmpeg with mbedtls support. | |
* | |
* This will loop until either no more fd can be opened, or an error happens when trying to open the url. | |
* | |
* Check the value fd after each time avformat_open_input is called. | |
* Try this with a http / local file and you will notice that fd will keep the vallue of 3 (0=stdin, 1=stout, 2=stderr) | |
* | |
* Try this same test with ffmpeg compiled with openssl, the program will behave correctly. | |
*/ | |
#include <stdio.h> //printf | |
#include <unistd.h> //open | |
#include <fcntl.h> //close | |
#include <libavformat/avformat.h> | |
// example https url. | |
#define URL "https://www.radiantmediaplayer.com/media/bbb-360p.mp4" | |
int main(int argc, char *argv[]) | |
{ | |
while (1) | |
{ | |
int fd = open(argv[0], O_RDONLY); | |
{ | |
printf("opened %d\n", fd); | |
close(fd); | |
} | |
if (fd == -1) | |
{ | |
printf("failed to open fd\n"); | |
return -1; | |
} | |
AVFormatContext *format_ctx = {0}; | |
if (avformat_open_input(&format_ctx, URL, NULL, NULL)) | |
{ | |
printf("failed to open ctx\n"); | |
return -1; | |
} | |
avformat_close_input(&format_ctx); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment