Skip to content

Commit

Permalink
Added the complete source code.
Browse files Browse the repository at this point in the history
- All the files have been successfully migrated
- All the necessary changes have been made
- It is now Subtitle-Resync and not co_oCCur
  • Loading branch information
sypai committed Sep 1, 2019
1 parent a612954 commit f4bc249
Show file tree
Hide file tree
Showing 17 changed files with 2,014 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -174,6 +174,8 @@ set(SourceFiles
src/utils/base64_strings.cpp
src/utils/align_fingerprints.h
src/utils/align_fingerprints.cpp
src/utils/tool.cpp
src/utils/tool.h

src/subtitle_resync.h
src/subtitle_resync.cpp
Expand Down
8 changes: 4 additions & 4 deletions cmake-build-debug/CMakeFiles/Makefile2
Expand Up @@ -69,11 +69,11 @@ CMAKE_BINARY_DIR = /home/sypai/Subtitle-Resync/cmake-build-debug

# All Build rule for target.
CMakeFiles/resync.dir/all: CMakeFiles/webrtc.dir/all
CMakeFiles/resync.dir/all: CMakeFiles/chromaprint.dir/all
CMakeFiles/resync.dir/all: CMakeFiles/ccaligner.dir/all
CMakeFiles/resync.dir/all: CMakeFiles/chromaprint.dir/all
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/depend
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles --progress-num=28,29,30,31,32,33 "Built target resync"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles --progress-num=28,29,30,31,32,33,34 "Built target resync"
.PHONY : CMakeFiles/resync.dir/all

# Include target in all.
Expand All @@ -83,7 +83,7 @@ all: CMakeFiles/resync.dir/all

# Build rule for subdir invocation for target.
CMakeFiles/resync.dir/rule: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles 51
$(CMAKE_COMMAND) -E cmake_progress_start /home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles 52
$(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/resync.dir/all
$(CMAKE_COMMAND) -E cmake_progress_start /home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles 0
.PHONY : CMakeFiles/resync.dir/rule
Expand Down Expand Up @@ -147,7 +147,7 @@ clean: CMakeFiles/ccaligner.dir/clean
CMakeFiles/webrtc.dir/all:
$(MAKE) -f CMakeFiles/webrtc.dir/build.make CMakeFiles/webrtc.dir/depend
$(MAKE) -f CMakeFiles/webrtc.dir/build.make CMakeFiles/webrtc.dir/build
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles --progress-num=34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 "Built target webrtc"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=/home/sypai/Subtitle-Resync/cmake-build-debug/CMakeFiles --progress-num=35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52 "Built target webrtc"
.PHONY : CMakeFiles/webrtc.dir/all

# Include target in all.
Expand Down
2 changes: 1 addition & 1 deletion cmake-build-debug/CMakeFiles/progress.marks
@@ -1 +1 @@
51
52
36 changes: 18 additions & 18 deletions cmake-build-debug/CMakeFiles/webrtc.dir/progress.make
@@ -1,19 +1,19 @@
CMAKE_PROGRESS_1 = 34
CMAKE_PROGRESS_2 = 35
CMAKE_PROGRESS_3 = 36
CMAKE_PROGRESS_4 = 37
CMAKE_PROGRESS_5 = 38
CMAKE_PROGRESS_6 = 39
CMAKE_PROGRESS_7 = 40
CMAKE_PROGRESS_8 = 41
CMAKE_PROGRESS_9 = 42
CMAKE_PROGRESS_10 = 43
CMAKE_PROGRESS_11 = 44
CMAKE_PROGRESS_12 = 45
CMAKE_PROGRESS_13 = 46
CMAKE_PROGRESS_14 = 47
CMAKE_PROGRESS_15 = 48
CMAKE_PROGRESS_16 = 49
CMAKE_PROGRESS_17 = 50
CMAKE_PROGRESS_18 = 51
CMAKE_PROGRESS_1 = 35
CMAKE_PROGRESS_2 = 36
CMAKE_PROGRESS_3 = 37
CMAKE_PROGRESS_4 = 38
CMAKE_PROGRESS_5 = 39
CMAKE_PROGRESS_6 = 40
CMAKE_PROGRESS_7 = 41
CMAKE_PROGRESS_8 = 42
CMAKE_PROGRESS_9 = 43
CMAKE_PROGRESS_10 = 44
CMAKE_PROGRESS_11 = 45
CMAKE_PROGRESS_12 = 46
CMAKE_PROGRESS_13 = 47
CMAKE_PROGRESS_14 = 48
CMAKE_PROGRESS_15 = 49
CMAKE_PROGRESS_16 = 50
CMAKE_PROGRESS_17 = 51
CMAKE_PROGRESS_18 = 52

30 changes: 30 additions & 0 deletions cmake-build-debug/Makefile
Expand Up @@ -1431,6 +1431,33 @@ src/utils/dactylogram.cpp.s:
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/src/utils/dactylogram.cpp.s
.PHONY : src/utils/dactylogram.cpp.s

src/utils/tool.o: src/utils/tool.cpp.o

.PHONY : src/utils/tool.o

# target to build an object file
src/utils/tool.cpp.o:
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/src/utils/tool.cpp.o
.PHONY : src/utils/tool.cpp.o

src/utils/tool.i: src/utils/tool.cpp.i

.PHONY : src/utils/tool.i

# target to preprocess a source file
src/utils/tool.cpp.i:
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/src/utils/tool.cpp.i
.PHONY : src/utils/tool.cpp.i

src/utils/tool.s: src/utils/tool.cpp.s

.PHONY : src/utils/tool.s

# target to generate assembly for a file
src/utils/tool.cpp.s:
$(MAKE) -f CMakeFiles/resync.dir/build.make CMakeFiles/resync.dir/src/utils/tool.cpp.s
.PHONY : src/utils/tool.cpp.s

# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
Expand Down Expand Up @@ -1584,6 +1611,9 @@ help:
@echo "... src/utils/dactylogram.o"
@echo "... src/utils/dactylogram.i"
@echo "... src/utils/dactylogram.s"
@echo "... src/utils/tool.o"
@echo "... src/utils/tool.i"
@echo "... src/utils/tool.s"
.PHONY : help


Expand Down
2 changes: 1 addition & 1 deletion libs/lib_co-oCCur/SiftSRT/SiftSRT.h
Expand Up @@ -982,7 +982,7 @@ inline void co_oCCurEditor::Adjust(const std::string &FileName, const std::vecto
std::vector<std::string> temp1;
temp1 = split(FileName, '/', temp1);
std::string adjustedFileName = temp[0] + ".srt";
std::string co_oCCurFileName = "../co_oCCur-" + temp1[temp1.size() - 1];
std::string co_oCCurFileName = "../output/co_oCCur-" + temp1[temp1.size() - 1];

std::ofstream writeToFile;
m_FileNameOut = co_oCCurFileName;
Expand Down
100 changes: 98 additions & 2 deletions src/main.cpp
Expand Up @@ -3,8 +3,104 @@
* Email: 7suyashbajpai@gmail.com
* Github: https://github.com/sypai
*/
#include "subtitle_resync.h"

int main()
void CLIHeader()
{
std::cout << "co_oCCur: Subtitle Synchronization tool, Suyash Bajpai." << std::endl;
std::cout << "Parent Organization: CCExtractor Development" << std::endl;
std::cout << "Mentor: Carlos Fernandez Sans, Google Summer of Code 2019." << std::endl;
std::cout << "-------------------------------------------------------------\n" << std::endl;
}

void PrintUsage()
{
std::string usage;
usage = R"(Syntax:
./resync -org /path/to/original/wav/file -mod /path/to/modified/wav/file -s /path/to/SRT
Options:
-org OR -o FILE: Original Audio file
-mod OR -m FILE: Modified Audio file
-srt OR -s FILE: Original Subtitle file
Example: ./resync -org episode1.wav -mod episode1_W/OCommercial.wav -s input.srt)";

std::cout << usage << std::endl;
}

int ParseOptions(int arg_c, char* arg_v[])
{
Subtitle_Resync::resync *sync;
sync = new Subtitle_Resync::resync();

if (arg_c < 2)
{
PrintUsage();
return 11;
}

for (int i=1; i<arg_c; i++)
{
std::string parameter(arg_v[i]);

if ((parameter == "-org" || parameter == "-o") && i + 1 < arg_c)
{
sync->setOriginalAudio(arg_v[i+1]);
i++;
}

else if ((parameter == "-mod" || parameter == "-m") && i + 1 < arg_c)
{
sync->setModifiedAudio(arg_v[i+1]);
i++;
}

else if ((parameter == "-srt" || parameter == "-s") && i + 1 < arg_c)
{
sync->setOriginalSubtitle(arg_v[i+1]);
i++;
}

else if ((parameter == "-out") && i + 1 < arg_c)
{
sync->setOutputName(arg_v[i+1]);
i++;
}

else if ((parameter == "-debug"))
{
sync->setLogLevel();
i++;
}

else
{
std::cout << "[ERROR] : Wrong input format." << std::endl;
PrintUsage();
return 11;
}
}

sync->init();
delete sync;
return 0;
}

void CLIFooter()
{
std::cout << "\n-------------------------------------------------------------" << std::endl;
std::cout << "Issues? Open a ticket here" << std::endl;
std::cout << "https://github.com/CCExtractor/Subtitle_Resync/issues" << std::endl;
}

int main(int argc, char *argv[])
{
CLIHeader();
ParseOptions(argc, argv);
CLIFooter();

return 0;
}
}


42 changes: 42 additions & 0 deletions src/subtitle_resync.cpp
Expand Up @@ -5,3 +5,45 @@
*/

#include "subtitle_resync.h"


Subtitle_Resync::resync::resync()
= default;

void Subtitle_Resync::resync::setOriginalAudio(std::string OriginalAudioName)
{
m_OriginalAudioFileName = std::move(OriginalAudioName);
}

void Subtitle_Resync::resync::setModifiedAudio(std::string ModifiedAudioName)
{
m_ModifiedAudioFileName = std::move(ModifiedAudioName);
}

void Subtitle_Resync::resync::setOriginalSubtitle(std::string OriginalSRTName)
{
m_OriginalSRTFileName = std::move(OriginalSRTName);
}

void Subtitle_Resync::resync::setOutputName(std::string OutputSRTName)
{
m_OutputSRTName = std::move(OutputSRTName);
}

void Subtitle_Resync::resync::setLogLevel()
{
m_LogLevel = 1;
}

void Subtitle_Resync::resync::init()
{
Subtitle_Resync::Tool* handle;
handle = new Subtitle_Resync::Tool(m_OriginalAudioFileName, m_ModifiedAudioFileName, m_OriginalSRTFileName, m_LogLevel);

handle->sync();

delete handle;
}

Subtitle_Resync::resync::~resync()
= default;
31 changes: 31 additions & 0 deletions src/subtitle_resync.h
Expand Up @@ -7,4 +7,35 @@
#ifndef SUBTITLE_RESYNC_SUBTITLE_RESYNC_H
#define SUBTITLE_RESYNC_SUBTITLE_RESYNC_H


#include <iostream>
#include <vector>
#include <string>

#include "logger.h"
#include "utils/tool.h"

namespace Subtitle_Resync{

class resync
{
private:
std::string m_OriginalAudioFileName;
std::string m_ModifiedAudioFileName;
std::string m_OriginalSRTFileName;
std::string m_OutputSRTName;
int m_LogLevel = 1;

public:
resync();
void setOriginalAudio(std::string OriginalAudioName);
void setModifiedAudio(std::string ModifiedAudioName);
void setOriginalSubtitle(std::string OriginalSRTName);
void setOutputName(std::string OutputSRTName);
void setLogLevel();
void init();
~resync();
};
}

#endif //SUBTITLE_RESYNC_SUBTITLE_RESYNC_H

0 comments on commit f4bc249

Please sign in to comment.