📄 lavplay.c
字号:
lavplay_increase_frame(info, atoi(buffer+2)); break; default: lavplay_set_frame(info, atoi(buffer+1)); break; } break; case 'e': switch (buffer[1]) { case 'o': sscanf(buffer+2, "%d %d", &arg1, &arg2); lavplay_edit_copy(info, arg1, arg2); break; case 'u': sscanf(buffer+2, "%d %d", &arg1, &arg2); lavplay_edit_cut(info, arg1, arg2); break; case 'p': lavplay_edit_paste(info, current_frame); break; case 'm': sscanf(buffer+2, "%d %d %d", &arg1, &arg2, &arg3); lavplay_edit_move(info, arg1, arg2, arg3); break; case 'a': sscanf(buffer+2, "%s %d %d %d", arg, &arg1, &arg2, &arg3); lavplay_edit_addmovie(info, arg, arg1, arg2, arg3); break; case 'd': sscanf(buffer+2, "%d %d", &arg1, &arg2); lavplay_edit_delete(info, arg1, arg2); break; case 's': sscanf(buffer+2, "%d %d", &arg1, &arg2); lavplay_edit_set_playable(info, arg1, arg2); break; } break; case 'o': movie[0] = buffer+2; lavplay_open(info, movie, 1); break; case 'w': switch (buffer[1]) { case 'a': sscanf(buffer+3, "%s", arg); lavplay_save_all(info, arg); break; case 's': sscanf(buffer+3, "%d %d %s", &arg1, &arg2, arg); lavplay_save_selection(info, arg, arg1, arg2); break; } break; }}static int set_option(const char *name, char *value){ /* return 1 means error, return 0 means okay */ int nerr = 0; if (strcmp(name, "verbose")==0 || strcmp(name, "v")==0) { verbose = atoi(optarg); } else if (strcmp(name, "audio")==0 || strcmp(name, "a")==0) { info->audio = atoi(optarg); } else if (strcmp(name, "H-offset")==0 || strcmp(name, "H")==0) { info->horizontal_offset = atoi(optarg); } else if (strcmp(name, "V-offset")==0 || strcmp(name, "V")==0) { info->vertical_offset = atoi(optarg); } else if (strcmp(name, "skip")==0 || strcmp(name, "s")==0) { skip_seconds = atoi(optarg); if (skip_seconds<0) skip_seconds = 0; } else if (strcmp(name, "synchronization")==0 || strcmp(name, "c")==0) { info->sync_correction = atoi(optarg); } else if (strcmp(name, "mjpeg-buffers")==0 || strcmp(name, "n")==0) { info->MJPG_numbufs = atoi(optarg); if (info->MJPG_numbufs<4) info->MJPG_numbufs = 4; if (info->MJPG_numbufs>256) info->MJPG_numbufs = 256; } else if (strcmp(name, "no-quit")==0 || strcmp(name, "q")==0) { info->continuous = 1; } else if (strcmp(name, "exchange-fields")==0 || strcmp(name, "x")==0) { info->exchange_fields = 1; } else if (strcmp(name, "zoom")==0 || strcmp(name, "z")==0) { info->zoom_to_fit = 1; } else if (strcmp(name, "gui-mode")==0 || strcmp(name, "g")==0) { gui_mode = 1; } else if (strcmp(name, "full-screen")==0 || strcmp(name, "Z")==0) { info->soft_full_screen = 1; } else if( strcmp( name, "preserve-pathnames") == 0 || strcmp(name, "P")==0) { info->preserve_pathnames = 1; } else if (strcmp(name, "playback")==0 || strcmp(name, "p")==0) { switch (value[0]) {#ifdef HAVE_V4L case 'H': case 'C':#endif#ifdef HAVE_SDL case 'S':#endif info->playback_mode = value[0]; break; default: mjpeg_error("Unknown playback mode: \'%c\'", value[0]); nerr++; break; } } else if (strcmp(name, "size")==0 || strcmp(name, "S")==0) { if (sscanf(value, "%dx%d", &info->sdl_width, &info->sdl_height)!=2) { mjpeg_error( "--size parameter requires NxN argument"); nerr++; } } else if (strcmp(name, "flicker")==0 || strcmp(name, "F")==0) { info->flicker_reduction = 0; } else if (strcmp(name, "display")==0) { info->display = optarg; } else if (strcmp(name, "s-x-offset")==0) { info->vw_x_offset = atoi(optarg); } else if (strcmp(name, "s-y-offset")==0) { info->vw_y_offset = atoi(optarg); } else nerr++; /* unknown option - error */ return nerr;}static void check_command_line_options(int argc, char *argv[]){ int nerr,n,option_index=0; char option[2];#ifdef HAVE_GETOPT_LONG /* getopt_long options */ static struct option long_options[]={ {"verbose" ,1,0,0}, /* -v/--verbose */ {"norm" ,1,0,0}, /* -o/--norm */ {"h-offset" ,1,0,0}, /* -H/--H-offset */ {"v-offset" ,1,0,0}, /* -V/--V-offset */ {"skip" ,1,0,0}, /* -s/--skip */ {"synchronization" ,1,0,0}, /* -c/--synchronization */ {"mjpeg-buffers" ,1,0,0}, /* -n/--mjpeg-buffers */ {"no-quit" ,0,0,0}, /* -q/--no-quit */ {"exchange-fields" ,0,0,0}, /* -x/--exchange-fields */ {"zoom" ,0,0,0}, /* -z/--zoom */ {"full-screen" ,0,0,0}, /* -Z/--full-screen */ {"preserve-pathnames" ,0,0,0}, /* -P/--preserve-pathnames */ {"playback" ,1,0,0}, /* -p/--playback [SHC] */ {"audio" ,1,0,0}, /* -a/--audio num */ {"gui-mode" ,1,0,0}, /* -g/--gui-mode */ {"size" ,1,0,0}, /* -S/--size */ {"flicker" ,0,0,0}, /* -F/--flicker */ {"display" ,1,0,0}, /* --display */ {"s-x-offset" ,1,0,0}, /* --s-x-offset */ {"s-y-offset" ,1,0,0}, /* --s-y-offset */ {0,0,0,0} };#endif if(argc < 2) Usage(argv[0]);/* Get options */ nerr = 0;#ifdef HAVE_GETOPT_LONG while( (n=getopt_long(argc,argv,"S:a:v:H:V:s:c:n:t:qZp:xrzgPF", long_options, &option_index)) != EOF)#else while( (n=getopt(argc,argv,"S:a:v:H:V:s:c:n:t:qZp:xrzgPF")) != EOF)#endif { switch(n) {#ifdef HAVE_GETOPT_LONG /* getopt_long values */ case 0: nerr += set_option(long_options[option_index].name, optarg); break;#endif /* These are the old getopt-values (non-long) */ default: sprintf(option, "%c", n); nerr += set_option(option, optarg); break; } } if(optind>=argc) nerr++; if(nerr) Usage(argv[0]); if (getenv("LAV_VIDEO_DEV")) info->video_dev = getenv("LAV_VIDEO_DEV"); else { struct stat vstat; if(stat("/dev/video", &vstat) == 0 && S_ISCHR(vstat.st_mode)) info->video_dev = "/dev/video"; else if(stat("/dev/video0", &vstat) == 0 && S_ISCHR(vstat.st_mode)) info->video_dev = "/dev/video0"; else if(stat("/dev/v4l/video0", &vstat) == 0 && S_ISCHR(vstat.st_mode)) info->video_dev = "/dev/v4l/video0"; else if(stat("/dev/v4l0", &vstat) == 0 && S_ISCHR(vstat.st_mode)) info->video_dev = "/dev/v4l0"; else if(stat("/dev/v4l", &vstat) == 0 && S_ISCHR(vstat.st_mode)) info->video_dev = "/dev/v4l"; } if (getenv("LAV_AUDIO_DEV")) info->audio_dev = getenv("LAV_AUDIO_DEV"); else { struct stat astat; if(stat("/dev/dsp", &astat) == 0 && S_ISCHR(astat.st_mode)) info->audio_dev = "/dev/dsp"; else if(stat("/dev/sound/dsp", &astat) == 0 && S_ISCHR(astat.st_mode)) info->audio_dev = "/dev/sound/dsp"; else if(stat("/dev/audio", &astat) == 0 && S_ISCHR(astat.st_mode)) info->audio_dev = "/dev/audio"; } mjpeg_default_handler_verbosity(verbose); /* Get and open input files */ lavplay_open(info, argv + optind, argc - optind);}int main(int argc, char **argv){ char buffer[256]; /* Output Version information - Used by xlav to check for * consistency. */ printf( LAVPLAY_VSTR "\n" ); fflush(stdout); printf( "lavtools version " VERSION "\n" ); fcntl(0, F_SETFL, O_NONBLOCK); signal(SIGINT,SigHandler); info = lavplay_malloc(); if (!info) return 1; check_command_line_options(argc, argv); info->output_statistics = stats; info->msg_callback = input; info->state_changed = state_changed; if (!lavplay_main(info)) return 1; if (!lavplay_set_frame(info, skip_seconds * info->editlist->video_norm=='p'?25:30)) return 1; if (!lavplay_set_speed(info, 1)) return 1; /* okay, now wait until we get command-line input and ROCK! */ while (!exit_flag) { if (read(0, buffer, 255) > 0) process_input(buffer); else usleep(10000); } lavplay_busy(info); /* wait for all the nice goodies to shut down */ lavplay_free(info); fprintf(stderr, "\n"); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -