mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
ffmpeg_opt: add -to option to specify stop time
Signed-off-by: Jean First <jeanfirst@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
997a36238f
commit
2d7044683f
@ -256,6 +256,14 @@ libx264, and the 138th audio, which will be encoded with libvorbis.
|
|||||||
Stop writing the output after its duration reaches @var{duration}.
|
Stop writing the output after its duration reaches @var{duration}.
|
||||||
@var{duration} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form.
|
@var{duration} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form.
|
||||||
|
|
||||||
|
-to and -t are mutually exclusive and -t has priority.
|
||||||
|
|
||||||
|
@item -to @var{position} (@emph{output})
|
||||||
|
Stop writing the output at @var{position}.
|
||||||
|
@var{position} may be a number in seconds, or in @code{hh:mm:ss[.xxx]} form.
|
||||||
|
|
||||||
|
-to and -t are mutually exclusive and -t has priority.
|
||||||
|
|
||||||
@item -fs @var{limit_size} (@emph{output})
|
@item -fs @var{limit_size} (@emph{output})
|
||||||
Set the file size limit, expressed in bytes.
|
Set the file size limit, expressed in bytes.
|
||||||
|
|
||||||
|
1
ffmpeg.h
1
ffmpeg.h
@ -114,6 +114,7 @@ typedef struct OptionsContext {
|
|||||||
int chapters_input_file;
|
int chapters_input_file;
|
||||||
|
|
||||||
int64_t recording_time;
|
int64_t recording_time;
|
||||||
|
int64_t stop_time;
|
||||||
uint64_t limit_filesize;
|
uint64_t limit_filesize;
|
||||||
float mux_preload;
|
float mux_preload;
|
||||||
float mux_max_delay;
|
float mux_max_delay;
|
||||||
|
17
ffmpeg_opt.c
17
ffmpeg_opt.c
@ -145,6 +145,7 @@ static void init_options(OptionsContext *o, int is_input)
|
|||||||
" consider fixing your command line.\n");
|
" consider fixing your command line.\n");
|
||||||
} else
|
} else
|
||||||
o->recording_time = INT64_MAX;
|
o->recording_time = INT64_MAX;
|
||||||
|
o->stop_time = INT64_MAX;
|
||||||
o->mux_max_delay = 0.7;
|
o->mux_max_delay = 0.7;
|
||||||
o->limit_filesize = UINT64_MAX;
|
o->limit_filesize = UINT64_MAX;
|
||||||
o->chapters_input_file = INT_MAX;
|
o->chapters_input_file = INT_MAX;
|
||||||
@ -1656,6 +1657,20 @@ loop_end:
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o->stop_time != INT64_MAX && o->recording_time != INT64_MAX) {
|
||||||
|
o->stop_time = INT64_MAX;
|
||||||
|
av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
|
||||||
|
if (o->stop_time <= o->start_time) {
|
||||||
|
av_log(NULL, AV_LOG_WARNING, "-to value smaller than -ss; ignoring -to.\n");
|
||||||
|
o->stop_time = INT64_MAX;
|
||||||
|
} else {
|
||||||
|
o->recording_time = o->stop_time - o->start_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GROW_ARRAY(output_files, nb_output_files);
|
GROW_ARRAY(output_files, nb_output_files);
|
||||||
if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))
|
if (!(output_files[nb_output_files - 1] = av_mallocz(sizeof(*output_files[0]))))
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -2389,6 +2404,8 @@ const OptionDef options[] = {
|
|||||||
{ "t", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(recording_time) },
|
{ "t", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(recording_time) },
|
||||||
"record or transcode \"duration\" seconds of audio/video",
|
"record or transcode \"duration\" seconds of audio/video",
|
||||||
"duration" },
|
"duration" },
|
||||||
|
{ "to", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(stop_time) },
|
||||||
|
"record or transcode stop time", "time_stop" },
|
||||||
{ "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET, { .off = OFFSET(limit_filesize) },
|
{ "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET, { .off = OFFSET(limit_filesize) },
|
||||||
"set the limit file size in bytes", "limit_size" },
|
"set the limit file size in bytes", "limit_size" },
|
||||||
{ "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(start_time) },
|
{ "ss", HAS_ARG | OPT_TIME | OPT_OFFSET, { .off = OFFSET(start_time) },
|
||||||
|
Loading…
Reference in New Issue
Block a user