<div dir="ltr">I have created a small utility program based on fs_encode which will take ALL files in a directory and convert them from .WAV to .G729 and .PCMU formats.  The utility is called wavBatchEncode and takes just a directory path as an argument.<div><br></div><div>This program was working very well until I upgraded FreeSwitch. Now the program seems to hang when it tries to write out the first converted files.  I have to KILL the program from another terminal.  It leaves 2 0 byte files with .PCMU and .G729 extension.</div><div><br></div><div> I have run through a GIT bisect to find where things broke.  The last working version is Version 1.6.16 git ae1cdce 2017-04-11.</div><div>The first broken version is 38621e47bad3b63f03a0a27f6ca9ed92f6969032.</div><div><br></div><div>I then used GIT DIFF to see if I could see what had happened.  There are very few modifications between these two commits:</div><div><br></div><div><div>root@fs3:/usr/src/freeswitch.git# git diff ae1cdce 38621e47bad3b63f03a0a27f6ca9ed92f6969032</div><div>diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h</div><div>index e0a5c20..7ca027d 100644</div><div>--- a/src/include/switch_module_interfaces.h</div><div>+++ b/src/include/switch_module_interfaces.h</div><div>@@ -329,6 +329,11 @@ typedef struct switch_mm_s {</div><div>        switch_video_profile_t vprofile;</div><div>        switch_video_encode_speed_t vencspd;</div><div>        uint8_t try_hardware_encoder;</div><div>+       int scale_w;</div><div>+       int scale_h;</div><div>+       switch_img_fmt_t fmt;</div><div>+       char *auth_username;</div><div>+       char *auth_password;</div><div> } switch_mm_t;</div><div> </div><div> /*! an abstract representation of a file handle (some parameters based on compat with libsndfile) */</div><div>diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c</div><div>index b944625..4b92801 100644</div><div>--- a/src/mod/applications/mod_av/avformat.c</div><div>+++ b/src/mod/applications/mod_av/avformat.c</div><div>@@ -906,7 +906,7 @@ SWITCH_STANDARD_APP(record_av_function)</div><div>                char codec_str[256];</div><div>                const AVCodecDescriptor *desc;</div><div> </div><div>-               if (!strncmp(data, "rtmp://", 7)) {</div><div>+               if (!strncmp(data, "rtmp://", 7) || !strncmp(data, "rtsp://", 7)) {</div><div>                        fmt->video_codec = AV_CODEC_ID_H264;</div><div>                        fmt->audio_codec = AV_CODEC_ID_AAC;</div><div>                }</div><div>@@ -1694,9 +1694,20 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa</div><div>                return SWITCH_STATUS_GENERR;</div><div>        } else if (handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "youtube"))) {</div><div>                format = "flv";</div><div>-               switch_snprintf(file, sizeof(file), "rtmp://%s", path);</div><div>+</div><div>+               // meh really silly format for the user / pass libav.....</div><div>+               if (handle->mm.auth_username && handle->mm.auth_password) { </div><div>+                       switch_snprintf(file, sizeof(file), "rtmp://%s pubUser=%s pubPasswd=%s flashver=FMLE/3.0", path, handle->mm.auth_username, handle->mm.auth_password);</div><div>+               } else {</div><div>+                       switch_snprintf(file, sizeof(file), "rtmp://%s", path);</div><div>+               }</div><div>+</div><div>+       } else if (handle->stream_name && !strcasecmp(handle->stream_name, "rtsp")) {</div><div>+               format = "rtsp";</div><div>+               switch_snprintf(file, sizeof(file), "rtsp://%s", path);</div><div>        }</div><div> </div><div>+</div><div>        ext++;</div><div> </div><div>        if ((context = (av_file_context_t *)switch_core_alloc(handle->memory_pool, sizeof(av_file_context_t))) == 0) {</div><div>@@ -1783,7 +1794,7 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa</div><div>        if (fmt->video_codec != AV_CODEC_ID_NONE) {</div><div>                const AVCodecDescriptor *desc;</div><div> </div><div>-               if ((handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "youtube")))) {</div><div>+               if ((handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "rtsp") || !strcasecmp(handle->stream_name, "youtube")))) {</div><div> </div><div>                        if (fmt->video_codec != AV_CODEC_ID_H264 ) {</div><div>                                fmt->video_codec = AV_CODEC_ID_H264; // force H264</div><div>@@ -2525,6 +2536,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avformat_load)</div><div> </div><div>        supported_formats[i++] = "av";</div><div>        supported_formats[i++] = "rtmp";</div><div>+       supported_formats[i++] = "rtsp";</div><div>        supported_formats[i++] = "mp4";</div><div>        supported_formats[i++] = "m4a";</div><div>        supported_formats[i++] = "mov";</div><div>diff --git a/src/mod/applications/mod_av/mod_av.c b/src/mod/applications/mod_av/mod_av.c</div><div>index 3d3bd82..141fcdc 100644</div><div>--- a/src/mod/applications/mod_av/mod_av.c</div><div>+++ b/src/mod/applications/mod_av/mod_av.c</div><div>@@ -93,7 +93,7 @@ int mod_av_lockmgr_cb(void **m, enum AVLockOp op)</div><div> static void log_callback(void *ptr, int level, const char *fmt, va_list vl)</div><div> {</div><div>        switch_log_level_t switch_level = SWITCH_LOG_DEBUG;</div><div>-</div><div>+       return;</div><div>        /* naggy messages */</div><div>        if (level == AV_LOG_DEBUG || level == AV_LOG_WARNING) return;</div><div> </div><div>diff --git a/src/switch_core_file.c b/src/switch_core_file.c</div><div>index 46ee539..aff9442 100644</div><div>--- a/src/switch_core_file.c</div><div>+++ b/src/switch_core_file.c</div><div>@@ -177,6 +177,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,</div><div>                        fh->mm.try_hardware_encoder = switch_true(val);</div><div>                }</div><div> </div><div>+               if ((val = switch_event_get_header(fh->params, "auth_username"))) {</div><div>+                       fh->mm.auth_username = switch_core_strdup(fh->memory_pool, val);</div><div>+               }</div><div>+</div><div>+               if ((val = switch_event_get_header(fh->params, "auth_password"))) {</div><div>+                       fh->mm.auth_password = switch_core_strdup(fh->memory_pool, val);</div><div>+               }</div><div>+</div><div>                if ((val = switch_event_get_header(fh->params, "fps"))) {</div><div>                        float ftmp = atof(val);</div><div>                        if (ftmp > 0.0f) {</div><div>(END)</div><div><br></div><div><br></div><div>I believe that it is the changes in switch_core_file.c that break my utility program, but I can't be sure.  Just o add some detail, I have a Digium TCE400 card in my system which handles the G729 conversion.</div><div><br></div><div>I have no idea of what those auth_username and auth_password parameters are, but that seems to break things for me.  Any idea of what I can do to get things working again?</div><div><br></div><div>I have created a PasteBin with the code of my fs_encode derived utility: <a href="https://pastebin.freeswitch.org/view/a3d64c69" style="font-size:13px;color:rgb(0,136,204);text-decoration-line:none;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif">https://pastebin.freeswitch.org/view/a3d64c69</a>  It is pretty short.</div><div><br></div>-- <br><div class="gmail_signature">Guillermo Ruiz Camauer<br></div>
</div></div>