1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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:
Simon Thelen 2014-12-25 22:56:06 +01:00 committed by Michael Niedermayer
parent c263102298
commit cc63da1223
3 changed files with 35 additions and 6 deletions

View File

@ -2270,16 +2270,34 @@ static void print_sdp(void)
{
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, nb_output_files, sdp, sizeof(sdp));
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_close(sdp_pb);
av_free(sdp_filename);
}
}
av_freep(&avc);
}
@ -3122,7 +3140,7 @@ static int transcode_init(void)
return ret;
}
if (want_sdp) {
if (sdp_filename || want_sdp) {
print_sdp();
}

View File

@ -470,6 +470,7 @@ extern FilterGraph **filtergraphs;
extern int nb_filtergraphs;
extern char *vstats_filename;
extern char *sdp_filename;
extern float audio_drift_threshold;
extern float dts_delta_threshold;

View File

@ -77,6 +77,7 @@ const HWAccel hwaccels[] = {
};
char *vstats_filename;
char *sdp_filename;
float audio_drift_threshold = 0.1;
float dts_delta_threshold = 10;
@ -381,6 +382,13 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg)
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.
* @param arg metadata string to parse
@ -3070,6 +3078,8 @@ const OptionDef options[] = {
"set the initial demux-decode delay", "seconds" },
{ "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_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) },
"A comma-separated list of bitstream filters", "bitstream_filters" },