33#include < iostream>
44#include < vector>
55
6- // A function for clearing screen
6+ // A function for clearing screen (Cross Platform)
77void clear_screen ()
88{
99#ifdef _WIN32
@@ -21,13 +21,15 @@ class ffmpeg
2121private:
2222 std::vector<std::string> encodes;
2323 std::vector<int > crf;
24+ std::vector<int > audiobitrate;
2425
2526public:
2627 // Vars
2728 int selected;
2829 std::string video_name;
2930 int selected_crf;
30-
31+ int selected_audioBitrate;
32+ bool is_ab_selected = false ;
3133 // Methods
3234 ffmpeg ();
3335 ~ffmpeg ();
@@ -102,6 +104,88 @@ class ffmpeg
102104 }
103105 }
104106 }
107+
108+ void select_audioBitrate ()
109+ {
110+ int choice;
111+ int ab1 = 96 ;
112+ int ab2 = 128 ;
113+ int ab3 = 192 ;
114+ int ab4 = 256 ;
115+ int ab5 = 320 ;
116+ audiobitrate.push_back (ab1);
117+ audiobitrate.push_back (ab2);
118+ audiobitrate.push_back (ab3);
119+ audiobitrate.push_back (ab4);
120+ audiobitrate.push_back (ab5);
121+
122+ // Asking if the user need the option or not
123+ std::cout << " Do you want to specify the -ab option:" ;
124+ std::cout << std::endl;
125+ std::cout << " 1. Yes" ;
126+ std::cout << std::endl;
127+ std::cout << " 2. No" ;
128+ std::cout << std::endl;
129+
130+ std::cout << " Your choice: " ;
131+ std::cin >> choice;
132+
133+ if (choice == 1 )
134+ {
135+ is_ab_selected = true ;
136+ // showing the audioBitrate
137+ for (int i = 0 ; i < audiobitrate.size (); i++)
138+ {
139+ std::cout << (i + 1 ) << " . " << audiobitrate[i] << std::endl;
140+ }
141+
142+ // Taking the audioBitrate
143+ std::cout << " Input your choice: " ;
144+ std::cin >> choice;
145+
146+ switch (choice)
147+ {
148+ case 1 :
149+ {
150+ selected_audioBitrate = ab1;
151+ break ;
152+ }
153+ case 2 :
154+ {
155+ selected_audioBitrate = ab2;
156+ break ;
157+ }
158+ case 3 :
159+ {
160+ selected_audioBitrate = ab3;
161+ break ;
162+ }
163+ case 4 :
164+ {
165+ selected_audioBitrate = ab4;
166+ break ;
167+ }
168+ case 5 :
169+ {
170+ selected_audioBitrate = ab5;
171+ break ;
172+ }
173+ default :
174+ {
175+ std::cout << " No audioBitrate selected going with default 128" ;
176+ std::cout << std::endl;
177+ selected_audioBitrate = 128 ;
178+ }
179+ }
180+ }
181+ else
182+ {
183+ is_ab_selected = false ;
184+ std::cout << " Going without -ab option" ;
185+ std::cout << std::endl;
186+ }
187+ }
188+
105189 void h264 ()
106190 {
107191 // Taking the video name input
@@ -118,7 +202,15 @@ class ffmpeg
118202 // preparing the prefix and suffix code for ffmpeg convertion
119203 std::cout << std::endl;
120204 std::cout << std::endl;
121- std::cout << " ffmpeg -i " << video_name << " .mp4 -vcodec h264 -acodec aac -crf " <<selected_crf<<" " << video_name << " .encoded.mp4" ;
205+ if (is_ab_selected = true )
206+ {
207+ std::cout << " ffmpeg -i " << video_name << " .mp4 -vcodec h264 -acodec aac -ab " <<selected_audioBitrate<<" k " << " -crf " << selected_crf << " " << video_name << " .encoded.mp4" ;
208+
209+ }
210+ else
211+ {
212+ std::cout << " ffmpeg -i " << video_name << " .mp4 -vcodec h264 -acodec aac -crf " << selected_crf << " " << video_name << " .encoded.mp4" ;
213+ }
122214 std::cout << std::endl;
123215 std::cout << std::endl;
124216 }
@@ -131,6 +223,7 @@ class ffmpeg
131223 case 1 : // h264
132224 {
133225 select_crf ();
226+ select_audioBitrate ();
134227 do
135228 {
136229 h264 ();
0 commit comments