for (i = 0; i < nb_output_files; i++) {
OutputFile *of = output_files[i];
AVFormatContext *s = of->ctx;
- if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
- avio_close(s->pb);
+ if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
+ avio_closep(&s->pb);
avformat_free_context(s);
av_dict_free(&of->opts);
if (vstats_file)
fclose(vstats_file);
- av_free(vstats_filename);
+ av_freep(&vstats_filename);
av_freep(&input_streams);
av_freep(&input_files);
avio_flush(progress_avio);
av_bprint_finalize(&buf_script, NULL);
if (is_last_report) {
- avio_close(progress_avio);
- progress_avio = NULL;
+ avio_closep(&progress_avio);
}
}
{
char sdp[16384];
int i;
+ int j;
+ AVIOContext *sdp_pb;
AVFormatContext **avc = av_malloc_array(nb_output_files, sizeof(*avc));
if (!avc)
exit_program(1);
- for (i = 0; i < nb_output_files; i++)
- avc[i] = output_files[i]->ctx;
+ for (i = 0, j = 0; i < nb_output_files; i++) {
+ if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) {
+ avc[j] = output_files[i]->ctx;
+ j++;
+ }
+ }
+
+ av_sdp_create(avc, j, sdp, sizeof(sdp));
+
+ if (!sdp_filename) {
+ printf("SDP:\n%s\n", sdp);
+ fflush(stdout);
+ } else {
+ if (avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL) < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename);
+ } else {
+ avio_printf(sdp_pb, "SDP:\n%s", sdp);
+ avio_closep(&sdp_pb);
+ av_freep(&sdp_filename);
+ }
+ }
- av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));
- printf("SDP:\n%s\n", sdp);
- fflush(stdout);
av_freep(&avc);
}
AVFormatContext *oc;
OutputStream *ost;
InputStream *ist;
- char error[1024];
+ char error[1024] = {0};
int want_sdp = 1;
for (i = 0; i < nb_filtergraphs; i++) {
return ret;
}
- if (want_sdp) {
+ if (sdp_filename || want_sdp) {
print_sdp();
}