Opened 3 years ago
Last modified 2 years ago
#9525 new defect
File truncate option not honored
Reported by: | toots | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | file |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
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.
Change History (1)
comment:1 by , 2 years ago
Component: | undetermined → avformat |
---|---|
Keywords: | file added |
Version: | unspecified → git-master |
Note:
See TracTickets
for help on using tickets.
I tested 29a9b12b10c91c638205da74f3330acd06517ae8 and I have no idea how this option was ever supposed to work.
Maybe Martin or Anton want to comment?