[FFmpeg-cvslog] ffmpeg:Daemon mode, add -d as first option to try it.

Víctor Paesa victorpaesa at gmail.com
Fri Apr 22 12:18:24 CEST 2011


Hi,

On Tue, Apr 19, 2011 at 02:00, Michael Niedermayer <git at videolan.org> wrote:
> ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Apr 18 13:10:52 2011 +0200| [39aafa5ee90e10382e2f991e4d79d7852231df68] | committer: Michael Niedermayer
>
> ffmpeg:Daemon mode, add -d as first option to try it.
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
>
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39aafa5ee90e10382e2f991e4d79d7852231df68
> ---
>
>  ffmpeg.c |   21 ++++++++++++++++++++-
>  1 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index 06c8bed..94d3ede 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -235,6 +235,7 @@ static int audio_volume = 256;
>  static int exit_on_error = 0;
>  static int using_stdin = 0;
>  static int verbose = 1;
> +static int daemon  = 0;
>  static int thread_count= 1;
>  static int q_pressed = 0;
>  static int64_t video_size = 0;
> @@ -444,7 +445,8 @@ static void term_exit(void)
>  {
>     av_log(NULL, AV_LOG_QUIET, "");
>  #if HAVE_TERMIOS_H
> -    tcsetattr (0, TCSANOW, &oldtty);
> +    if(!daemon)
> +        tcsetattr (0, TCSANOW, &oldtty);
>  #endif
>  }
>
> @@ -461,6 +463,7 @@ sigterm_handler(int sig)
>  static void term_init(void)
>  {
>  #if HAVE_TERMIOS_H
> +    if(!daemon){
>     struct termios tty;
>
>     tcgetattr (0, &tty);
> @@ -478,6 +481,7 @@ static void term_init(void)
>
>     tcsetattr (0, TCSANOW, &tty);
>     signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
> +    }
>  #endif
>
>     signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
> @@ -496,6 +500,9 @@ static int read_key(void)
>     struct timeval tv;
>     fd_set rfds;
>
> +    if(daemon)
> +        return -1;
> +
>     FD_ZERO(&rfds);
>     FD_SET(0, &rfds);
>     tv.tv_sec = 0;
> @@ -4266,6 +4273,10 @@ static int opt_preset(const char *opt, const char *arg)
>     return 0;
>  }
>
> +static void log_callback_null(void* ptr, int level, const char* fmt, va_list vl)
> +{
> +}
> +
>  static const OptionDef options[] = {
>     /* main options */
>  #include "cmdutils_common_opts.h"
> @@ -4409,6 +4420,14 @@ int main(int argc, char **argv)
>
>     av_log_set_flags(AV_LOG_SKIP_REPEATED);
>
> +    if(argc>1 && !strcmp(argv[1], "-d")){
> +        daemon=1;
> +        verbose=-1;
> +        av_log_set_callback(log_callback_null);
> +        argc--;
> +        argv++;
> +    }
> +
>     avcodec_register_all();
>  #if CONFIG_AVDEVICE
>     avdevice_register_all();
>

daemon() is defined in unistd.h for BSD and Cygwin.

Could that int be renamed?

Thanks in advance,
Víctor


More information about the ffmpeg-cvslog mailing list