Skip to content

Commit a554d64

Browse files
committed
Busybox-like ff{mpeg,probe,server,play} multitool
Makefile changes are not implemented
1 parent c78a726 commit a554d64

File tree

6 files changed

+89
-16
lines changed

6 files changed

+89
-16
lines changed

ffmpeg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106

107107
#include "libavutil/avassert.h"
108108

109-
const char program_name[] = "ffmpeg";
110-
const int program_birth_year = 2000;
109+
// const char program_name[] = "ffmpeg";
110+
// const int program_birth_year = 2000;
111111

112112
static FILE *vstats_file;
113113

@@ -4274,7 +4274,8 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
42744274
{
42754275
}
42764276

4277-
int main(int argc, char **argv)
4277+
int main_ffmpeg(int argc, char **argv);
4278+
int main_ffmpeg(int argc, char **argv)
42784279
{
42794280
int ret;
42804281
int64_t ti;

ffmpeg_opt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2894,7 +2894,8 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
28942894
return 0;
28952895
}
28962896

2897-
void show_help_default(const char *opt, const char *arg)
2897+
void show_help_default_ffmpeg(const char *opt, const char *arg);
2898+
void show_help_default_ffmpeg(const char *opt, const char *arg)
28982899
{
28992900
/* per-file options have at least one of those set */
29002901
const int per_file = OPT_SPEC | OPT_OFFSET | OPT_PERFILE;

ffmulti.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <string.h>
2+
3+
#include "config.h"
4+
5+
const char program_name[] = "ffmulti";
6+
const int program_birth_year = 2016;
7+
8+
int main_ffmpeg(int argc, char **argv);
9+
int main_ffprobe(int argc, char **argv);
10+
int main_ffserver(int argc, char **argv);
11+
int main_ffplay(int argc, char **argv);
12+
13+
void show_help_default_ffmpeg(const char *opt, const char *arg);
14+
void show_help_default_ffserver(const char *opt, const char *arg);
15+
void show_help_default_ffprobe(const char *opt, const char *arg);
16+
void show_help_default_ffplay(const char *opt, const char *arg);
17+
void show_help_default(const char *opt, const char *arg);
18+
19+
static char tool = '\0';
20+
21+
void show_help_default(const char *opt, const char *arg)
22+
{
23+
switch(tool) {
24+
#if CONFIG_FFMPEG == 1
25+
case 'm': show_help_default_ffmpeg (opt, arg); break;
26+
#endif
27+
#if CONFIG_FFSERVER == 1
28+
case 's': show_help_default_ffserver(opt, arg); break;
29+
#endif
30+
#if CONFIG_FFPROBE == 1
31+
case 'r': show_help_default_ffprobe (opt, arg); break;
32+
#endif
33+
#if CONFIG_FFPLAY == 1
34+
case 'l': show_help_default_ffplay (opt, arg); break;
35+
#endif
36+
}
37+
}
38+
39+
int main(int argc, char **argv) {
40+
if (argc == 0 || !argv|| !argv[0]) return 127;
41+
if (0) {
42+
#if CONFIG_FFMPEG == 1
43+
} else if (strstr(argv[0], "ffmpeg")) {
44+
tool='m';
45+
return main_ffmpeg(argc, argv);
46+
#endif
47+
#if CONFIG_FFPLAY == 1
48+
} else if (strstr(argv[0], "ffplay")) {
49+
tool='l';
50+
return main_ffplay(argc, argv);
51+
#endif
52+
#if CONFIG_FFPROBE == 1
53+
} else if (strstr(argv[0], "ffprobe")) {
54+
tool='r';
55+
return main_ffprobe(argc, argv);
56+
#endif
57+
#if CONFIG_FFSERVER == 1
58+
} else if (strstr(argv[0], "ffserver")) {
59+
tool='s';
60+
return main_ffserver(argc, argv);
61+
#endif
62+
} else {
63+
return main(argc-1, argv+1);
64+
}
65+
}

ffplay.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060

6161
#include <assert.h>
6262

63-
const char program_name[] = "ffplay";
64-
const int program_birth_year = 2003;
63+
// const char program_name[] = "ffplay";
64+
// const int program_birth_year = 2003;
6565

6666
#define MAX_QUEUE_SIZE (15 * 1024 * 1024)
6767
#define MIN_FRAMES 25
@@ -3708,7 +3708,8 @@ static void show_usage(void)
37083708
av_log(NULL, AV_LOG_INFO, "\n");
37093709
}
37103710

3711-
void show_help_default(const char *opt, const char *arg)
3711+
void show_help_default_ffplay(const char *opt, const char *arg);
3712+
void show_help_default_ffplay(const char *opt, const char *arg)
37123713
{
37133714
av_log_set_callback(log_callback_help);
37143715
show_usage();
@@ -3765,7 +3766,8 @@ static int lockmgr(void **mtx, enum AVLockOp op)
37653766
}
37663767

37673768
/* Called from the main */
3768-
int main(int argc, char **argv)
3769+
int main_ffplay(int argc, char **argv);
3770+
int main_ffplay(int argc, char **argv)
37693771
{
37703772
int flags;
37713773
VideoState *is;

ffprobe.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#include "libpostproc/postprocess.h"
5050
#include "cmdutils.h"
5151

52-
const char program_name[] = "ffprobe";
53-
const int program_birth_year = 2007;
52+
// const char program_name[] = "ffprobe";
53+
// const int program_birth_year = 2007;
5454

5555
static int do_bitexact = 0;
5656
static int do_count_frames = 0;
@@ -2897,7 +2897,8 @@ static int opt_input_file_i(void *optctx, const char *opt, const char *arg)
28972897
return 0;
28982898
}
28992899

2900-
void show_help_default(const char *opt, const char *arg)
2900+
void show_help_default_ffprobe(const char *opt, const char *arg);
2901+
void show_help_default_ffprobe(const char *opt, const char *arg)
29012902
{
29022903
av_log_set_callback(log_callback_help);
29032904
show_usage();
@@ -3170,7 +3171,8 @@ static inline int check_section_show_entries(int section_id)
31703171
do_show_##varname = 1; \
31713172
} while (0)
31723173

3173-
int main(int argc, char **argv)
3174+
int main_ffprobe(int argc, char **argv);
3175+
int main_ffprobe(int argc, char **argv)
31743176
{
31753177
const Writer *w;
31763178
WriterContext *wctx;

ffserver.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373

7474
#define PATH_LENGTH 1024
7575

76-
const char program_name[] = "ffserver";
77-
const int program_birth_year = 2000;
76+
// const char program_name[] = "ffserver";
77+
// const int program_birth_year = 2000;
7878

7979
static const OptionDef options[];
8080

@@ -3951,7 +3951,8 @@ static void opt_debug(void)
39513951
snprintf(config.logfilename, sizeof(config.logfilename), "-");
39523952
}
39533953

3954-
void show_help_default(const char *opt, const char *arg)
3954+
void show_help_default_ffserver(const char *opt, const char *arg);
3955+
void show_help_default_ffserver(const char *opt, const char *arg)
39553956
{
39563957
printf("usage: ffserver [options]\n"
39573958
"Hyper fast multi format Audio/Video streaming server\n");
@@ -3967,7 +3968,8 @@ static const OptionDef options[] = {
39673968
{ NULL },
39683969
};
39693970

3970-
int main(int argc, char **argv)
3971+
int main_ffserver(int argc, char **argv);
3972+
int main_ffserver(int argc, char **argv)
39713973
{
39723974
struct sigaction sigact = { { 0 } };
39733975
int cfg_parsed;

0 commit comments

Comments
 (0)