通过帧插值从30fps源创建30fps延时视频

时间:2019-01-25 21:09:21

标签: video ffmpeg interpolation timelapse

我正在尝试使用以下方法将视频源转换为延时:

ffmpeg -i source.mp4 -an -filter:v "setpts=PTS/360" timelapse.mp4

但由于使用PTS/360选项丢帧,我不喜欢这种断断续续的输出视频。我尝试使用tblend=average,framestep=2,setpts=PTS/360,但它看起来和原来一样,并且使该过滤器像原来一样

tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,...setpts=PTS/180

对我没有任何明显的改变。

ffmpeg是否还有其他选项可将30帧混合为1个平均帧并使用这些帧编译输出30fps视频?

1 个答案:

答案 0 :(得分:0)

我知道了!我在计算中错了,因此,具有帧平均的x256慢速视频的正确命令将如下所示:

#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXL 30 /* if you need a constant, #define one (or more) */ struct game_piece { char label[MAXL]; }; struct game_board { struct game_piece **board; int row, col; }; void game_piece_init_default(struct game_piece* piece) { strcpy(piece->label, "---"); } void game_piece_init(struct game_piece* piece, char* new_label) { size_t len = strlen (new_label); if (len < MAXL) memcpy (piece->label, new_label, len + 1); else { fputs ("warning: label truncated.\n", stderr); memcpy (piece->label, new_label, MAXL-1); piece->label[MAXL-1] = 0; /* nul-terminate */ } } char *game_piece_get_label (struct game_piece *piece) { return piece->label; } char *game_piece_to_string (struct game_piece *piece) { char *tempLabel; /* uninitialized pointer */ size_t len = strlen (game_piece_get_label(piece)); tempLabel = malloc (len + 1); if (tempLabel == NULL) { perror ("malloc-tempLabel"); return NULL; } memcpy (tempLabel, game_piece_get_label(piece), len + 1); if (len > 3) tempLabel[1] = '\0'; for (size_t i = 3; i > len; i--) strcat(tempLabel, " "); return tempLabel; } void game_board_init(struct game_board* game_board, int rows, int cols) { /* allocate row number of pointers */ game_board->board = malloc (sizeof(*game_board->board)*rows); /* allocate col number of **game_board->board per row * (e.g. col * sizeof (struct game_piece) per row) */ for (int i = 0; i < rows; i++){ game_board->board[i] = malloc(sizeof(struct game_piece) * cols); } game_board->row = rows; game_board->col = cols; for (int i=0; i < rows; i++){ printf("\n"); for (int j=0; j < cols; j++) { game_piece_init_default(&game_board->board[i][j]); printf("%s ",game_board->board[i][j].label); } } } int game_board_is_space_valid(struct game_board* game_board, int row, int col) { if (row > game_board->row || col > game_board->col) return 0; if (row < 0 || col < 0) return 0; return 1; } int game_board_add_piece(struct game_board* game_board, struct game_piece* piece, int row, int col) { if (game_board_is_space_valid(game_board, row, col) == 0) return 0; if (strncmp(game_board->board[row][col].label, "---", 3) == 0) { game_board->board[row][col] = *piece; return 1; } return 0; } int game_board_move_piece(struct game_board* game_board, int src_row, int src_col, int dest_row, int dest_col) { return 0; if (game_board || src_row || src_col || dest_row || dest_col) {} } void game_board_print(struct game_board* game_board) { int col = 3; int row = 3; printf("try again -kelly"); for (int i=0; i < row; i++) { printf("\n"); for (int j=0; j < col; j++) { printf("%s",game_piece_to_string(&game_board->board[i][j])); } } } int main() { /* declare local variables */ int row; int col; int destRow; int destCol; int rowNum; int colNum; struct game_board board; struct game_piece piece; char input_string[30]; /* get the size of the game board */ printf("Please enter the number of rows.\n"); scanf("%d", &rowNum); printf("Please enter the number of columns.\n"); scanf("%d", &colNum); game_board_init(&board, rowNum, colNum); /* get the first piece's label */ printf("Please enter a label for a new piece. " "Enter \"Q\" when done.\n"); scanf("%s", input_string); while (strcmp(input_string, "Q") != 0 && strcmp(input_string, "q") != 0) { game_piece_init(&piece, input_string); /* get the location to place the piece */ printf("Please enter a row for the piece.\n"); scanf("%d", &row); printf("Please enter a column for the piece.\n"); scanf("%d", &col); /* verify the space is valid then add the piece to the board */ if (game_board_is_space_valid(&board, row, col)) { if (game_board_add_piece(&board, &piece, row, col)) { printf("New piece \"%s\" added.\n", game_piece_get_label(&piece)); } else { printf("A piece is already at that space.\n"); } } else { printf("Invalid row and/or column.\n"); } /* get the label for the next piece */ printf("Please enter a label for a new piece. " "Enter \"Q\" when done."); scanf("%s", input_string); } /* print the board and check if user wants to move a piece */ game_board_print(&board); printf("Would you like to move a piece? Enter \"Y\" to move a piece.\n"); scanf("%s", input_string); while (strcmp(input_string, "Y") == 0 || strcmp(input_string, "y") == 0) { /* get the location of the piece */ printf("Please enter the piece's row."); scanf("%d", &row); printf("Please enter the piece's column."); scanf("%d", &col); /* get the destination for the piece */ printf("Please enter the piece's new row."); scanf("%d", &destRow); printf("Please enter the piece's new column."); scanf("%d", &destCol); /* verify both spaces are valid then move the piece */ if (game_board_is_space_valid(&board, row, col) && game_board_is_space_valid(&board, destRow, destCol)) { if (game_board_move_piece(&board, row, col, destRow, destCol)) { printf("Piece moved to new space.\n"); } else { printf("A piece is already in that space.\n"); } } else { printf("A row or column is invalid. No piece moved.\n"); } /* print the board and check if the user wants move another piece */ game_board_print(&board); printf("Would you like to move a piece? " "Enter \"Y\" to move a piece.\n"); scanf("%s", input_string); } return 0; }