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

Fix bug for HTTP, failed to download large file recorded with 2GB #2780 #2781

Closed
wants to merge 1 commit into from

Conversation

CodeflowSun
Copy link

@CodeflowSun CodeflowSun commented Dec 10, 2021

I work with Java and have no knowledge of C++. Based on my personal understanding, I made some fixes to #2780. If there are any inappropriate modifications, please forgive me. Just close this PR if necessary. Currently, based on my judgment, most of the modifications should be fine, but I feel that there is a certain level of risk in one line of code modification.

if ((err = copy(w, fs, r, (int)left)) != srs_success)   >> if ((err = copy(w, fs, r, left)) != srs_success)

There are two concerns regarding this modification:

  1. It is uncertain whether the stl copy supports passing long as an argument.
  2. It is unclear whether this modification will have adverse effects on memory when dealing with large files.

TRANS_BY_GPT3

@winlinvip winlinvip linked an issue Dec 11, 2021 that may be closed by this pull request
@winlinvip winlinvip changed the title fix https://github.com/ossrs/srs/issues/2780 Fix bug for HTTP, 2GB录制的大文件下载失败 #2780 Dec 11, 2021
@winlinvip
Copy link
Member

winlinvip commented Dec 11, 2021

Thank you for the PR, but it's indeed not quite suitable. No worries, we will find time to take a look.

TRANS_BY_GPT3

@@ -137,7 +137,7 @@ srs_error_t SrsVodStream::serve_flv_stream(ISrsHttpResponseWriter* w, ISrsHttpMe
return err;
}

srs_error_t SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int start, int end)
srs_error_t SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int start, long end)
Copy link
Member

@chundonglinlin chundonglinlin Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more appropriate to use int64_t instead of long.

TRANS_BY_GPT3

@@ -180,8 +180,8 @@ srs_error_t SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMe
fs->seek2(start);

// send data
if ((err = copy(w, fs, r, (int)left)) != srs_success) {
return srs_error_wrap(err, "read mp4=%s size=%d", fullpath.c_str(), (int)left);
if ((err = copy(w, fs, r, left)) != srs_success) {
Copy link
Member

@chundonglinlin chundonglinlin Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only the left variable type is changed to int64_t, but the declaration of copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, ISrsHttpMessage* r, int64_t size) should also be modified to int64_t, and the variable types inside the copy function should remain consistent, otherwise the modification will not be achieved.

TRANS_BY_GPT3

Copy link
Member

@winlinvip winlinvip Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please create a new PR? @CodeflowSun mentioned that he works with Java, so it may not be suitable for him to continue modifying the C++ code. Please make sure to maintain the markdown structure.

@CodeflowSun has already identified the problem, which is already very good. Please make sure to maintain the markdown structure.

Thank you very much to both of you. 🙏 Please make sure to maintain the markdown structure.

TRANS_BY_GPT3

Copy link
Member

@chundonglinlin chundonglinlin Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will create a new PR to address this issue. Thanks to @CodeflowSun for helping to identify the problem 🙏.

TRANS_BY_GPT3

Copy link
Member

@chundonglinlin chundonglinlin Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When modifying the distribution of mp4 files, it was discovered that flv files also have this issue. offset is defined as int type. If you use ffplay http://127.0.0.1:8080/test.flv, the flv file will keep buffering after exceeding 2GB. After making modifications, it was found that flv does not support range operations. Summarizing the above observations:

  1. When distributing mp4 and flv files, if they exceed 2GB, there will be overflow or connection timeout issues.
  2. When distributing flv files, VLC player will exit or fail when dragging.

TRANS_BY_GPT3

Copy link
Member

@chundonglinlin chundonglinlin Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When modifying the distribution of mp4 files, it was found that flv also had this problem. offset is defined as int type. If ffplay http://127.0.0.1:8080/test.flv is used, the flv file will freeze indefinitely after exceeding 2GB. After modification, it was found that range operation is not supported for flv. Summarize the above phenomena: 1. When distributing mp4 and flv files, if they exceed 2GB, overflow or connection timeout may occur. 2. When distributing flv files, VLC will exit or fail when dragging during playback.

Phenomenon 2, when dragging to play flv, does not support the range parameter. Is it necessary? When distributing flv files using nginx, it supports range operation.

TRANS_BY_GPT3

Copy link

@ellenWei11 ellenWei11 Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I would like to ask if the drag-and-drop feature for FLV files has been resolved?

TRANS_BY_GPT3

Copy link

@ellenWei11 ellenWei11 Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compiled nginx with the following configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_mp4_module --with-http_flv_module.
At the same time, I used yamdi to add keyframe information to the recorded videos.
yamdi -i source.flv -o dest.flv //input video output video
Then, I can use nginx to play the recorded files and enable dragging and dropping.
So, the problem should be that the DVR recording does not include keyframe information, which is why dragging and dropping playback is not possible.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

Fix by #2809

Thanks again @CodeflowSun @chundonglinlin

@winlinvip winlinvip closed this Dec 25, 2021
@winlinvip winlinvip changed the title Fix bug for HTTP, 2GB录制的大文件下载失败 #2780 Fix bug for HTTP, failed to download large file recorded with 2GB #2780 Jul 29, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP: Failed to download large file recorded with 2GB.
5 participants