[FFmpeg-trac] #7865(avformat:new): HLS_TEMP_FILE is not being set correctly

FFmpeg trac at avcodec.org
Wed Apr 24 22:53:32 EEST 2019


#7865: HLS_TEMP_FILE is not being set correctly
-------------------------------------+-------------------------------------
             Reporter:  kamyon       |                     Type:  defect
               Status:  new          |                 Priority:  important
            Component:  avformat     |                  Version:  4.1
             Keywords:  hls,         |               Blocked By:
  HLS_TEMP_FILE                      |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 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.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7865>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list