fftools: reject negative -t durations

Reject negative recording durations for input and output -t before they reach streamcopy or trim handling. Keep -t 0 accepted.

Signed-off-by: 张永鹏 <roc63@outlook.com>
(cherry picked from commit 629a5b4b0f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
张永鹏 authored and Michael Niedermayer committed 2026-09-19 14:27:18 +02:00
1 parent 2560bec4ed
commit da37798dfd
3 files changed
+24

No files matched your search

+5
View File
@@ -1929,6 +1929,11 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
}
}
if (recording_time != INT64_MAX && recording_time < 0) {
av_log(d, AV_LOG_ERROR, "-t value must be non-negative; aborting.\n");
return AVERROR(EINVAL);
}
if (o->format) {
if (!(file_iformat = av_find_input_format(o->format))) {
av_log(d, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
+5
View File
@@ -3377,6 +3377,11 @@ int of_open(const OptionsContext *o, const char *filename, Scheduler *sch)
}
}
if (recording_time != INT64_MAX && recording_time < 0) {
av_log(mux, AV_LOG_ERROR, "-t value must be non-negative; aborting.\n");
return AVERROR(EINVAL);
}
of->recording_time = recording_time;
of->start_time = o->start_time;
+14
View File
@@ -267,6 +267,20 @@ fate-ffmpeg-streamcopy-t: CMD = ffmpeg
-c copy -f null -t 1 -
FATE_FFMPEG-$(call REMUX, RAWVIDEO, NULL_MUXER) += fate-ffmpeg-streamcopy-t
fate-ffmpeg-negative-t: tests/data/vsynth1.yuv
fate-ffmpeg-negative-t: CMP = null
fate-ffmpeg-negative-t: CMD = ffmpeg \
-stream_loop -1 -f rawvideo -s 352x288 -pix_fmt yuv420p -i $(TARGET_PATH)/tests/data/vsynth1.yuv \
-c copy -f null -t -1 -; test $$? -ne 0
FATE_FFMPEG-$(call REMUX, RAWVIDEO, NULL_MUXER) += fate-ffmpeg-negative-t
fate-ffmpeg-negative-input-t: tests/data/vsynth1.yuv
fate-ffmpeg-negative-input-t: CMP = null
fate-ffmpeg-negative-input-t: CMD = ffmpeg \
-stream_loop -1 -f rawvideo -s 352x288 -pix_fmt yuv420p -t -1 -i $(TARGET_PATH)/tests/data/vsynth1.yuv \
-c copy -f null -; test $$? -ne 0
FATE_FFMPEG-$(call REMUX, RAWVIDEO, NULL_MUXER) += fate-ffmpeg-negative-input-t
# Test loopback decoding and passing the output to a complex graph.
fate-ffmpeg-loopback-decoding: tests/data/vsynth1.yuv
fate-ffmpeg-loopback-decoding: CMD = transcode \