Skip to content

Commit

Permalink
[fix] worked around the buggy option -map in FFmpeg (#245).
Browse files Browse the repository at this point in the history
  • Loading branch information
winshining committed Sep 19, 2023
1 parent a13c92c commit d978ffe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ngx_rtmp_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
ngx_rtmp_core_main_conf_t *cmcf;
ngx_array_t *ch;
ngx_rtmp_handler_pt *ph;
ngx_chain_t *cl;
ngx_int_t amf_len;
size_t len, n;

static u_char func[128];
Expand Down Expand Up @@ -393,6 +395,31 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,

cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);

/*
* work around the buggy option `-map` in FFmpeg, see:
* https://trac.ffmpeg.org/ticket/10565
*/
if (in->buf->pos[0] == NGX_RTMP_AMF_NUMBER) {
cl = in;
amf_len = 0;

while (cl) {
amf_len += cl->buf->last - cl->buf->pos;
if (amf_len >= 8) {
break;
}

cl = cl->next;
}

if (amf_len < 8) {
ngx_log_error(NGX_LOG_WARN, s->connection->log, 0,
"AMF malformed: type=%d, length=%D, ignored",
NGX_RTMP_AMF_NUMBER, amf_len);
return NGX_OK;
}
}

/* read AMF func name & transaction id */
ngx_memzero(&act, sizeof(act));
act.link = in;
Expand Down

0 comments on commit d978ffe

Please sign in to comment.