Skip to content

Commit 3350bf1

Browse files
committed
Create Base App
Base app codes added for using it as a structure More codecs should be added soon
1 parent 96eaebb commit 3350bf1

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# ffmpeg-helper
22
A small CLI tool which will help in producing different types of ffmpeg CLI users video converting codes quickly
3+
4+
* Works in both **Linux** & **Windows**

ffmpeg-coder.cpp

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/* A C++ program code by Mushfiqur Rahman Abir */
2+
3+
#include <iostream>
4+
#include <vector>
5+
6+
//A function for clearing screen
7+
void clear_screen()
8+
{
9+
#ifdef _WIN32
10+
// do something for windows like include <windows.h>
11+
system("cls");
12+
#elif defined __unix__
13+
// do something for unix like include <unistd.h>
14+
system("clear");
15+
#endif
16+
}
17+
18+
//The FFMPEG class which will hold all kinds of encode options as methods
19+
class ffmpeg
20+
{
21+
private:
22+
std::vector<std::string> encodes;
23+
std::vector<int> crf;
24+
25+
public:
26+
//Vars
27+
int selected;
28+
std::string video_name;
29+
int selected_crf;
30+
31+
//Methods
32+
ffmpeg();
33+
~ffmpeg();
34+
35+
void load_encodes()
36+
{
37+
//Loading the encodes into the vector
38+
encodes.push_back("h264");
39+
encodes.push_back("libx265");
40+
};
41+
void show_encodes()
42+
{
43+
for (int i = 0; i < encodes.size(); i++)
44+
{
45+
std::cout << (i + 1) << ". " << encodes[i] << std::endl;
46+
}
47+
};
48+
int select_encodes()
49+
{
50+
std::cout << "Enter your choice: ";
51+
std::cin >> selected;
52+
53+
return selected;
54+
};
55+
56+
//ENCODERS ACTIONS
57+
void select_crf()
58+
{
59+
int choice;
60+
crf.push_back(20);
61+
crf.push_back(24);
62+
crf.push_back(26);
63+
crf.push_back(28);
64+
65+
//showing the crf
66+
for (int i = 0; i < crf.size(); i++)
67+
{
68+
std::cout << (i + 1) << ". " << crf[i] << std::endl;
69+
}
70+
71+
//Taking the crf
72+
std::cout << "Input your choice: ";
73+
std::cin >> choice;
74+
75+
switch (choice)
76+
{
77+
case 1:
78+
{
79+
selected_crf = 20;
80+
break;
81+
}
82+
case 2:
83+
{
84+
selected_crf = 24;
85+
break;
86+
}
87+
case 3:
88+
{
89+
selected_crf = 26;
90+
break;
91+
}
92+
case 4:
93+
{
94+
selected_crf = 28;
95+
break;
96+
}
97+
default:
98+
{
99+
std::cout << "No CRF selected going with default 24";
100+
std::cout << std::endl;
101+
selected_crf = 24;
102+
}
103+
}
104+
}
105+
void h264()
106+
{
107+
//Taking the video name input
108+
std::cout << "Please input the video file name: ";
109+
// getline(std::cin, video_name);
110+
std::cin >> video_name;
111+
clear_screen();
112+
std::cout << "NB: Input -1 to Exit the input loop";
113+
std::cout << std::endl;
114+
115+
std::cout << "Your input video file name is: " << video_name;
116+
std::cout << std::endl;
117+
118+
//preparing the prefix and suffix code for ffmpeg convertion
119+
std::cout << std::endl;
120+
std::cout << std::endl;
121+
std::cout << "ffmpeg -i " << video_name << ".mp4 -vcodec h264 -acodec aac -crf "<<selected_crf<<" " << video_name << ".encoded.mp4";
122+
std::cout << std::endl;
123+
std::cout << std::endl;
124+
}
125+
126+
void selected_action()
127+
{
128+
using namespace std;
129+
switch (selected)
130+
{
131+
case 1: //h264
132+
{
133+
select_crf();
134+
do
135+
{
136+
h264();
137+
} while (video_name != "-1");
138+
}
139+
}
140+
}
141+
};
142+
143+
ffmpeg::ffmpeg()
144+
{
145+
}
146+
147+
ffmpeg::~ffmpeg()
148+
{
149+
}
150+
151+
//Functions
152+
void title()
153+
{
154+
using namespace std;
155+
cout << "FFMPEG Coder\n"
156+
<< endl;
157+
}
158+
159+
//Home page of the tool
160+
void homepage()
161+
{
162+
using namespace std;
163+
164+
ffmpeg ffmpeg; //Creating ffmpeg object
165+
int choice;
166+
167+
cout << "Choose your option: " << endl;
168+
169+
//Adding the options to the homepage menu (Main menu)
170+
vector<string> options;
171+
options.push_back("Make Codes");
172+
options.push_back("About");
173+
options.push_back("Exit");
174+
175+
//showing the options
176+
for (int i = 0; i < options.size(); i++)
177+
{
178+
cout << (i + 1) << ". " << options[i] << endl;
179+
}
180+
181+
//taking choice input
182+
cout << "Your choice: ";
183+
cin >> choice;
184+
185+
//Entering into selected option funcs
186+
if (choice == 1)
187+
{
188+
clear_screen();
189+
ffmpeg.load_encodes();
190+
ffmpeg.show_encodes();
191+
ffmpeg.select_encodes();
192+
ffmpeg.selected_action();
193+
}
194+
}
195+
196+
int main()
197+
{
198+
title();
199+
homepage();
200+
}

0 commit comments

Comments
 (0)