-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
HTTP: FLV or TS stream outputs the correct header. The HTTP-FLV stream downloaded in the browser has a different FLV header than the stream pulled by ffmpeg. #939
Comments
This feeling is nonsense. Have you tried using curl? The HTTP protocol should be the same for everyone, right?
|
If you need to provide an accurate FLV header, then you need to have the stream first in order to respond to the client. This can be a bit troublesome, and some players may have issues because of this. It might be worth considering making some changes. Postpone to SRS4.
|
The root cause of this problem lies in the uncertainty of the audio and video packets sent by the encoder reaching the server, which can be divided into several scenarios:
The above special situations are generally not encountered. A detailed analysis is as follows:
SRS chooses a relatively simple approach:
|
Already solved, testing found that whether pushing the stream first or playing it first, FFMPEG can correctly respond to the FLV header.
SRS will have a marked log, indicating what kind of header it is responding to.
VLC plays normally.
|
There is another situation where there is only a Sequence Header but no data packets, in this case, it should also be considered as no stream. For example, the sequence: At this time, although there is an Audio packet, it is only a Sequence Header, so it should also be considered as having no audio stream. To avoid misjudgment when there is only
Reference: #3310
|
When converting RTC to FLV, if the FLV is played immediately after streaming, it is possible that the audio packets arrive before the video packets, resulting in the FLV header being set to For such complex situations, it is still necessary to consider supporting configuration. Even if # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if
# this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally
# it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false.
# Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts.
# default: on
drop_if_not_match on;
Reference: #3306
|
I need a fallback solution that can automatically detect potential errors in certain special scenarios, so that they can be bypassed through configuration. # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains
# these flags. Sometimes you might want to force the metadata by disable guess_has_av.
# Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts.
# Default: on
has_audio on;
# Whether stream has video track, used as default value for stream metadata, for example, FLV header contains
# these flags. Sometimes you might want to force the metadata by disable guess_has_av.
# Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts.
# Default: on
has_video on;
# Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If
# guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream
# is not regular. If not guessing, use the configured default value has_audio and has_video.
# See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460
# Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts.
# Default: on
guess_has_av on; For example, if you need to force the settings to has_audio off;
has_video on;
guess_has_av off; For example, if sometimes the packets may not arrive on time, such as RTC to FLV conversion, you can force the configuration to have audio and video streams to prevent misjudgment and packet loss. has_audio on;
has_video on;
guess_has_av off; Combining with Reference: #3311
|
Please provide an update on the situation with HTTP-TS. Both ffplay and VLC can play it correctly, but the header of mpegts.js still needs to be adjusted. For example, if the PMT provides the PID for audio and video streams, but there is no audio in the result, it will cause playback issues. Therefore, for HTTP-TS, these two configurations are still meaningful: Note that this issue with the header is the same for both H.264 and H.265.
|
My network camera does not have audio. Then I used the following command to push the camera's
rtsp
stream to thesrs
server. The configuration file used is SRS-HTTP-FLV Deployment Example.ffmpeg -i rtsp://** -vcodec libx264 -acodec aac -f flv rtmp://192.168.31.221/live/livestream
Afterwards, I used the following command on
ffmpeg
to pull thehttp-flv
stream into thesrs.flv
file.ffmpeg.exe -i http://192.168.31.221:8080/live/livestream.flv -vcodec copy -acodec copy -f flv srs.flv
Then I used
FlvParse
to examine the structure ofsrs.flv
, and it showedhas audio=0
, indicating that there was noAudio Tag
, which is consistent with the actual situation. However, on the other hand, when I directly input the linkhttp://192.168.31.221:8080/live/livestream.flv
into the browser, the downloaded file showedhas audio=1
, but still noAudio Tag
. What could be the reason for this?TRANS_BY_GPT3
The text was updated successfully, but these errors were encountered: