arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.35k stars 3.51k forks source link

Recording issues (keyframes) #99

Open adi- opened 11 years ago

adi- commented 11 years ago

Found a small "bug" which can later arise to a huge problem. I found that sometimes rtmp-module records stream not from the keyframe in video stream. This is not a problem for most players, but for Flash player it is – video and audio can be desync.

Problem is probably caused by recording an audio stream when a video keyframe was ommited. This can be seen as a black screen for even a few seconds at the biggining of the video while audio is already playing. In that case flash player plays audio and doesnt wait for a first video keyframe to be displayed at proper time (in sync). It plays video stream instantly occuring in video/audio desync.

Question is: Can rtmp-module start recording to file from full keyframe?

adi- commented 11 years ago

Video is encoded to h264 by Flash Player itself.

adi- commented 11 years ago

Looking further into this is, I suspect that flv is not well formed. There are occasions, when video and audio tracks start with different timecode.

Difference is probably a value between audio start and nearest recorded keyframe from video stream.

Converting such a file into mp4 results in successfull file encoding, but avconv outputs "multiple edit list entries" message. Most video players have no problem with playing that file with 100% audio/video sync, but Flash Player has problems displaying that.

arut commented 11 years ago

Video and audio can start with different timecodes. That does not seem to be an error. Please explain how do you reproduce the error? BTW the flv that is recorded by nginx-rtmp has no metadata. Use yamdi (or ffmpeg) to inject it. That can be a problem when displaying flv.

How do you play flv with flash player? HTTP, RTMP?

adi- commented 11 years ago

The proces is a bit complex, goes like this:

1) Record with Flash Player and rtmp-module 2) Convert flv file to mp4 using avconv (new version of ffmpeg) 3) mp4 file is played by flash player as a progressive file

Video and audio can start with different timecodes. That does not seem to be an error.

What I have noticed, Flash Player have problems with mp4 files with diffrent start timecodes for audio and video. It just plays video and audio at the beginning getting rid of the delay in timecode. It probably starts with the desynced timecodes in flv format.

Nevertheless, recording a stream via rtmp-module with audio and video in it should store an flv file with same timecodes. Am I right?

arut commented 11 years ago

3) mp4-over-nginx/http or mp4-over-nginx/rtmp?

What do you mean 'same' ? Timecodes are consistent (if that's not true, that's a bug of course, that's what I'm trying to figure out). They cannot be the same because audio and video frames come at different rates at different moment of time.

adi- commented 11 years ago

3) mp4-over-nginx/http or mp4-over-nginx/rtmp?

I dont stream mp4. Just play it progressively over nginx using mp4-over-nginx/http

adi- commented 11 years ago

After the question u asked me, I realized that I could use yours rtmp-module to stream it, not progress download it, right? Can you tell me some details about system resources used by rtmp-module? Is it compareable to normal nginx progress download?

adi- commented 11 years ago

More info on testing. Got errors as follow:

2012/12/04 12:38:09 [alert] 877#0: worker process 886 exited on signal 11 (core dumped) 2012/12/04 12:54:56 [alert] 877#0: worker process 1662 exited on signal 11 (core dumped)

2012/12/04 13:28:07 [debug] 5109#0: *2 recv() not ready (11: Resource temporarily unavailable)

Tail from log: http://d.pr/f/RbC5

arut commented 11 years ago

Thanks

rodislav commented 11 years ago

hello, I also have issues with recording, video is recorded only if I don't change setQuality() in as3 and the overall quality of the videoclip is bad..