1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

fftools: move opt_timelimit from cmdutils to ffmpeg

This option is only supported by ffmpeg.
This commit is contained in:
Anton Khirnov
2022-03-09 12:16:16 +01:00
parent a545cb2b9d
commit 00da464658
2 changed files with 20 additions and 17 deletions

View File

@@ -48,10 +48,6 @@
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "cmdutils.h" #include "cmdutils.h"
#include "opt_common.h" #include "opt_common.h"
#if HAVE_SYS_RESOURCE_H
#include <sys/time.h>
#include <sys/resource.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif
@@ -798,19 +794,6 @@ do { \
return 0; return 0;
} }
int opt_timelimit(void *optctx, const char *opt, const char *arg)
{
#if HAVE_SETRLIMIT
int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
struct rlimit rl = { lim, lim + 1 };
if (setrlimit(RLIMIT_CPU, &rl))
perror("setrlimit");
#else
av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
#endif
return 0;
}
void print_error(const char *filename, int err) void print_error(const char *filename, int err)
{ {
char errbuf[128]; char errbuf[128];

View File

@@ -19,8 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "config.h"
#include <stdint.h> #include <stdint.h>
#if HAVE_SYS_RESOURCE_H
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include "ffmpeg.h" #include "ffmpeg.h"
#include "cmdutils.h" #include "cmdutils.h"
#include "opt_common.h" #include "opt_common.h"
@@ -3500,6 +3507,19 @@ static int opt_progress(void *optctx, const char *opt, const char *arg)
return 0; return 0;
} }
int opt_timelimit(void *optctx, const char *opt, const char *arg)
{
#if HAVE_SETRLIMIT
int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
struct rlimit rl = { lim, lim + 1 };
if (setrlimit(RLIMIT_CPU, &rl))
perror("setrlimit");
#else
av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
#endif
return 0;
}
#define OFFSET(x) offsetof(OptionsContext, x) #define OFFSET(x) offsetof(OptionsContext, x)
const OptionDef options[] = { const OptionDef options[] = {
/* main options */ /* main options */