Opened 6 years ago
Closed 6 years ago
#7865 closed defect (needs_more_info)
HLS_TEMP_FILE is not being set correctly
Reported by: | kamyon | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | unspecified | Keywords: | hls |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I am using ffmpeg v4.1.3 to create an hls file locally. However, there seems to be an issue with checking the temp_file flag, and I get the "Cannot use rename on non file protocol, this may lead to races and temporary partial files" error, even though the output is a local file, and not a network url.
I looked at hlsenc.c to see what the issue may be, it seems there is a potential problem when checking whether the file is temporary or not. In the hlswindow function, line 1341 checks to see if a temporary file should be used by
int use_temp_file = proto && !strcmp(proto, "file") && (s->flags & HLS_TEMP_FILE);
The first two conditions evaluate to true, as they should, but the last condition (s->flags& HLS_TEMP_FILE) evaluates to false. I think this is a bug, since the flags to check should be the hls flags, not the format context flags (i.e., the last condition should be hls->flags & HLS_TEMP_FILE).
In my code, I use
av_opt_set(pFormatCtx->priv_data, "hls_flags", "+temp_file", 0);
to try to set this flag. When I verify that it is set by
assert(av_opt_flag_is_set(pFormatCtx->priv_data, "hls_flags", "temp_file"));
I can verify that it is being correctly set. However, it is not being picked up correctly. This may also be the same issue that was raised at https://stackoverflow.com/questions/54888506/including-the-switch-hls-flags-temp-files-while-encoding-to-hls-does-nothing
As a workaround/hack, I can set pFormatCtx->flags |= (1<<11), and then everything works correctly as much as I can tell, but this is obviously not a long-term solution (1<<11 is currently not any of the documented AVFormatContext flags).
Note that the same
int use_temp_file = proto && !strcmp(proto, "file") && (s->flags & HLS_TEMP_FILE);
line or similar is used in multiple lines in hlsenc.h, so this should (if it is a bug as I suspect) be fixed in those locations as well.
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Keywords: | HLS_TEMP_FILE removed |
---|---|
Priority: | important → normal |
Resolution: | → needs_more_info |
Status: | new → closed |
Version: | 4.1 → unspecified |
Please test current FFmpeg git head and provide either an ffmpeg
command line including complete, uncut console output or code that uses FFmpeg libraries and allows to reproduce the issue.
I believe this is already fixed in master.