Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtmp works but hls sometimes does not work #263

Open
dodolzg opened this issue Jan 18, 2018 · 5 comments
Open

rtmp works but hls sometimes does not work #263

dodolzg opened this issue Jan 18, 2018 · 5 comments

Comments

@dodolzg
Copy link

dodolzg commented Jan 18, 2018

Here is my config

application dev_hls_camera {
live on;
hls on;
hls_path /static/cdn/dev/hls;
hls_nested on;
hls_fragment 3s;
hls_max_fragment 6s;
hls_playlist_length 360000s;
hls_cleanup off;
drop_idle_publisher 10s;
}

Video is recorded by chrome H5 API MediaRecorder with "video/webm;codecs=h264"

ffprobe version 3.3.2 Copyright (c) 2007-2017 the FFmpeg developers
built with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
configuration: --extra-cflags=-I/usr/local/ffmpeg/include --extra-ldflags=-L/usr/local/ffmpeg/lib --pkg-config-flags=--static --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-libvpx --enable-libx264 --prefix=/usr/local/ffmpeg --extra-libs=-ldl
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, matroska,webm, from '1.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Stream #0:1(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 1360x768, SAR 1:1 DAR 85:48, 16.67 tbr, 1k tbn, 2k tbc (default)

Case 1:

/usr/local/ffmpeg/bin/ffmpeg -re -i 1.webm -acodec aac -vcodec copy -f flv rtmp://localhost:1935/dev_hls_camera/test1

rtmp works, hls works about previous 10 seconds, but there is no video after 10s (only audio).

Case 2:

/usr/local/ffmpeg/bin/ffmpeg -re -i 1.webm -acodec aac -vcodec libx264 -f flv rtmp://localhost:1935/dev_hls_camera/test2

rtmp works, hls works.

Does nginx-rtmp support "h264 (Constrained Baseline)", Or only support "libx264"?

Frames detail
Video url

@dodolzg
Copy link
Author

dodolzg commented Jan 18, 2018

Maybe there is same problem NALU

@dodolzg
Copy link
Author

dodolzg commented Jan 19, 2018

I found that it is composed of SPS+PPS+IDR after analysised the h264stream. There is no AUD NAL unit at the beginning of each PES packet. And I rechecked the spec ——

"Access Unit Delimiter (AUD). An AUD is an optional NALU that can be use to delimit frames in an elementary stream. It is not required (unless otherwise stated by the container/protocol, like TS), and is often not included in order to save space, but it can be useful to finds the start of a frame without having to fully parse each NALU."

Can nginx-rtmp-module support this case?

@dodolzg dodolzg changed the title rtmp works but hls sometimes does not work Can nginx-rtmp-module support video without AUD frame Jan 19, 2018
@dodolzg
Copy link
Author

dodolzg commented Jan 22, 2018

libx264 vs copy
libx264-1.ts is sliced by libx264 rtmp stream(-vcodec libx264), and there are SPS+PPS+IDR_SLICE frames
copy-1.ts is sliced by libx264 rtmp stream(-vcodec copy), and there are no SPS+PPS+IDR_SLICE frames

ffprobe -i copy-1.ts shows error info

[h264 @ 0x3fd7600] decode_slice_header error
[h264 @ 0x3fd7600] no frame!
[h264 @ 0x3fd7600] non-existing PPS 1 referenced
Last message repeated 1 times

@portokala123
Copy link

portokala123 commented Jan 22, 2018

Hi, did you try to add -bsf:v h264_mp4toannexb to your command?

@dodolzg
Copy link
Author

dodolzg commented Jan 22, 2018

@portokala123 same with case1, hls works about previous 10 seconds, but there is no video after 10s (only audio).

/usr/local/ffmpeg/bin/ffmpeg -re -i 1.webm -acodec aac -vcodec copy -bsf:v h264_mp4toannexb -f flv rtmp://localhost:1935/dev_hls_camera/test3

@dodolzg dodolzg changed the title Can nginx-rtmp-module support video without AUD frame rtmp works but hls sometimes does not work Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants