winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.71k stars 567 forks source link

[bug]使用ffmpeg推流一个mp3文件到nginx-http-flv-module生成的ts文件带视频信息,导致iphone12下播放有问题 #217

Closed ljwps closed 1 year ago

ljwps commented 2 years ago

When you meet a bug, please open the issue including a title prefixed by '[bug]' and describe it as follows: 当你碰到一个 bug,请在提出问题时以 '[bug]' 为前缀写明标题,并且像下面的内容一样描述它: [bug]使用ffmpeg推流一个mp3文件到nginx-http-flv-module生成的ts文件带视频信息(HLS模式),导致iphone12下播放有问题,虽然ts里面视频信息宽高都为0并且没有码率,但iphone12会当作视频一直等待加载,需要点击播放并且拉动滚动条才能播放。 再次使用ffmpeg将ts文件去掉视频信息后播放正常。

Expected behavior / 期望行为

m3u8可以直接播放

Actual behavior / 实际行为

m3u8不可以直接播放

OS and Nginx version / 操作系统和 Nginx 版本号

Linux version 3.10.0-1127.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) nginx-http-flv-module 1.2.9, nginx 1.21.1

Configuration file / 配置文件

Steps to reproduce the behavior / 复现问题步骤

1、启动nginx+nginx-http-flv-module 2、推流ffmpeg -re -stream_loop -1 -i i:/我的/Desktop/a.mp3 -acodec aac -f flv rtmp://192.168.5.141:9004/hls/123456 3、使用iphone12访问m3u8地址,即可复现 image 上图为第二步,点了播放按钮并且拖动滚动条后,如下图 image 虽然通过点击+拖动滚动条能播放了,但实际上iphone12还是当作一个视频在播放

chundonglinlin commented 2 years ago

hls写ts片时头里patpmt是固定的ngx_rtmp_mpegts_header,如: https://github.com/winshining/nginx-http-flv-module/blob/ddc0df9d96b4d7045782cf944e42dac585906b3c/hls/ngx_rtmp_mpegts.c#L48 你应该重新生成pmt部分的信息替换h264和aac

ljwps commented 2 years ago

hls写ts片时头里patpmt是固定的ngx_rtmp_mpegts_header,如:

https://github.com/winshining/nginx-http-flv-module/blob/ddc0df9d96b4d7045782cf944e42dac585906b3c/hls/ngx_rtmp_mpegts.c#L48

你应该重新生成pmt部分的信息替换h264和aac

感谢回复! 我看到 nginx-rtmp-module 也被提了个这个问题:https://github.com/arut/nginx-rtmp-module/issues/642 此条 issue 的回复中有人拉了分支并修复了 https://github.com/sergey-dryabzhinsky/nginx-rtmp-module nginx-http-flv-module 是否可以把这个修复合并一下,我对 C 语言的代码修改没什么经验,感谢!

winshining commented 1 year ago

Fixed. Please fetch the latest code to test.