ffmpeg: add sdp_file option
Allow printing of sdp information to a file specified by -sdp_file This allows users to print sdp information when at least one of the outputs isn't an rtp stream. Signed-off-by: Simon Thelen <ffmpeg-dev@c-14.de> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
c263102298
commit
cc63da1223
26
ffmpeg.c
26
ffmpeg.c
@ -2270,16 +2270,34 @@ static void print_sdp(void)
|
|||||||
{
|
{
|
||||||
char sdp[16384];
|
char sdp[16384];
|
||||||
int i;
|
int i;
|
||||||
|
int j;
|
||||||
|
AVIOContext *sdp_pb;
|
||||||
AVFormatContext **avc = av_malloc_array(nb_output_files, sizeof(*avc));
|
AVFormatContext **avc = av_malloc_array(nb_output_files, sizeof(*avc));
|
||||||
|
|
||||||
if (!avc)
|
if (!avc)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
for (i = 0; i < nb_output_files; i++)
|
for (i = 0, j = 0; i < nb_output_files; i++) {
|
||||||
avc[i] = output_files[i]->ctx;
|
if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) {
|
||||||
|
avc[j] = output_files[i]->ctx;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));
|
av_sdp_create(avc, j, sdp, sizeof(sdp));
|
||||||
|
|
||||||
|
if (!sdp_filename) {
|
||||||
printf("SDP:\n%s\n", sdp);
|
printf("SDP:\n%s\n", sdp);
|
||||||
fflush(stdout);
|
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_close(sdp_pb);
|
||||||
|
av_free(sdp_filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
av_freep(&avc);
|
av_freep(&avc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3122,7 +3140,7 @@ static int transcode_init(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (want_sdp) {
|
if (sdp_filename || want_sdp) {
|
||||||
print_sdp();
|
print_sdp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
ffmpeg.h
1
ffmpeg.h
@ -470,6 +470,7 @@ extern FilterGraph **filtergraphs;
|
|||||||
extern int nb_filtergraphs;
|
extern int nb_filtergraphs;
|
||||||
|
|
||||||
extern char *vstats_filename;
|
extern char *vstats_filename;
|
||||||
|
extern char *sdp_filename;
|
||||||
|
|
||||||
extern float audio_drift_threshold;
|
extern float audio_drift_threshold;
|
||||||
extern float dts_delta_threshold;
|
extern float dts_delta_threshold;
|
||||||
|
10
ffmpeg_opt.c
10
ffmpeg_opt.c
@ -77,6 +77,7 @@ const HWAccel hwaccels[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
char *vstats_filename;
|
char *vstats_filename;
|
||||||
|
char *sdp_filename;
|
||||||
|
|
||||||
float audio_drift_threshold = 0.1;
|
float audio_drift_threshold = 0.1;
|
||||||
float dts_delta_threshold = 10;
|
float dts_delta_threshold = 10;
|
||||||
@ -381,6 +382,13 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
|
||||||
|
{
|
||||||
|
av_free(sdp_filename);
|
||||||
|
sdp_filename = av_strdup(arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a metadata specifier passed as 'arg' parameter.
|
* Parse a metadata specifier passed as 'arg' parameter.
|
||||||
* @param arg metadata string to parse
|
* @param arg metadata string to parse
|
||||||
@ -3070,6 +3078,8 @@ const OptionDef options[] = {
|
|||||||
"set the initial demux-decode delay", "seconds" },
|
"set the initial demux-decode delay", "seconds" },
|
||||||
{ "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver },
|
{ "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver },
|
||||||
"override the options from ffserver", "" },
|
"override the options from ffserver", "" },
|
||||||
|
{ "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { opt_sdp_file },
|
||||||
|
"specify a file in which to print sdp information", "file" },
|
||||||
|
|
||||||
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
|
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
|
||||||
"A comma-separated list of bitstream filters", "bitstream_filters" },
|
"A comma-separated list of bitstream filters", "bitstream_filters" },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user