Revision 17d37fe7
chunker_streamer/chunker_streamer.c | ||
---|---|---|
540 | 540 |
//a raw uncompressed video picture |
541 | 541 |
AVFrame *pFrame1 = NULL; |
542 | 542 |
|
543 |
AVFormatContext *pFormatCtx; |
|
543 |
AVFormatContext *pFormatCtx = NULL;
|
|
544 | 544 |
AVCodecContext *pCodecCtx = NULL ,*aCodecCtxEnc = NULL ,*aCodecCtx = NULL; |
545 | 545 |
AVCodec *pCodec = NULL ,*aCodec = NULL ,*aCodecEnc = NULL; |
546 | 546 |
AVPacket packet; |
... | ... | |
708 | 708 |
av_register_all(); |
709 | 709 |
|
710 | 710 |
// Open input file |
711 |
if(av_open_input_file(&pFormatCtx, av_input, NULL, 0, NULL) != 0) { |
|
712 |
fprintf(stdout, "INIT: Couldn't open video file. Exiting.\n"); |
|
713 |
exit(-1); |
|
711 |
if (!pFormatCtx) { // do not reopen if it is already open after a restart |
|
712 |
if (av_open_input_file(&pFormatCtx, av_input, NULL, 0, NULL) != 0) { |
|
713 |
fprintf(stderr, "INIT: Couldn't open video file. Exiting.\n"); |
|
714 |
exit(-1); |
|
715 |
} |
|
714 | 716 |
} |
715 | 717 |
|
716 | 718 |
// Retrieve stream information |
717 | 719 |
if(av_find_stream_info(pFormatCtx) < 0) { |
718 |
fprintf(stdout, "INIT: Couldn't find stream information. Exiting.\n");
|
|
720 |
fprintf(stderr, "INIT: Couldn't find stream information. Exiting.\n");
|
|
719 | 721 |
exit(-1); |
720 | 722 |
} |
721 | 723 |
|
... | ... | |
733 | 735 |
} |
734 | 736 |
|
735 | 737 |
if(videoStream==-1 || audioStream==-1) { // TODO: refine to work with 1 or the other |
736 |
fprintf(stdout, "INIT: Didn't find audio and video streams. Exiting.\n");
|
|
738 |
fprintf(stderr, "INIT: Didn't find audio and video streams. Exiting.\n");
|
|
737 | 739 |
exit(-1); |
738 | 740 |
} |
739 | 741 |
|
... | ... | |
1337 | 1339 |
} |
1338 | 1340 |
|
1339 | 1341 |
// Close the video file |
1340 |
av_close_input_file(pFormatCtx); |
|
1342 |
if (strcmp(av_input, "/dev/stdin") != 0) { //TODO: implement better check for stdin |
|
1343 |
av_close_input_file(pFormatCtx); |
|
1344 |
pFormatCtx = NULL; |
|
1345 |
} |
|
1341 | 1346 |
|
1342 | 1347 |
if(LOOP_MODE) { |
1343 | 1348 |
//we want video to continue, but the av_read_frame stopped |
Also available in: Unified diff