]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7519: auto set some values on avformat recording
authorAnthony Minessale <anthm@freeswitch.org>
Sat, 23 May 2015 01:27:14 +0000 (20:27 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:33 +0000 (12:47 -0500)
src/mod/applications/mod_av/avformat.c
src/switch_ivr_play_say.c

index f2f11d571fcb20a94779e3054060abd8816a3346..f8ff97ce6aecaad2ef455119c461451a408c4450 100644 (file)
@@ -225,6 +225,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
        switch_status_t status = SWITCH_STATUS_FALSE;
        int threads = switch_core_cpu_count();
        int buffer_bytes = 2097152; /* 2 mb */
+       int fps = 15;
 
        /* find the encoder */
        *codec = avcodec_find_encoder(codec_id);
@@ -271,13 +272,21 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
                        if (mm->vbuf) {
                                buffer_bytes = mm->vbuf;
                        }
+                       fps = mm->fps;
+
+                       if (mm->vw && mm->vh) {
+                               mst->width = mm->vw;
+                               mst->height = mm->vh;
+                       }
+
                }
 
                c->codec_id = codec_id;
-               c->bit_rate = 1000000;
+
                /* Resolution must be a multiple of two. */
                c->width    = mst->width;
                c->height   = mst->height;
+               c->bit_rate = switch_calc_bitrate(c->width, c->height, 2, fps) * 1024;
                mst->st->time_base.den = 1000;
                mst->st->time_base.num = 1;
                c->time_base.den = 1000;
@@ -297,7 +306,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
 
                if (mm) {
                        if (mm->vb) {
-                               c->bit_rate = mm->vb * 1000;
+                               c->bit_rate = mm->vb * 1024;
                        }
                        if (mm->keyint) {
                                c->gop_size = mm->keyint;
index d056399c3f796306b08c7abe459cdcc647e22fdd..76c666b6e2b84e54725bdf271d3e2131934dca34 100644 (file)
@@ -530,8 +530,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
        }
 
        if (switch_channel_test_flag(channel, CF_VIDEO)) {
+               switch_vid_params_t vid_params = { 0 };
+
                file_flags |= SWITCH_FILE_FLAG_VIDEO;
                switch_channel_set_flag_recursive(channel, CF_VIDEO_DECODED_READ);
+               fh->mm.fps = switch_core_media_get_video_fps(session);
+               switch_core_media_get_vid_params(session, &vid_params);
+               fh->mm.vw = vid_params.width;
+               fh->mm.vh = vid_params.height;
        }
 
        if (switch_core_file_open(fh, file, fh->channels, read_impl.actual_samples_per_second, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {