[FFmpeg-trac] #9525(undetermined:new): File truncate option not honored

FFmpeg trac at avcodec.org
Tue Nov 23 00:05:54 EET 2021


#9525: File truncate option not honored
-------------------------------------+-------------------------------------
             Reporter:  toots        |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:

 File protocol truncate option as described at: https://ffmpeg.org/ffmpeg-
 protocols.html#file is not honored

 How to reproduce:
 {{{
 ❯ git diff
 diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
 index 807e783422..8712685fbb 100644
 --- a/fftools/ffmpeg_opt.c
 +++ b/fftools/ffmpeg_opt.c
 @@ -2603,12 +2603,14 @@ loop_end:
          assert_file_overwrite(filename);

          /* open the file */
 +        printf("truncate: %s\n", av_dict_get(of->opts, "truncate", NULL,
 0)->value);
          if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
                                &oc->interrupt_callback,
                                &of->opts)) < 0) {
              print_error(filename, err);
              exit_program(1);
          }
 +       printf("truncate: %p\n", av_dict_get(of->opts, "truncate", NULL,
 0));
      } else if (strcmp(oc->oformat->name, "image2")==0 &&
 !av_filename_number_test(filename))
          assert_file_overwrite(filename);
 }}}

 Then:
 {{{
 ❯ ./ffmpeg -i /tmp/bla.aac -y -truncate 0 /tmp/bli.mp3
 ffmpeg version n4.4.1-1-ga614b4c8ea Copyright (c) 2000-2021 the FFmpeg
 developers
   built with Apple clang version 13.0.0 (clang-1300.0.29.3)
   configuration: --enable-libmp3lame --enable-shared --prefix=/tmp/ffmpeg
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
 [aac @ 0x15a00a200] Estimating duration from bitrate, this may be
 inaccurate
 Input #0, aac, from '/tmp/bla.aac':
   Duration: 00:00:04.91, bitrate: 82 kb/s
   Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 82 kb/s
 truncate: 0
 truncate: 0x0
 Stream mapping:
   Stream #0:0 -> #0:0 (aac (native) -> mp3 (libmp3lame))
 Press [q] to stop, [?] for help
 Output #0, mp3, to '/tmp/bli.mp3':
   Metadata:
     TSSE            : Lavf58.76.100
   Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp
     Metadata:
       encoder         : Lavc58.134.100 libmp3lame
 size=      78kB time=00:00:04.93 bitrate= 129.7kbits/s speed= 101x
 video:0kB audio:78kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.316923%
 }}}

 This keeps creating a new file, despite being confirmed that the option is
 indeed passed and consumed by the output context.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9525>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list