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>
... | ... |
@@ -2270,16 +2270,34 @@ static void print_sdp(void) |
2270 | 2270 |
{ |
2271 | 2271 |
char sdp[16384]; |
2272 | 2272 |
int i; |
2273 |
+ int j; |
|
2274 |
+ AVIOContext *sdp_pb; |
|
2273 | 2275 |
AVFormatContext **avc = av_malloc_array(nb_output_files, sizeof(*avc)); |
2274 | 2276 |
|
2275 | 2277 |
if (!avc) |
2276 | 2278 |
exit_program(1); |
2277 |
- for (i = 0; i < nb_output_files; i++) |
|
2278 |
- avc[i] = output_files[i]->ctx; |
|
2279 |
+ for (i = 0, j = 0; i < nb_output_files; i++) { |
|
2280 |
+ if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) { |
|
2281 |
+ avc[j] = output_files[i]->ctx; |
|
2282 |
+ j++; |
|
2283 |
+ } |
|
2284 |
+ } |
|
2285 |
+ |
|
2286 |
+ av_sdp_create(avc, j, sdp, sizeof(sdp)); |
|
2287 |
+ |
|
2288 |
+ if (!sdp_filename) { |
|
2289 |
+ printf("SDP:\n%s\n", sdp); |
|
2290 |
+ fflush(stdout); |
|
2291 |
+ } else { |
|
2292 |
+ if (avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL) < 0) { |
|
2293 |
+ av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); |
|
2294 |
+ } else { |
|
2295 |
+ avio_printf(sdp_pb, "SDP:\n%s", sdp); |
|
2296 |
+ avio_close(sdp_pb); |
|
2297 |
+ av_free(sdp_filename); |
|
2298 |
+ } |
|
2299 |
+ } |
|
2279 | 2300 |
|
2280 |
- av_sdp_create(avc, nb_output_files, sdp, sizeof(sdp)); |
|
2281 |
- printf("SDP:\n%s\n", sdp); |
|
2282 |
- fflush(stdout); |
|
2283 | 2301 |
av_freep(&avc); |
2284 | 2302 |
} |
2285 | 2303 |
|
... | ... |
@@ -3122,7 +3140,7 @@ static int transcode_init(void) |
3122 | 3122 |
return ret; |
3123 | 3123 |
} |
3124 | 3124 |
|
3125 |
- if (want_sdp) { |
|
3125 |
+ if (sdp_filename || want_sdp) { |
|
3126 | 3126 |
print_sdp(); |
3127 | 3127 |
} |
3128 | 3128 |
|
... | ... |
@@ -77,6 +77,7 @@ const HWAccel hwaccels[] = { |
77 | 77 |
}; |
78 | 78 |
|
79 | 79 |
char *vstats_filename; |
80 |
+char *sdp_filename; |
|
80 | 81 |
|
81 | 82 |
float audio_drift_threshold = 0.1; |
82 | 83 |
float dts_delta_threshold = 10; |
... | ... |
@@ -381,6 +382,13 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) |
381 | 381 |
return 0; |
382 | 382 |
} |
383 | 383 |
|
384 |
+static int opt_sdp_file(void *optctx, const char *opt, const char *arg) |
|
385 |
+{ |
|
386 |
+ av_free(sdp_filename); |
|
387 |
+ sdp_filename = av_strdup(arg); |
|
388 |
+ return 0; |
|
389 |
+} |
|
390 |
+ |
|
384 | 391 |
/** |
385 | 392 |
* Parse a metadata specifier passed as 'arg' parameter. |
386 | 393 |
* @param arg metadata string to parse |
... | ... |
@@ -3070,6 +3078,8 @@ const OptionDef options[] = { |
3070 | 3070 |
"set the initial demux-decode delay", "seconds" }, |
3071 | 3071 |
{ "override_ffserver", OPT_BOOL | OPT_EXPERT | OPT_OUTPUT, { &override_ffserver }, |
3072 | 3072 |
"override the options from ffserver", "" }, |
3073 |
+ { "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { opt_sdp_file }, |
|
3074 |
+ "specify a file in which to print sdp information", "file" }, |
|
3073 | 3075 |
|
3074 | 3076 |
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) }, |
3075 | 3077 |
"A comma-separated list of bitstream filters", "bitstream_filters" }, |