`
- 浏览:
499010 次
- 性别:
- 来自:
河北
-
/**************************************************************************** Description:* A tool to adjust the timestamps of srt subtitle files.* Version 0.1* Author : wplxb* Language: C* Date : 2007-07-01***************************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#define MAX_LINE_LEN 400#define TIMESTAMP_LEN 27void print_help(char * filename){ printf("Usage: %s [Options] file\n", filename); printf("Options:\n"); printf(" +sec Add sec seconds to the subtitle file specified.\n"); printf(" -sec Subtract sec seconds to the subtitle file specified.\n"); printf(" --help Display this information.\n"); printf(" -h Display this information.\n"); printf(" -? Display this information.\n"); printf("\n"); printf("Note that the adjusted subtitle will be outputed to the standard output.\n");}void preprocess(int argc, char *argv[]){ char * filename = "timestamp"; char * arg1; if (1 == argc) { print_help(filename); exit(1); } arg1 = argv[1]; if (0 == strcmp("-h", arg1) || 0 == strcmp("--help", arg1) || 0 == strcmp("-?", arg1)) { print_help(filename); exit(0); } else if (argc < 3) { print_help(filename); exit(1); } else if ('+' != arg1[0] && '-' != arg1[0]) { print_help(filename); exit(1); } if (strspn(arg1 + 1, "0123456789") != strlen(arg1 + 1)) { print_help(filename); exit(1); }}int is_timestamp_line(char * line){ if (!line) { return 0; } line = strpbrk(line, "0123456789"); if (line) { if (strlen(line) >= TIMESTAMP_LEN && ':' == line[2] && ':' == line[5] && ',' == line[8]) { return 1; } } return 0;}int main(int argc, char * argv[]){ FILE * srt; int seconds; char timestamp_line[MAX_LINE_LEN]; preprocess(argc, argv); seconds = atoi(argv[1] + 1); if ('-' == argv[1][0]) { seconds = -seconds; } if (NULL == (srt = fopen(argv[2], "r"))) { printf("Can't open file \"%s\"!\n", argv[2]); exit(errno); } /* The real process starts here. */ while (fgets(timestamp_line, sizeof(timestamp_line), srt)) { if (is_timestamp_line(timestamp_line)) { int start_hour; int start_minute; int start_second; int start_millisecond; int start_time; int end_hour; int end_minute; int end_second; int end_millisecond; int end_time; sscanf(timestamp_line, "%d", &start_hour); sscanf(timestamp_line + 3, "%d", &start_minute); sscanf(timestamp_line + 6, "%d", &start_second); sscanf(timestamp_line + 9, "%d", &start_millisecond); start_time = start_hour; start_time = start_time * 60 + start_minute; start_time = start_time * 60 + start_second; start_time += seconds; start_second = start_time % 60; start_time /= 60; start_minute = start_time % 60; start_time /= 60; start_hour = start_time; sscanf(timestamp_line + 17, "%d", &end_hour); sscanf(timestamp_line + 20, "%d", &end_minute); sscanf(timestamp_line + 23, "%d", &end_second); sscanf(timestamp_line + 26, "%d", &end_millisecond); end_time = end_hour; end_time = end_time * 60 + end_minute; end_time = end_time * 60 + end_second; end_time += seconds; end_second = end_time % 60; end_time /= 60; end_minute = end_time % 60; end_time /= 60; end_hour = end_time; printf("%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n", start_hour, start_minute, start_second, start_millisecond, end_hour, end_minute, end_second, end_millisecond); } else { printf("%s", timestamp_line); } } fclose(srt); return 0;}
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
一个离线运行的本地语音识别转文字服务,输出json、srt字幕带时间戳、纯文字格式
Moo0文件时间戳修改器顾名思义是一款短小精悍免费实用的文件时间戳修改设置工具,内置查看和复制、查看和编辑以及能满足多文件批量修改的一次更改多个文件或文件夹三种模式,该时间戳修改工具允许大家可以直接将文件...
PE 可执行文件时间戳转换工具,支持所有windows 可执行文件格式
将Youtube字幕字幕转换成srt格式 个人开发使用,非喜勿喷,谢谢。
修改文件时间戳 Moo0 文件时间戳修改器 可以让你方便的修改文件和文件夹的时间戳。 使用这个软件,你可以修改单个或多个文件的“创建时间”、“修改时间”、和“访问时间“,通过设定具体的时间以抵消时区设置。...
通过javacv加载字幕文件,然后跟视频合并。首先使用FFmpegFrameGrabber类加载视频文件和字幕文件。...同时,在合并字幕和视频时,需要根据字幕文件中的时间戳来确定字幕的位置和显示时间,以确保字幕与视频的同步。
可以修改照片的创建时间,修改时间等时间戳 不需要安装,可以直接使用
非常简单的,绿色小工具,EXE直接运行,有源码,字幕文件SRT格式的时间戳整体提前或延后的调整的Windows窗口小工具,可以拖入SRT文件的。
概述:本程序使用python编写,其中UI使用pyqt5编写,主要功能是将纯文本txt内容的文字转换为SRT或者ASS格式的字幕文件,适合于制作短视频时额外字幕的制作。有些视频编辑工具,字幕添加比较麻烦,本程序可以单独对...
简单实现基于raw socket 的请求时间戳的客户端程序。
一个可以任意修改文件时间戳的工具,相当好用
提取字幕文件内容的实用程序。 支持的类型: ass : ssa : srt : sub : txt : 有关更多信息: : 用法 方法解析需要以下参数: path :字幕文件的位置。 subtype :受支持的文件类型之一,默认情况下...
PE 文件时间戳修改工具, 将PE文件中编译时间戳统一修改为2008-08-08 08:08:08 使用方法: 1、命令行: TimeFix d:\Budded.dll 2、Delphi2007中PostBuild中可以使用: "$(BDS)\Bin\TimeFix.exe" "$(OUTPUTPATH)" ...
SubsManipulator 处理字幕中的时间戳(.SRT)
NewFileTime翻译过来就是新的文件时间,通过拖放来添加文件,将要修改的文件拖到软件窗口中,可以显示并修改原来的文件的修改时间、创建时间和访问时间。每个时间戳都可以修改为指定日期和时间。语言切换说明:进入...
改变文件、文件夹的时间属性,包括创建时间、更改时间、最近访问时间。
自己编写的 将UTC时间戳(秒数)与 任意时间日期相互转换的小程序,QT和C++编写的,含源码,也可以直接运行打包好的执行文件
这篇文章主要介绍了基于python修改srt字幕的时间轴,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 代码如下 # -*- coding: utf-8 -*- # @时间 : 2020-01-19 ...
通过Cortex-M3内置DWT(Data Watchpoint and Trace)外设,记录程序片段内核时钟运行个数,CYCCNT为32位寄存器,stm32f407单片机测试通过
//时间戳转换成日期时间 function js_date_time(unixtime) { var dateTime = new Date(parseInt(unixtime) * 1000) var year = dateTime.getFullYear(); var month = dateTime.getMonth() + 1; var day = ...