mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
FLV: Reset has_audio or has_video if only sequence header. (#3310)
1. Reset has_audio if got some video frames but no audio frames. 2. Reset has_video if got some audio frames but no video frames. 3. Note that audio/video frames are not sequence header.
This commit is contained in:
parent
d1bc155c8b
commit
35185cf844
2 changed files with 17 additions and 3 deletions
|
@ -8,6 +8,7 @@ The changelog for SRS.
|
|||
|
||||
## SRS 5.0 Changelog
|
||||
|
||||
* v5.0, 2022-12-13, For [#939](https://github.com/ossrs/srs/issues/939): FLV: Reset has_audio or has_video if only sequence header.
|
||||
* v5.0, 2022-12-12, Merge [#3301](https://github.com/ossrs/srs/pull/3301): DASH: Fix dash crash bug when writing file. v5.0.108
|
||||
* v5.0, 2022-12-09, Merge [#3296](https://github.com/ossrs/srs/pull/3296): SRT: Support SRT to RTMP to WebRTC. v5.0.107
|
||||
* v5.0, 2022-12-08, Merge [#3295](https://github.com/ossrs/srs/pull/3295): API: Parse fragment of URI. v5.0.106
|
||||
|
|
|
@ -307,18 +307,31 @@ srs_error_t SrsFlvStreamEncoder::write_tags(SrsSharedPtrMessage** msgs, int coun
|
|||
|
||||
// For https://github.com/ossrs/srs/issues/939
|
||||
if (!header_written) {
|
||||
bool has_video = false;
|
||||
bool has_audio = false;
|
||||
bool has_video = false; bool has_audio = false;
|
||||
int nn_video_frames = 0; int nn_audio_frames = 0;
|
||||
|
||||
for (int i = 0; i < count && (!has_video || !has_audio); i++) {
|
||||
// Note that we must iterate all messages to count the audio and video frames.
|
||||
for (int i = 0; i < count; i++) {
|
||||
SrsSharedPtrMessage* msg = msgs[i];
|
||||
if (msg->is_video()) {
|
||||
if (!SrsFlvVideo::sh(msg->payload, msg->size)) nn_video_frames++;
|
||||
has_video = true;
|
||||
} else if (msg->is_audio()) {
|
||||
if (!SrsFlvAudio::sh(msg->payload, msg->size)) nn_audio_frames++;
|
||||
has_audio = true;
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/ossrs/srs/issues/939#issuecomment-1348541733
|
||||
if (nn_video_frames > 0 && nn_audio_frames == 0) {
|
||||
if (has_audio) srs_trace("FLV: Reset has_audio for videos=%d and audios=%d", nn_video_frames, nn_audio_frames);
|
||||
has_audio = false;
|
||||
}
|
||||
if (nn_audio_frames > 0 && nn_video_frames == 0) {
|
||||
if (has_video) srs_trace("FLV: Reset has_video for videos=%d and audios=%d", nn_video_frames, nn_audio_frames);
|
||||
has_video = false;
|
||||
}
|
||||
|
||||
// Drop data if no A+V.
|
||||
if (!has_video && !has_audio) {
|
||||
return err;
|
||||
|
|
Loading…
Reference in a new issue