Revision 8fb566fd ffmpeg.c

View differences:

ffmpeg.c
66 66
#include <sys/select.h>
67 67
#endif
68 68

  
69
#if HAVE_KBHIT
70
#include <conio.h>
71
#endif
72 69
#include <time.h>
73 70

  
74 71
#include "cmdutils.h"
......
229 226
static int using_stdin = 0;
230 227
static int verbose = 1;
231 228
static int thread_count= 1;
232
static int q_pressed = 0;
233 229
static int64_t video_size = 0;
234 230
static int64_t audio_size = 0;
235 231
static int64_t extra_size = 0;
......
440 436
#endif
441 437
}
442 438

  
443
/* read a key without blocking */
444
static int read_key(void)
445
{
446
#if HAVE_KBHIT
447
    if(kbhit())
448
        return(getch());
449
#endif
450
    return -1;
451
}
452

  
453 439
static int decode_interrupt_cb(void)
454 440
{
455
    return q_pressed || (q_pressed = read_key() == 'q');
441
    return received_sigterm;
456 442
}
457 443

  
458 444
static int ffmpeg_exit(int ret)
......
1894 1880
    AVInputStream *ist, **ist_table = NULL;
1895 1881
    AVInputFile *file_table;
1896 1882
    char error[1024];
1897
    int key;
1898 1883
    int want_sdp = 1;
1899 1884
    uint8_t no_packet[MAX_FILES]={0};
1900 1885
    int no_packet_count=0;
......
2456 2441
        print_sdp(output_files, nb_output_files);
2457 2442
    }
2458 2443

  
2459
    if (!using_stdin && verbose >= 0) {
2460
#if HAVE_KBHIT
2461
        fprintf(stderr, "Press [q] to stop encoding\n");
2462
#else
2444
    if (verbose >= 0)
2463 2445
        fprintf(stderr, "Press ctrl-c to stop encoding\n");
2464
#endif
2465
        avio_set_interrupt_cb(decode_interrupt_cb);
2466
    }
2467 2446
    term_init();
2468 2447

  
2469 2448
    timer_start = av_gettime();
......
2477 2456
    redo:
2478 2457
        ipts_min= 1e100;
2479 2458
        opts_min= 1e100;
2480
        /* if 'q' pressed, exits */
2481
        if (!using_stdin) {
2482
            if (q_pressed)
2483
                break;
2484
            /* read_key() returns 0 on EOF */
2485
            key = read_key();
2486
            if (key == 'q')
2487
                break;
2488
        }
2489 2459

  
2490 2460
        /* select the stream that we must read now by looking at the
2491 2461
           smallest output pts */
......
4372 4342
#endif
4373 4343
    av_register_all();
4374 4344

  
4375
#if HAVE_ISATTY
4376
    if(isatty(STDIN_FILENO))
4377
        avio_set_interrupt_cb(decode_interrupt_cb);
4378
#endif
4345
    avio_set_interrupt_cb(decode_interrupt_cb);
4379 4346

  
4380 4347
    init_opts();
4381 4348

  

Also available in: Unified diff