我需要字幕幫助=)C/Java - 讀取2個文件寫入一個
我有兩個帶字幕的.srt文件。一個是英文的,另一個是斯洛文尼亞的。問題在於Slovene中的文件沒有正確的 時間碼,所以字幕比實際的線更快。我想要做的是編寫一個程序,讀取這兩個文件,從eng.srt文件和字幕文件並寫入所有complete.srt中的時間代碼字幕和 。我不在乎它是否在Java或C中。我目前正在嘗試用C語言編寫程序,並且我會提供任何幫助。
現在證明它是我想做的事:
eng.srt (right timecode)
1
00:00:01,259 --> 00:00:03,734
<i>Previously on...</i>
2
00:00:03,746 --> 00:00:06,910
<i>Tom and Lynette drifted further apart,</i>
3
00:00:06,911 --> 00:00:09,275
<i>and Jane took advantage.</i>
4
00:00:09,440 --> 00:00:10,670
I'm scared.
5
00:00:10,671 --> 00:00:13,362
<i>Roy helped Karen face her cancer.</i>
slo.srt (right subtitles)
1
00:00:00,009 --> 00:00:02,484
<i>Prejšnič...</i>
2
00:00:02,496 --> 00:00:05,660
<i>Tom and Lynette
sta se še bolj odtujila,</i>
3
00:00:05,661 --> 00:00:08,025
<i>in Jane je to izkoristila.</i>
4
00:00:08,190 --> 00:00:09,420
Strah me je.
5
00:00:09,421 --> 00:00:12,112
<i>Roy se je pomagal Karen
soočiti z rakom.</i>
complete.srt (where i write)
1
00:00:01,259 --> 00:00:03,734
<i>Prejšnič...</i>
2
00:00:03,746 --> 00:00:06,910
<i>Tom and Lynette
sta se še bolj odtujila,</i>
...
這是我到目前爲止所(我打開3個文件,我將更新我的工作,因爲我去):
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch, sf1[20], sf2[20], tf[20];
FILE *source1, *source2, *target;
//first source file
printf("Enter name of first source file\n");
gets(sf1);
source1 = fopen(sf1, "r");
//seconds source file
printf("Enter name of second source file\n");
gets(sf2);
source2 = fopen(sf2, "r");
if(source == NULL)
{
printf("Press any key to exit...\n");
exit(EXIT_FAILURE);
}
//target file
printf("Enter name of target file\n");
gets(tf);
target = fopen(tf, "w");
if(target == NULL)
{
fclose(source);
printf("Press any key to exit...\n");
exit(EXIT_FAILURE);
}
printf("File writen successfully.\n");
fclose(source1);
fclose(source2);
fclose(target);
return 0;
}
我的問題是,我不知道如何告訴程序從eng.srt文件只讀的數字,比跳過字幕部分,並等待,比讀slo.srt文件拿出字幕並跳過編號RS。
請仔細閱讀幫助部分。這不是簡單地詢問代碼的地方。你有嘗試過什麼嗎? – home
當問一個關於堆棧溢出的問題時,顯示代碼片段是一個很好的習慣 –
問題是什麼? – reporter