summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorSimon Thelen <ffmpeg-dev@c-14.de>2014-12-25 22:56:06 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-12-28 02:05:34 +0100
commitcc63da1223da2ccd758d3aab815ad230d74f1a5d (patch)
tree80b0e72c05c3825723a777f606c49295dabb4b6d /ffmpeg.c
parentc263102298ecb1cb8d307d881d2f45e0f6fc16d2 (diff)
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>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 9f29eac7b1..46ea57b933 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -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, 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_sdp_create(avc, nb_output_files, sdp, sizeof(sdp));
- printf("SDP:\n%s\n", sdp);
- fflush(stdout);
av_freep(&avc);
}
@@ -3122,7 +3140,7 @@ static int transcode_init(void)
return ret;
}
- if (want_sdp) {
+ if (sdp_filename || want_sdp) {
print_sdp();
}