Advertisement
Guest User

3.46

a guest
Nov 11th, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 101.27 KB | None | 0 0
  1. diff -Naur -x '*~' src/730-ffmpeg-tool-main.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/730-ffmpeg-tool-main.cpp
  2. --- src/730-ffmpeg-tool-main.cpp 1970-01-01 01:00:00.000000000 +0100
  3. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/730-ffmpeg-tool-main.cpp 2013-11-10 16:04:15.524769531 +0100
  4. @@ -0,0 +1,344 @@
  5. +#include "main.h"
  6. +#include "funzioni.h"
  7. +#include "routines/routines.h"
  8. +#include "routines/r-video-generali.h"
  9. +#include "routines/r-video-x264.h"
  10. +#include "routines/r-video-asp-avi.h"
  11. +#include "routines/r-audio.h"
  12. +#include "routines/r-util.h"
  13. +#include "routines/r-util-sox.h"
  14. +#include "routines/r-file-sett.h"
  15. +#include "routines/r-build-fin.h"
  16. +
  17. +
  18. +
  19. +
  20. +const std::string versione ("v-3.46");
  21. +const std::string filesettaggi_version ("v1.1");
  22. +
  23. +int main(int argc, char * argv[])
  24. +{
  25. + setlocale (LC_ALL,"");
  26. +
  27. + s_dati dati;
  28. +
  29. + dati.eseguibile = ESEGUIBILE_FFMPEG;
  30. + dati.estensione_file_in = "";
  31. + dati.nuova_estensione = NUOVA_EXT_MKV;
  32. + dati.debug = false;
  33. + dati.rate = "";
  34. + dati.maps = "";
  35. + dati.vcodec = VCODEC_X264;
  36. + dati.video_codec_is = VIDEO_IS_X_264;
  37. + dati.bitrate_video = BITRATE_VIDEO_X264_DEFAULT;
  38. + dati.b_v_rate = 0;
  39. + dati.preset = PRESET_FASTER;
  40. + dati.profile = "";
  41. + dati.set_264 = OPT_264_1;
  42. + dati.audio_parm = AUDIO_PARM_AF112;
  43. + dati.audio_codec_is = AUDIO_IS_FDKAAC;
  44. + dati.pass = 1;
  45. + dati.nofastfirst = false;
  46. + dati.filter = "";
  47. + dati.filtervalore = ""; // per utility vftest
  48. + dati.a_filter_valore = "";
  49. + dati.tempoin = "";
  50. + dati.tempodur = "";
  51. + dati.logfile = "";
  52. + dati.altro = "";
  53. + dati.aspetto = "";
  54. + dati.format_out = FORMAT_OUT_MATROSKA;
  55. + dati.nuovo_nome_file_out = "";
  56. + // stringa finale daeseguire
  57. + dati.daeseguire = "";
  58. + dati.filsett_vers = filesettaggi_version;
  59. +
  60. +
  61. + // check che venga passato almeno il nome del file
  62. + if (argc < 2)
  63. + {
  64. + printf ("\n");
  65. + printf ("Usare: %s nomefile\n", argv[0]);
  66. + printf ("Help: %s -h\n", argv[0]);
  67. + printf ("versione: %s\n", versione.c_str() );
  68. + printf ("\n");
  69. + return 1;
  70. + }
  71. +
  72. + // -h help
  73. + if (std::string(argv[1]) == "-h")
  74. + {
  75. + stampa_help(argv[0]);
  76. + return 0;
  77. + }
  78. +
  79. +
  80. + // nome del file con path
  81. + dati.nomefilein = (argv[1]);
  82. + std::string verifica = tipo_ext (dati.nomefilein);
  83. + if (verifica == "")
  84. + {
  85. + printf ("\nAttenzione: %s non ha alcuna estensione.\n\n", dati.nomefilein.c_str() );
  86. + return 1;
  87. + }
  88. + // nome del file senza path
  89. + dati.nomedelfile = ( rimuovi_path(dati.nomefilein) );
  90. + // estensione del file
  91. + dati.estensione_file_in = tipo_ext (dati.nomedelfile);
  92. + // nome del file senza ext
  93. + dati.nome_file_senza_ext = ( removeExtension (dati.nomedelfile.c_str()) );
  94. +
  95. + // check se il file input esiste
  96. + if ( !fileExists (dati.nomefilein.c_str()) )
  97. + {
  98. + printf ("\nIl file: %s non esiste.\n\n", dati.nomefilein.c_str() );
  99. + return 1;
  100. + }
  101. +
  102. + // check minimale sul numero parametri immessi
  103. + dati.param_tot_previsti = 2;
  104. +
  105. +
  106. + // debug stampa solo i comandi senza eseguirli
  107. + isdebug (argc, argv, &dati);
  108. +
  109. +
  110. + // frame rate, -r 25
  111. + if ( !frame_rate (argc, argv, &dati) )
  112. + return 1;
  113. +
  114. +
  115. + // -map (multipli) es -map 0:0 -map 0:1
  116. + if ( !is_map (argc, argv, &dati) )
  117. + return 1;
  118. +
  119. +
  120. + // bitrate in k, es: -b 500 default: 730k AVC 1500k ASP
  121. + if ( !video_bit_rate (argc, argv, &dati) )
  122. + return 1;
  123. +
  124. +
  125. + // parametri video: default preset="-preset faster -tune film"
  126. + // -fast -medium -slow
  127. + is_preset (argc, argv, &dati);
  128. +
  129. +
  130. + // profile: -main -high, default auto
  131. + is_profile (argc, argv, &dati);
  132. +
  133. +
  134. + // opts264
  135. + // -nopts = parametri del preset senza tuning personale
  136. + is_nopts (argc, argv, &dati);
  137. +
  138. +
  139. + // opencl lookahead
  140. + // -opencl
  141. + is_opencl (argc, argv, &dati);
  142. +
  143. +
  144. + // -nr x264 fastdenoise da 100 a 1000 -nr200 -nr500
  145. + // non usare se usate -vf |denoiser|
  146. + is_nr_denoise (argc, argv, &dati);
  147. +
  148. +
  149. + // -level1 to 5, default auto
  150. + is_level (argc, argv, &dati);
  151. +
  152. +
  153. + // -10bit = x264 10 bit depth
  154. + is_10bit (argc, argv, &dati);
  155. +
  156. + // -af audio filter (solo i parametri -af " " va aggiunto alla fine)
  157. + if ( !is_afilter (argc, argv, &dati) )
  158. + return 1;
  159. +
  160. + // -avolume -20 20 (db)
  161. + if ( !is_avolume (argc, argv, &dati) )
  162. + return 1;
  163. +
  164. + // -acomp ffmpeg audio compader filter
  165. + if ( !is_acomp (argc, argv, &dati) )
  166. + return 1;
  167. +
  168. + // audio
  169. + // -a32 -a64 -a96 -a128 -acopy -an
  170. + // -aaq 80-160
  171. + // -alameq 0-9
  172. + // -alame 32-320 (K)
  173. + if ( !is_audio (argc, argv, &dati) )
  174. + return 1;
  175. +
  176. + // -aboost // solo per fdk_aac - dopo avi altrimenti i confronti audio_parm non funzionano
  177. + is_aboost (argc, argv, &dati);
  178. +
  179. + // -pass passate 1,2 o 3 (3 solo x264)
  180. + if ( !passate (argc, argv , &dati) )
  181. + return 1;
  182. +
  183. +
  184. + // -nofast -fastfirstpass 0 (solo x264)
  185. + no_fast (argc, argv, &dati);
  186. +
  187. +
  188. + // filtri -vf deshake,pp=ac/al
  189. + if ( !is_filter (argc, argv, &dati) )
  190. + return 1;
  191. +
  192. +
  193. + // tempo start e durata, esempio -ss 00:03:00 -t 00:05:00 oppure -ss 120 -t 60
  194. + // -ss -t
  195. + if ( !is_ss_is_t (argc, argv, &dati) )
  196. + return 1;
  197. +
  198. +
  199. + // -log logfile ffmpeg
  200. + is_log (argc, argv, &dati);
  201. +
  202. +
  203. + // -mp4 .mp4
  204. + is_mp4_out (argc, argv, &dati);
  205. +
  206. +
  207. + // -mpeg4
  208. + // -avi
  209. + // -xvid
  210. + if ( !is_mpeg4_avi_xvid (argc, argv, &dati) )
  211. + return 1;
  212. +
  213. + // -crf 19.0 (0-50) solo se VIDEO_IS_X_264
  214. + if ( !is_crf (argc, argv, &dati) )
  215. + return 1;
  216. +
  217. + //// altri parametri
  218. + // -nometa -map_metadata -1
  219. + // -scopy -c:s copy subtitles
  220. + is_altro (argc, argv, &dati);
  221. +
  222. +
  223. + // -vcopy = -c:v copy
  224. + // -copy = -c copy
  225. + // -vn = -vn
  226. + is_vcopy_copy (argc, argv, &dati);
  227. +
  228. +
  229. + // -aspect 4:3 16/9 (da usare solo con video copy,
  230. + // se codificate -vf setdar=16/9)
  231. + if ( !is_aspect (argc, argv, &dati) )
  232. + return 1;
  233. +
  234. +
  235. + // -h help in posizione > 1
  236. + for (int i=2; i<argc; i++)
  237. + {
  238. + if (std::string(argv[i]) == "-h")
  239. + {
  240. + stampa_help(argv[0]);
  241. + return 0;
  242. + }
  243. + }
  244. +
  245. +
  246. + // utility mkvinfo
  247. + if ( !is_util_mkvinfo (argc, argv, &dati) )
  248. + return 0;
  249. +
  250. + // utility mgm (mkvmerge gui)
  251. + if ( !is_util_mkvmerge (argc, argv, &dati) )
  252. + return 0;
  253. +
  254. + // utility probe
  255. + if ( !is_util_probe (argc, argv, &dati) )
  256. + return 0;
  257. +
  258. +
  259. + // utility play (preview con -map -ss e -vf)
  260. + if ( !is_util_play (argc, argv, &dati))
  261. + return 0;
  262. +
  263. + // utility -hf filter, -h filter=unsharp
  264. + if ( !is_util_help_filter (argc, argv) )
  265. + return 0;
  266. +
  267. + // utility vftest 2 video verticali
  268. + // filtervalore per utility vftest
  269. + if ( !is_util_vftest (argc, argv, &dati) )
  270. + return 0;
  271. +
  272. + // utility vftestsp video split
  273. + if ( !is_util_vftestsp (argc, argv, &dati) )
  274. + return 0;
  275. +
  276. + // utility calcola scala proporzionale
  277. + // calc 720 0 16 9 oppure calc 0 480 4 3
  278. + if ( !is_util_calc_scale (argc, argv) )
  279. + return 0;
  280. +
  281. + // utility showwaves
  282. + if ( !is_util_showwaves (argc, argv, &dati) )
  283. + return 0;
  284. +
  285. + // utility showspectrum
  286. + if ( !is_util_showspectrum (argc, argv, &dati) )
  287. + return 0;
  288. +
  289. + // utility ebur128 (ebu r128)
  290. + if ( !is_util_ebur128 (argc, argv, &dati) )
  291. + return 0;
  292. +
  293. + // utility dbcalc db to ratio
  294. + if ( !is_util_dbcalc (argc, argv, &dati) )
  295. + return 0;
  296. +
  297. + // utility scrivi leggi settaggi su file
  298. + // save | load nomefile (con o senza .estensione e senza spazi)
  299. + if ( !is_load_save (argc, argv, &dati) )
  300. + return 0;
  301. +
  302. + // utility
  303. + // muxer nomefile2audio
  304. + if ( !is_muxer (argc, argv, &dati)
  305. + )
  306. + return 0;
  307. +
  308. + // utility
  309. + // volumedet = -af volumedetect
  310. + if ( !is_util_volumedetect (argc, argv, &dati) )
  311. + return 0;
  312. +
  313. + // sox
  314. + if ( !is_util_sox (argc, argv, &dati) )
  315. + return 0;
  316. +
  317. + // utility time
  318. + if ( !is_util_time (argc, argv, &dati) )
  319. + return 0;
  320. +
  321. + // nome fileout
  322. + // check se fileout esiste e nel caso rinomina _N_.ext
  323. + dati.nuovo_nome_file_out = check_fileout_name_e_rename (dati.nome_file_senza_ext, dati.nuova_estensione);
  324. +
  325. + //
  326. +
  327. + printf ("\n");
  328. +
  329. + // check parametri totali in input
  330. + if (dati.param_tot_previsti > argc)
  331. + {
  332. + dati.debug = true;
  333. + printf ("\n\nVerificare i parametri inseriti:\n");
  334. + printf ("Immessi %i, previsti %i\n\n",argc, dati.param_tot_previsti);
  335. + }
  336. +
  337. +
  338. + // esecuzione
  339. +
  340. + if ( !build_fin_eseg (&dati) )
  341. + return 1;
  342. +
  343. + return 0;
  344. +}
  345. +
  346. +
  347. +
  348. +
  349. diff -Naur -x '*~' src/f-help.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/f-help.cpp
  350. --- src/f-help.cpp 1970-01-01 01:00:00.000000000 +0100
  351. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/f-help.cpp 2013-11-10 16:19:21.894492187 +0100
  352. @@ -0,0 +1,80 @@
  353. +#include "funzioni.h"
  354. +
  355. +////
  356. +
  357. +void stampa_help(char * prg)
  358. +{
  359. + printf ("\n");
  360. + printf ("%s \n", prg);
  361. + printf (" nomefile [obbligatorio]\n");
  362. + printf (" [opzioni]\n");
  363. + printf (" -b bitrate video [kb] (-b 600, default: 730 AVC, 1500 ASP)\n");
  364. + printf (" -crf [0.0-50.0] (solo x264, default 19.0, 1 pass crf)\n");
  365. + printf (" -pass passate (-pass 2, -pass 3, default: singola)\n");
  366. + printf (" -nofast (-fastfirstpass 0, default 1)\n");
  367. + printf (" -audio (-a32 -a64 (aacplus 32k 64k)\n");
  368. + printf (" -a96 -a128 (aac_fdk: 96k 128k, default: 112k)\n");
  369. + printf (" -aaq [80-160] (faac vbr q 80 ~96k, 90 ~100k, 120 ~128k, 160 ~156k, default 100 ~118k)\n");
  370. + printf (" -alameq [0-9] (lame vbr q 0 ~245k, 5 ~130k, 6 ~115k, 9 ~65k, default 6)\n");
  371. + printf (" -alame [32-320] (lame cbr da 32 a 320k, default 128 )\n");
  372. + printf (" -an (no audio), -acopy (copia))\n");
  373. + printf (" -aboost (aac_fdk -afterburner 1)\n");
  374. + printf (" -avolume -20 20 (varia il volume audio da -20 a +20db.\n");
  375. + printf (" usare prima volumedet per stabilire il fattore)\n");
  376. + printf (" -acomp [std|film2|film3] [n] gain da -30 a 12 (default film, 0, ffmpeg compader audio)\n");
  377. + printf (" -vcopy (-c:v copy, default no)\n");
  378. + printf (" -vn (no video, out.mka)\n");
  379. + printf (" -mpeg4 (-c:v mpeg4 -c:a libmp3lame 128k, out.mkv)\n");
  380. + printf (" -avi (come -mpeg4, out.avi)\n");
  381. + printf (" -xvid (-vtag XVID, come mpeg4)\n");
  382. + printf (" -mp4 (.mp4, incompatibile con -avi -xvid)\n");
  383. + printf (" -copy (-c copy, default no)\n");
  384. + printf (" -scopy (-c:s copy, subtitles, default no -> ass)\n");
  385. + printf (" -map (multipli, es: -map 0:1 -map 0:0)\n");
  386. + printf (" -preset (-fast, -medium, -slow, default: faster)\n");
  387. + printf (" -profile (-main, -high, default: auto)\n");
  388. + printf (" -level (da -level1 a -level5, default: auto)\n");
  389. + printf (" -nopts (x264opts = nulla, default: le mie)\n");
  390. + printf (" -opencl (x264 OpenCL lookahead, default: no)\n");
  391. + printf (" -nr200 -nr500 (x264 noise reduction nr=200 or 500, default: no\n");
  392. + printf (" non usare in contemporanea a -vf [denoise])\n");
  393. + printf (" -10bit (x264 10bit depth, default: no)\n");
  394. + printf (" -vf filtri (-vf pp=ac,hqdn3d=3)\n");
  395. + printf (" -af filtri audio (-vf \"volume=enable='between(t,0,45)':volume=-6db\")\n");
  396. + printf (" -ss inizio HH:MM:SS o sec (-ss 00:01:00 -ss 60)\n");
  397. + printf (" -t durata HH:MM:SS o sec (-t 00:02:00 -t 120)\n");
  398. + printf (" -r rate (-r 25, default auto come sorgente)\n");
  399. + printf (" -nometa (come -map_metadata -1, default no)\n");
  400. + printf (" -aspect (4:3 4/3 16:9, da usare solo con -copy -vcopy -mpeg4)\n");
  401. + printf (" debug (stampa solo i comandi senza eseguire)\n");
  402. + printf (" -log (-psnr -report su logfile)\n");
  403. + printf (" [Utility]\n");
  404. + printf (" play (esegue ffplay nomefile con -vf -ss e -map)\n");
  405. + printf (" probe (esegue ffprobe nomefile)\n");
  406. + printf (" -hf filtro (help filtro, come ffmpeg -h filter=yadif)\n");
  407. + printf (" vftest (esegue ffplay nomefile in 2 finestre con -vf applicati e -ss)\n");
  408. + printf (" vftestsp (come spopra ma split verticale, per test unsharp,hqdn3d,hue ...)\n");
  409. + printf (" showwaves (visualizza onda audio, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
  410. + printf (" showspectrum (visualizza spettro audio, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
  411. + printf (" ebur128 (loudnesss audio ebu r128, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
  412. + printf (" calc 640 0 16 9 (oppure 0 480 4 3, calcola scale con proporzioni in multipli di 8)\n");
  413. + printf (" mkvinfo (fornisce informazioni sugli stream di un .mkv per estrarli poi con mkvextract)\n");
  414. + printf (" mmg (mkvmerge gui)\n");
  415. + printf (" save | load nomefile (senza .estensione e senza spazi) \n");
  416. + printf (" salva carica i settaggi per uso seriale. \n");
  417. + printf (" volumedet (statistiche sul livello dell'audio, supporta -map -t -ss)\n");
  418. + printf (" dbcalc db (20 -20) da db a fattore di amplificazione\n");
  419. + printf (" sox norm | comp | compf | fastdet | compfast [noshow mux]\n");
  420. + printf (" (usa sox per normalizzare | compand l'audio in un file .mka.\n");
  421. + printf (" compfast non normalizza, gli altri richiedono molto spazio disco,\n");
  422. + printf (" validi i set audio -t -ss e -map, noshow sox progress, con compfast -avolume\n");
  423. + printf (" mux muxa in un file .mkv.)\n");
  424. + printf (" muxer nomesecondofile [mkv|avi|mp4] (muxa il video del filein con l'audio del secondo file.\n");
  425. + printf (" se non sono specificati -map usa -map 0:0 -map 1:0)\n");
  426. + printf (" time in out (hh:mm:ss o sec) calcola durata -t\n");
  427. + printf ("\n");
  428. + printf ("esempio:\n");
  429. + printf ("\n");
  430. + printf ("%s video.mp4 -b 800 -pass 2 -a32 fast -vf pp=ac,hqdn3d=3\n", prg);
  431. + printf ("\n");
  432. +}
  433. diff -Naur -x '*~' src/funzioni.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.cpp
  434. --- src/funzioni.cpp 1970-01-01 01:00:00.000000000 +0100
  435. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.cpp 2013-09-08 16:35:15.472650505 +0200
  436. @@ -0,0 +1,306 @@
  437. +#include "funzioni.h"
  438. +
  439. +////////////////////////////////////////////////////////////////
  440. +
  441. +void stampatempo (double time_target)
  442. +{
  443. + const int ONE_HOUR = 60 * 60;
  444. + const int ONE_MINUTE = 60;
  445. +
  446. + int hour;
  447. + int min;
  448. + int sec;
  449. +
  450. + hour=time_target/ONE_HOUR;
  451. + time_target-=hour*ONE_HOUR;
  452. + min=time_target/ONE_MINUTE;
  453. + time_target-=min*ONE_MINUTE;
  454. + sec=time_target;
  455. +
  456. + printf("%02dh:%02dm:%02ds\n",hour,min,sec);
  457. +
  458. +}
  459. +
  460. +////
  461. +
  462. +std::string str_stampatempo (double time_target)
  463. +{
  464. +
  465. + const int ONE_HOUR = 60 * 60;
  466. + const int ONE_MINUTE = 60;
  467. +
  468. + int hour;
  469. + int min;
  470. + int sec;
  471. +
  472. + hour=time_target/ONE_HOUR;
  473. + time_target-=hour*ONE_HOUR;
  474. + min=time_target/ONE_MINUTE;
  475. + time_target-=min*ONE_MINUTE;
  476. + sec=time_target;
  477. + char buffer [20];
  478. + sprintf(buffer,"%02dh:%02dm:%02ds\n",hour,min,sec);
  479. + return ( buffer );
  480. +
  481. +}
  482. +
  483. +
  484. +////
  485. +
  486. +std::string removeExtension (const std::string filename)
  487. +{
  488. + size_t lastdot = filename.find_last_of(".");
  489. + if (lastdot == std::string::npos) return filename;
  490. + return filename.substr(0, lastdot);
  491. +}
  492. +
  493. +////
  494. +
  495. +bool fileExists(const std::string& filename)
  496. +{
  497. + struct stat buf;
  498. + if (stat(filename.c_str(), &buf) != -1)
  499. + {
  500. + return true;
  501. + }
  502. + return false;
  503. +}
  504. +
  505. +////
  506. +
  507. +std::string tipo_ext (std::string file)
  508. +{
  509. + int found = file.find_last_of(".");
  510. + if (found != -1)
  511. + return (file.substr(found));
  512. + else
  513. + return "";
  514. +}
  515. +
  516. +////
  517. +
  518. +int esegui (const char* daeseg)
  519. +{
  520. + FILE * f = popen( daeseg, "r" );
  521. + if ( f == 0 )
  522. + {
  523. + fprintf( stderr, "Could not execute\n" );
  524. + return 1;
  525. + }
  526. + const int BUFSIZE = 1000;
  527. + char buf[ BUFSIZE ];
  528. + while( fgets( buf, BUFSIZE, f ) )
  529. + {
  530. + fprintf( stdout, "%s", buf );
  531. + }
  532. + pclose( f );
  533. + return 0;
  534. +}
  535. +
  536. +////
  537. +
  538. +std::string rimuovi_path (std::string file)
  539. +{
  540. + unsigned found = file.find_last_of("/\\");
  541. + return (file.substr(found+1));
  542. +}
  543. +
  544. +////
  545. +
  546. +std::string leggi_str_da_file (FILE * pFile )
  547. +{
  548. + char buffer_string [255];
  549. + std::string var;
  550. + fgets (buffer_string , 255 , pFile);
  551. + var = buffer_string;
  552. + var.erase ( var.size() -1);
  553. + return var;
  554. +}
  555. +
  556. +////
  557. +
  558. +int leggi_int_da_file (FILE * pFile )
  559. +{
  560. + char buffer_string [255];
  561. + int var;
  562. + fgets (buffer_string , 255 , pFile);
  563. + var = atoi (buffer_string); // pass è int
  564. + return var;
  565. +}
  566. +
  567. +////
  568. +
  569. +void scrivi_str_su_file (FILE * pFile, std::string var)
  570. +{
  571. + char buffer_string [255];
  572. + sprintf (buffer_string, "%s\n",var.c_str()) ;
  573. + fputs (buffer_string,pFile);
  574. +}
  575. +
  576. +////
  577. +
  578. +void scrivi_int_su_file (FILE * pFile, int var)
  579. +{
  580. + char buffer_string [255];
  581. + sprintf (buffer_string, "%i\n",var);
  582. + fputs (buffer_string,pFile);
  583. +}
  584. +
  585. +////
  586. +
  587. +void calcola_proporzioni (int w, int h, int aw, int ah)
  588. +{
  589. + float tmp;
  590. + if (h == 0)
  591. + {
  592. + tmp = ( float (w) / float (aw) ) * float (ah);
  593. + h = tmp;
  594. + if (w%2 != 0) // w è dispari
  595. + w = w +1;
  596. + if (h%2 != 0)
  597. + h = h +1;
  598. + }
  599. + else if (w == 0)
  600. + {
  601. + tmp = ( float (h) / float (ah) ) * float (aw);
  602. + w = tmp;
  603. + if (h%2 != 0)
  604. + h = h +1;
  605. + if (w%2 != 0)
  606. + w = w +1;
  607. + }
  608. + printf ("\npiù prossima:\n");
  609. + printf ("\n-vf scale=%i:%i:flags=lanczos,setsar=1/1,setdar=%i/%i\n",w,h,aw,ah);
  610. +}
  611. +
  612. +////
  613. +
  614. +void calcola_proporzioni_8 (int w, int h, int aw, int ah)
  615. +{
  616. + float tmp;
  617. + if (h == 0)
  618. + {
  619. + tmp = ( float (w) / float (aw) ) * float (ah);
  620. + h = tmp;
  621. + if (h%2 != 0)
  622. + h = h +1;
  623. + h = (h / 8) * 8;
  624. + w = (w / 8) * 8;
  625. + }
  626. + else if (w == 0)
  627. + {
  628. + tmp = ( float (h) / float (ah) ) * float (aw);
  629. + w = tmp;
  630. + if (w%2 != 0)
  631. + w = w +1;
  632. + w = (w / 8) * 8;
  633. + h = (h / 8) * 8;
  634. + }
  635. + printf ("\nmultipla di 8:\n");
  636. + printf ("\n-vf scale=%i:%i:flags=lanczos,setsar=1/1,setdar=%i/%i\n\n",w,h,aw,ah);
  637. +}
  638. +
  639. +////
  640. +
  641. +void stampa_info_file (std::string nome_del_file)
  642. +{
  643. + struct stat filestatus;
  644. + float size;
  645. + char dimensioni [20];
  646. + struct tm * timeinfo;
  647. + char data [80];
  648. + stat( nome_del_file.c_str(), &filestatus );
  649. + size = filestatus.st_size;
  650. + if (size < (1024.0 * 1024.0 * 2) )
  651. + {
  652. + size = size / (1024.0);
  653. + sprintf (dimensioni, "%6.1f KB", size );
  654. + }
  655. + else if ( size < (1024.0 * 1024.0 * 1024.0 * 2) && size >= (1024.0 * 1024.0 * 2) )
  656. + {
  657. + size = size / (1024.0 * 1024.0);
  658. + sprintf (dimensioni, "%6.1f MB", size );
  659. + }
  660. + else if (size >= (1024.0 * 1024.0 * 1024.0 * 2) )
  661. + {
  662. + size = size / (1024.0 * 1024.0 * 1024.0);
  663. + sprintf (dimensioni, "%6.2f GB", size );
  664. + }
  665. + timeinfo = localtime (&filestatus.st_mtime);
  666. + strftime (data,80,"%a %d %b %Y %T",timeinfo);
  667. + printf ("%s - %s - %s\n", dimensioni , data , nome_del_file.c_str() );
  668. +}
  669. +
  670. +////
  671. +
  672. +std::string str_stampa_info_file (std::string nome_del_file)
  673. +{
  674. + struct stat filestatus;
  675. + float size;
  676. + char dimensioni [20];
  677. + struct tm * timeinfo;
  678. + char data [80];
  679. + stat( nome_del_file.c_str(), &filestatus );
  680. + size = filestatus.st_size;
  681. + if (size < (1024.0 * 1024.0 * 2) )
  682. + {
  683. + size = size / (1024.0);
  684. + sprintf (dimensioni, "%6.1f KB", size );
  685. + }
  686. + else if ( size < (1024.0 * 1024.0 * 1024.0 * 2) && size >= (1024.0 * 1024.0 * 2) )
  687. + {
  688. + size = size / (1024.0 * 1024.0);
  689. + sprintf (dimensioni, "%6.1f MB", size );
  690. + }
  691. + else if (size >= (1024.0 * 1024.0 * 1024.0 * 2) )
  692. + {
  693. + size = size / (1024.0 * 1024.0 * 1024.0);
  694. + sprintf (dimensioni, "%6.2f GB", size );
  695. + }
  696. + timeinfo = localtime (&filestatus.st_mtime);
  697. + strftime (data,80,"%a %d %b %Y %T",timeinfo);
  698. + char buffer [255];
  699. + sprintf (buffer,"%s - %s - %s\n", dimensioni , data , nome_del_file.c_str() );
  700. + return ( buffer );
  701. +}
  702. +
  703. +
  704. +////
  705. +
  706. +bool check_num_param (int argc, int i, int num_previsti_dopo)
  707. +{
  708. + if ( (argc - 1) < (i + num_previsti_dopo) )
  709. + {
  710. + printf ("\nErrore: parametri insufficienti.\n\n");
  711. + return false;
  712. + }
  713. + return true; // ok
  714. +}
  715. +
  716. +////
  717. +
  718. +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione)
  719. +{
  720. + // nome fileout
  721. + std::string nome_file_out (nome_del_file_senza_estensione + estensione);
  722. + // check se fileout esiste e nel caso rinomina _N_.ext
  723. + char buffer_ifile [3];
  724. + for (int i=2; i<=9; i++)
  725. + {
  726. + if ( fileExists (nome_file_out.c_str()) )
  727. + {
  728. + sprintf (buffer_ifile, "%i", i); // i è int
  729. + nome_file_out = nome_del_file_senza_estensione + "_" + buffer_ifile + "_" + estensione;
  730. + }
  731. + }
  732. + return (nome_file_out);
  733. +}
  734. +
  735. +////
  736. +
  737. +bool is_number(const std::string& s)
  738. +{
  739. + return ( strspn( s.c_str(), "-.0123456789" ) == s.size() );
  740. +}
  741. +
  742. +////
  743. diff -Naur -x '*~' src/funzioni.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.h
  744. --- src/funzioni.h 1970-01-01 01:00:00.000000000 +0100
  745. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.h 2013-08-28 16:11:25.551934004 +0200
  746. @@ -0,0 +1,38 @@
  747. +#ifndef FUNZIONI_H
  748. +#define FUNZIONI_H
  749. +
  750. +#ifndef NEED_LIBS_H
  751. +#define NEED_LIBS_H
  752. +#include <string>
  753. +#include <stdio.h>
  754. +#include <sys/types.h>
  755. +#include <sys/stat.h>
  756. +#include <time.h>
  757. +#include <stdlib.h> /* atoi */
  758. +#include <locale.h>
  759. +#include <string.h>
  760. +#endif
  761. +
  762. +////
  763. +void stampatempo (double time_target);
  764. +std::string str_stampatempo (double time_target);
  765. +std::string removeExtension (const std::string filename);
  766. +bool fileExists(const std::string& filename);
  767. +std::string tipo_ext (std::string file);
  768. +int esegui (const char* daeseg); // 0
  769. +std::string rimuovi_path (std::string file);
  770. +std::string leggi_str_da_file (FILE * pFile );
  771. +int leggi_int_da_file (FILE * pFile );
  772. +void scrivi_str_su_file (FILE * pFile, std::string var);
  773. +void scrivi_int_su_file (FILE * pFile, int var);
  774. +void calcola_proporzioni (int w, int h, int aw, int ah);
  775. +void calcola_proporzioni_8 (int w, int h, int aw, int ah);
  776. +void stampa_info_file (std::string nome_del_file);
  777. +std::string str_stampa_info_file (std::string nome_del_file);
  778. +bool check_num_param (int argc, int i, int num_previsti_dopo);
  779. +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione);
  780. +bool is_number(const std::string& s);
  781. +////
  782. +void stampa_help(char * testo);
  783. +////
  784. +#endif
  785. diff -Naur -x '*~' src/main.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/main.h
  786. --- src/main.h 1970-01-01 01:00:00.000000000 +0100
  787. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/main.h 2013-09-15 17:55:31.520040800 +0200
  788. @@ -0,0 +1,120 @@
  789. +#ifndef MAIN_H
  790. +#define MAIN_H
  791. +
  792. +#ifndef NEED_LIBS_H
  793. +#define NEED_LIBS_H
  794. +#include <string>
  795. +#include <stdio.h>
  796. +#include <sys/types.h>
  797. +#include <sys/stat.h>
  798. +#include <time.h>
  799. +#include <stdlib.h> /* atoi */
  800. +#include <locale.h>
  801. +#include <math.h> /* pow */
  802. +#include <string.h>
  803. +#endif
  804. +
  805. +struct s_dati
  806. +{
  807. + std::string nomefilein; // con path
  808. + std::string nomedelfile; // senza path
  809. + std::string nome_file_senza_ext;
  810. + std::string estensione_file_in;
  811. + std::string eseguibile;
  812. + std::string nuova_estensione;
  813. + bool debug;
  814. + std::string rate;
  815. + std::string maps;
  816. + std::string vcodec;
  817. + std::string video_codec_is;
  818. + std::string bitrate_video;
  819. + int b_v_rate;
  820. + std::string preset;
  821. + std::string profile;
  822. + std::string set_264;
  823. + std::string audio_parm;
  824. + std::string audio_codec_is;
  825. + int pass;
  826. + bool nofastfirst;
  827. + std::string filter;
  828. + std::string filtervalore;
  829. + std::string a_filter_valore;
  830. + std::string tempoin;
  831. + std::string tempodur;
  832. + std::string logfile;
  833. + std::string altro;
  834. + std::string aspetto;
  835. + std::string format_out;
  836. + std::string nuovo_nome_file_out;
  837. + std::string daeseguire;
  838. + std::string filsett_vers;
  839. + int param_tot_previsti;
  840. + std::string riepilogo;
  841. +};
  842. +
  843. +
  844. +// eseguibile ffmpeg
  845. +#define ESEGUIBILE_FFMPEG "ffmpeg2"
  846. +// eseguibile 10bit
  847. +#define ESEGUIBILE_10BIT "ffmpeg-x10bit"
  848. +// eseguibile play
  849. +#define ESEGUIBILE_PLAY "ffplay2"
  850. +// eseguibile probe
  851. +#define ESEGUIBILE_PROBE "ffprobe2"
  852. +// eseguibile mkvinfo
  853. +#define ESEGUIBILE_MKVINFO "mkvinfo-gui -g"
  854. +// default e opzioni
  855. +#define NUOVA_EXT_AVI ".avi"
  856. +#define NUOVA_EXT_MP4 ".mp4"
  857. +#define NUOVA_EXT_MKV ".mkv"
  858. +#define NUOVA_EXT_MKA ".mka"
  859. +#define VCODEC_X264 "-c:v libx264"
  860. +#define VCODEC_MPEG4 "-c:v mpeg4 -mpv_flags strict_gop"
  861. +#define VCODEC_VCOPY "-c:v copy"
  862. +#define VCODEC_NONE "-vn"
  863. +#define VCODEC_COPY_ALL "-c copy"
  864. +#define XVID_TAG "-vtag XVID"
  865. +#define VIDEO_IS_X_264 "video_is_x_264"
  866. +#define VIDEO_IS_MPEG4 "video_is_mpeg4"
  867. +#define VIDEO_IS_MPEG4_XVID "video_is_mpeg4_xvid"
  868. +#define BITRATE_VIDEO_X264_DEFAULT "-b:v 730k"
  869. +#define BITRATE_VIDEO_MPEG4_DEFAULT "-b:v 1500k"
  870. +#define PRESET_FASTER "-preset faster -tune film"
  871. +#define PRESET_FAST "-preset fast -tune film"
  872. +#define PRESET_MEDIUM "-preset medium -tune film"
  873. +#define PRESET_SLOW "-preset slow -tune film"
  874. +#define PROFILE_MAIN "-profile:v main"
  875. +#define PROFILE_HIGH "-profile:v high"
  876. +#define OPT_264_1 "-x264opts ref=4:bframes=4:direct=auto:aq-strength=1.3:ssim"
  877. +#define OPT_264_NOPTS "-x264opts ssim"
  878. +#define LEVEL_1_0 "level=1.0:ref=1:bframes=0:vbv-bufsize=218:vbv-maxrate=80"
  879. +#define LEVEL_2_0 "level=2.0:ref=2:b-pyramid=none:vbv-bufsize=2500:vbv-maxrate=2500"
  880. +#define LEVEL_3_0 "level=3.0:vbv-bufsize=12500:vbv-maxrate=12500"
  881. +#define LEVEL_4_0 "level=4.0:vbv-bufsize=25000:vbv-maxrate=20000"
  882. +#define LEVEL_5_0 "level=5.0:vbv-bufsize=168750:vbv-maxrate=168750"
  883. +#define AUDIO_PARM_AP32 "-c:a libaacplus -b:a 32k -ar 48k -ac 2"
  884. +#define AUDIO_PARM_AP64 "-c:a libaacplus -b:a 64k -ar 48k -ac 2"
  885. +#define AUDIO_PARM_AF96 "-c:a libfdk_aac -b:a 96k -ar 48k -ac 2"
  886. +#define AUDIO_PARM_AF112 "-c:a libfdk_aac -b:a 112k -ar 48k -ac 2"
  887. +#define AUDIO_PARM_AF128 "-c:a libfdk_aac -b:a 128k -ar 48k -ac 2"
  888. +#define AUDIO_PARM_COPY "-c:a copy"
  889. +#define AUDIO_PARM_NONE "-an"
  890. +#define AUDIO_PARM_LAME_C128 "-c:a libmp3lame -b:a 128k -ar 48k -ac 2"
  891. +#define AUDIO_BOOST_FDK "-afterburner 1" // solo per fdk_aac
  892. +#define AUDIO_IS_LAME "audio_is_lame"
  893. +#define AUDIO_IS_FDKAAC "audio_is_fdkaac"
  894. +#define AUDIO_IS_AACPLUS "audio_is_aacplus"
  895. +#define AUDIO_IS_FAAC "audio_is_faac"
  896. +#define FILESETTAGGI_EXT ".fftlset"
  897. +#define FAST_1_PASS "-fastfirstpass 1"
  898. +#define FORMAT_NULL "-f null"
  899. +#define FORMAT_OUT_AVI "-f avi"
  900. +#define FORMAT_OUT_MP4 "-f mp4"
  901. +#define FORMAT_OUT_MATROSKA "-f matroska"
  902. +#define OUT_NULL "/dev/null" // linux
  903. +#define FILTRO_FFMPEG_OUTPUT "2>&1 | grep -Ev 'configuration|built on|FFmpeg developers|libavutil|libavcodec|libavformat|libavfilter|libavdevice|libavdevice|libswscale|libswresample|libpostproc'"
  904. +
  905. +#endif
  906. +
  907. +
  908. +
  909. diff -Naur -x '*~' src/makefile /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/makefile
  910. --- src/makefile 1970-01-01 01:00:00.000000000 +0100
  911. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/makefile 2013-09-15 16:07:21.000000000 +0200
  912. @@ -0,0 +1,20 @@
  913. +all:
  914. + g++ -O3 -o 730-ffmpeg-tool-2 \
  915. + funzioni.cpp \
  916. + f-help.cpp \
  917. + routines/routines.cpp \
  918. + routines/r-video-generali.cpp \
  919. + routines/r-video-x264.cpp \
  920. + routines/r-video-asp-avi.cpp \
  921. + routines/r-audio.cpp \
  922. + routines/r-util.cpp \
  923. + routines/r-util-sox.cpp \
  924. + routines/r-file-sett.cpp \
  925. + routines/r-build-fin.cpp \
  926. + 730-ffmpeg-tool-main.cpp -s
  927. +
  928. +
  929. +clean:
  930. + rm -f *.o *.a *~ routines/*.o routines/*~ 730-ffmpeg-tool-2
  931. +
  932. +
  933. diff -Naur -x '*~' src/routines/r-audio.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.cpp
  934. --- src/routines/r-audio.cpp 1970-01-01 01:00:00.000000000 +0100
  935. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.cpp 2013-10-04 13:01:09.258847993 +0200
  936. @@ -0,0 +1,267 @@
  937. +#include "../main.h"
  938. +#include "../funzioni.h"
  939. +#include "r-audio.h"
  940. +
  941. +bool is_audio (int argc, char * argv[], s_dati *dati)
  942. +{
  943. + // audio
  944. + for (int i=2; i<argc; i++)
  945. + {
  946. +
  947. + if (std::string(argv[i]) == "-a32")
  948. + {
  949. + dati->audio_parm = AUDIO_PARM_AP32;
  950. + dati->audio_codec_is = AUDIO_IS_AACPLUS;
  951. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  952. + break;
  953. + }
  954. + if (std::string(argv[i]) == "-a64")
  955. + {
  956. + dati->audio_parm = AUDIO_PARM_AP64;
  957. + dati->audio_codec_is = AUDIO_IS_AACPLUS;
  958. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  959. + break;
  960. + }
  961. + if (std::string(argv[i]) == "-a96")
  962. + {
  963. + dati->audio_parm = AUDIO_PARM_AF96;
  964. + dati->audio_codec_is = AUDIO_IS_FDKAAC;
  965. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  966. + break;
  967. + }
  968. + if (std::string(argv[i]) == "-a128")
  969. + {
  970. + dati->audio_parm = AUDIO_PARM_AF128;
  971. + dati->audio_codec_is = AUDIO_IS_FDKAAC;
  972. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  973. + break;
  974. + }
  975. + if (std::string(argv[i]) == "-aaq")
  976. + {
  977. + // check argomento 80 to 160
  978. + int q (100); //default 100 vbr 118k
  979. + if ( argc-1 >= i+1 )
  980. + {
  981. + if ( is_number( argv[i+1]) )
  982. + {
  983. + q = atoi(argv[i+1]);
  984. + if ( q < 80 || q > 160)
  985. + {
  986. + printf ("\nInserire un q corretto (80-160) vbr 80 ~96k, 90 ~100k, 120 ~128k, 160 ~156k.\n\n");
  987. + return false;
  988. + }
  989. + }
  990. + }
  991. + char qfact [4];
  992. + sprintf(qfact,"%i",q);
  993. +
  994. + std::string audio_parm_aaq = "-c:a libfaac -q:a " + (std::string)qfact + " -ar 48k -ac 2";
  995. + dati->audio_parm = audio_parm_aaq;
  996. + dati->audio_codec_is = AUDIO_IS_FAAC;
  997. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  998. + break;
  999. + }
  1000. + if (std::string(argv[i]) == "-acopy")
  1001. + {
  1002. + dati->audio_parm = AUDIO_PARM_COPY;
  1003. + dati->audio_codec_is = "";
  1004. + dati->a_filter_valore = "";
  1005. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1006. + break;
  1007. + }
  1008. + if (std::string(argv[i]) == "-an")
  1009. + {
  1010. + dati->audio_parm = AUDIO_PARM_NONE;
  1011. + dati->audio_codec_is = "";
  1012. + dati->a_filter_valore = "";
  1013. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1014. + break;
  1015. + }
  1016. + if (std::string(argv[i]) == "-alameq")
  1017. + {
  1018. + // check argomento 0 to 9
  1019. + int q (6); //default 6 vbr 115k
  1020. + if ( argc-1 >= i+1 )
  1021. + {
  1022. + if ( is_number( argv[i+1]) )
  1023. + {
  1024. + q = atoi(argv[i+1]);
  1025. + if ( q < 0 || q > 9)
  1026. + {
  1027. + printf ("\nInserire un q corretto (0-9) vbr 0=245k 6=115k 9=65k.\n\n");
  1028. + return false;
  1029. + }
  1030. + }
  1031. + }
  1032. + char qfact [2];
  1033. + sprintf(qfact,"%i",q);
  1034. +
  1035. + std::string audio_parm_lameq = "-c:a libmp3lame -q:a " + (std::string)qfact + " -ar 48k -ac 2";
  1036. + dati->audio_parm = audio_parm_lameq;
  1037. + dati->audio_codec_is = AUDIO_IS_LAME;
  1038. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1039. + break;
  1040. + }
  1041. + if (std::string(argv[i]) == "-alame")
  1042. + {
  1043. + int ba (128); // default
  1044. + if ( argc-1 >= i+1 )
  1045. + {
  1046. + if ( is_number(argv[i+1]) )
  1047. + {
  1048. + ba = atoi(argv[i+1]);
  1049. + // check argomento 32 to 320
  1050. + if ( ba < 32 || ba > 320)
  1051. + {
  1052. + printf ("\nInserire un bitrate audio corretto (32-320).\n\n");
  1053. + return false;
  1054. + }
  1055. + }
  1056. + }
  1057. + char buffer [5];
  1058. + sprintf(buffer,"%i",ba);
  1059. + std::string audio_parm_lameb = "-c:a libmp3lame -b:a " + (std::string)buffer + "k -ar 48k -ac 2";
  1060. + dati->audio_parm = audio_parm_lameb;
  1061. + dati->audio_codec_is = AUDIO_IS_LAME;
  1062. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1063. + break;
  1064. + }
  1065. + }
  1066. + return true;
  1067. +}
  1068. +
  1069. +void is_aboost (int argc, char * argv[], s_dati *dati)
  1070. +{
  1071. + // -aboost // solo per fdk_aac
  1072. + for (int i=2; i<argc; i++)
  1073. + {
  1074. + if (std::string(argv[i]) == "-aboost")
  1075. + {
  1076. + // solo audio fdk_aac
  1077. + if ( dati->audio_codec_is == AUDIO_IS_FDKAAC )
  1078. + {
  1079. + dati->audio_parm = dati->audio_parm + " " + AUDIO_BOOST_FDK;
  1080. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1081. + }
  1082. + break;
  1083. + }
  1084. + }
  1085. +}
  1086. +
  1087. +bool is_avolume (int argc, char * argv[], s_dati *dati)
  1088. +{
  1089. + for (int i=2; i<argc; i++)
  1090. + {
  1091. + if (std::string(argv[i]) == "-avolume")
  1092. + {
  1093. + if ( !check_num_param (argc,i,1) )
  1094. + {
  1095. + printf ("\nInserire un fattore di amplificazione in db (da -20.0 a 20.0).\n");
  1096. + printf ("Usare: volumedet per stabilirlo con precisione.\n");
  1097. + return false;
  1098. + }
  1099. + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
  1100. + double amp = atof(argv[i+1]);
  1101. + if ( amp < -20.0 || amp > 20.0 || amp == 0.0 )
  1102. + {
  1103. + printf ("\nInserire un fattore di amplificazione in db (da -20.0 a 20.0).\n");
  1104. + printf ("Usare: volumedet per stabilirlo con precisione.\n");
  1105. + return false;
  1106. + }
  1107. + // db to ratio
  1108. + float f_ratio = pow (10.0, (amp/20.0) );
  1109. + char ratio [10];
  1110. + sprintf (ratio,"%.3f",f_ratio);
  1111. + setlocale (LC_ALL,""); // ripristino locale
  1112. + if ( dati->a_filter_valore == "" )
  1113. + dati->a_filter_valore = "volume=" + (std::string)ratio;
  1114. + else
  1115. + dati->a_filter_valore = dati->a_filter_valore + "," + "volume=" + (std::string)ratio;
  1116. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1117. + break;
  1118. + }
  1119. + }
  1120. + return true;
  1121. +}
  1122. +
  1123. +bool is_afilter (int argc, char * argv[], s_dati *dati)
  1124. +{
  1125. + for (int i=2; i<argc; i++)
  1126. + {
  1127. + if (std::string(argv[i]) == "-af")
  1128. + {
  1129. + if ( !check_num_param (argc,i,1) )
  1130. + {
  1131. + printf ("-af necessita di un parametro.\n\n");
  1132. + return false;
  1133. + }
  1134. + std::string temp;
  1135. + temp = (argv[i+1]);
  1136. + if ( dati->a_filter_valore == "" )
  1137. + dati->a_filter_valore = temp;
  1138. + else
  1139. + dati->a_filter_valore = dati->a_filter_valore + "," + temp;
  1140. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1141. + break;
  1142. + }
  1143. + }
  1144. + return true;
  1145. +}
  1146. +
  1147. +bool is_acomp (int argc, char * argv[], s_dati *dati)
  1148. +{
  1149. + for (int i=2; i<argc; i++)
  1150. + {
  1151. + if (std::string(argv[i]) == "-acomp")
  1152. + {
  1153. + int prossimo = 1;
  1154. + std::string compader = FFMPEG_COMPAND_FILM_1; //default
  1155. +
  1156. + if ( argc-1 >= i+prossimo )
  1157. + {
  1158. + if (std::string(argv[i+prossimo]) == "std")
  1159. + {
  1160. + compader = FFMPEG_COMPAND_1;
  1161. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1162. + prossimo = prossimo + 1;
  1163. + }
  1164. + else if (std::string(argv[i+prossimo]) == "film2")
  1165. + {
  1166. + compader = FFMPEG_COMPAND_FILM_2;
  1167. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1168. + prossimo = prossimo + 1;
  1169. + }
  1170. + else if (std::string(argv[i+prossimo]) == "film3")
  1171. + {
  1172. + compader = FFMPEG_COMPAND_FILM_3;
  1173. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1174. + prossimo = prossimo + 1;
  1175. + }
  1176. + }
  1177. +
  1178. + std::string comp_gain = "0"; //default GAIN = 0
  1179. + if ( argc-1 >= i+prossimo )
  1180. + {
  1181. + std::string is_gain = (argv[i+prossimo]);
  1182. + if ( is_number(is_gain) )
  1183. + {
  1184. + int test = atoi( is_gain.c_str() );
  1185. + if (test < 13 && test > -30)
  1186. + {
  1187. + comp_gain = is_gain;
  1188. + }
  1189. + }
  1190. + }
  1191. + compader.replace(compader.find("GAIN"),4,comp_gain);
  1192. +
  1193. + if ( dati->a_filter_valore == "" )
  1194. + dati->a_filter_valore = compader;
  1195. + else
  1196. + dati->a_filter_valore = dati->a_filter_valore + "," + compader;
  1197. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1198. + break;
  1199. + }
  1200. + }
  1201. + return true;
  1202. +}
  1203. +
  1204. diff -Naur -x '*~' src/routines/r-audio.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.h
  1205. --- src/routines/r-audio.h 1970-01-01 01:00:00.000000000 +0100
  1206. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.h 2013-08-29 20:05:15.326016089 +0200
  1207. @@ -0,0 +1,18 @@
  1208. +#ifndef R_AUDIO_H
  1209. +#define R_AUDIO_H
  1210. +
  1211. +// default GAIN = 0
  1212. +#define FFMPEG_COMPAND_1 "compand=.3 .3:1 1:-90/-60 -60/-40 -40/-30 -20/-20 :6:GAIN:-90:0.2"
  1213. +#define FFMPEG_COMPAND_FILM_1 "compand=.1 .1:.5 .5:-90/-90 -70/-64 -43/-37 -31/-25 -21/-15 -10/-10 :0.01:GAIN:-90:0.5" // 6db
  1214. +#define FFMPEG_COMPAND_FILM_2 "compand=.1 .1:.5 .5:-90/-90 -70/-60 -43/-33 -31/-21 -21/-15 -10/-10 :0.01:GAIN:-90:0.5" // 10-6db
  1215. +#define FFMPEG_COMPAND_FILM_3 "compand=.1 .1:.5 .5:-90/-90 -70/-60 -43/-33 -31/-21 -21/-15 -10/-7 -3/-3 0/-3 :3:GAIN:-90:0.5"
  1216. +
  1217. +#define FFMPEG_COMPAND_FILM_STD "compand=.1 .1:.5 .5:-90/-90 -70/-64 -43/-37 -31/-31 -21/-21 :0.01:GAIN:-90:0.5" //come su sox
  1218. +
  1219. +bool is_audio (int argc, char * argv[], s_dati *dati);
  1220. +void is_aboost (int argc, char * argv[], s_dati *dati);
  1221. +bool is_avolume (int argc, char * argv[], s_dati *dati);
  1222. +bool is_afilter (int argc, char * argv[], s_dati *dati);
  1223. +bool is_acomp (int argc, char * argv[], s_dati *dati);
  1224. +
  1225. +#endif
  1226. diff -Naur -x '*~' src/routines/r-build-fin.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.cpp
  1227. --- src/routines/r-build-fin.cpp 1970-01-01 01:00:00.000000000 +0100
  1228. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.cpp 2013-09-16 15:48:02.620479917 +0200
  1229. @@ -0,0 +1,174 @@
  1230. +#include "../main.h"
  1231. +#include "../funzioni.h"
  1232. +#include "r-build-fin.h"
  1233. +
  1234. +
  1235. +bool build_fin_eseg (s_dati *dati)
  1236. +{
  1237. + // variabili cronometri
  1238. + time_t now;
  1239. + double seconds, seconds2start, seconds3start;
  1240. + double durata, durata1, durata2, durata3;
  1241. +
  1242. +
  1243. + for (int i=1; i<=dati->pass; i++)
  1244. + {
  1245. +
  1246. + dati->daeseguire = (dati->eseguibile + " ");
  1247. + if (dati->logfile != "")
  1248. + dati->daeseguire = dati->daeseguire + dati->logfile + " ";
  1249. + if
  1250. + (
  1251. + (dati->pass==2 && i==1)
  1252. + || (dati->pass==3 && (i==1 || i==2))
  1253. + )
  1254. + dati->daeseguire = dati->daeseguire + "-y ";
  1255. +
  1256. + dati->daeseguire = dati->daeseguire + "-i "
  1257. + + "\"" + dati->nomefilein + "\"" + " ";
  1258. + if (dati->rate != "")
  1259. + dati->daeseguire = dati->daeseguire + dati->rate + " ";
  1260. + if (dati->maps!= "")
  1261. + dati->daeseguire = dati->daeseguire + dati->maps + " ";
  1262. + if (dati->tempoin != "")
  1263. + dati->daeseguire = dati->daeseguire + dati->tempoin + " ";
  1264. + if (dati->tempodur != "")
  1265. + dati->daeseguire = dati->daeseguire + dati->tempodur + " ";
  1266. + if (dati->filter != "")
  1267. + dati->daeseguire = dati->daeseguire + dati->filter + " ";
  1268. + if (dati->vcodec != "")
  1269. + dati->daeseguire = dati->daeseguire + dati->vcodec + " ";
  1270. + if (dati->video_codec_is == VIDEO_IS_X_264)
  1271. + {
  1272. + if (dati->preset != "")
  1273. + dati->daeseguire = dati->daeseguire + dati->preset + " ";
  1274. + if (dati->profile != "")
  1275. + dati->daeseguire = dati->daeseguire + dati->profile + " ";
  1276. + if (dati->set_264 != "")
  1277. + dati->daeseguire = dati->daeseguire + dati->set_264 + " ";
  1278. + }
  1279. + if (dati->bitrate_video != "")
  1280. + dati->daeseguire = dati->daeseguire + dati->bitrate_video + " ";
  1281. + if (dati->pass>=2 && i==1)
  1282. + {
  1283. + dati->daeseguire = dati->daeseguire + "-pass 1" + " ";
  1284. + if ( (dati->nofastfirst == 0) && (dati->video_codec_is == VIDEO_IS_X_264) )
  1285. + dati->daeseguire = dati->daeseguire + FAST_1_PASS + " ";
  1286. + }
  1287. + if
  1288. + (
  1289. + (dati->pass==2 && i==2)
  1290. + || (dati->pass==3 && i==3)
  1291. + )
  1292. + dati->daeseguire = dati->daeseguire + "-pass 2" + " ";
  1293. +
  1294. + if (dati->pass==3 && i==2)
  1295. + dati->daeseguire = dati->daeseguire + "-pass 3" + " ";
  1296. + if
  1297. + (
  1298. + (dati->pass==2 && i==1)
  1299. + || (dati->pass==3 && (i==1 || i==2))
  1300. + )
  1301. + dati->daeseguire = dati->daeseguire + AUDIO_PARM_NONE + " " + FORMAT_NULL + " " + OUT_NULL;
  1302. +
  1303. + if
  1304. + (
  1305. + dati->pass==1
  1306. + || (dati->pass==2 && i==2)
  1307. + || (dati->pass==3 && i==3)
  1308. + )
  1309. + {
  1310. + if (dati->a_filter_valore != "")
  1311. + dati->daeseguire = dati->daeseguire + "-af" + " "
  1312. + + "\"" + dati->a_filter_valore + "\"" + " ";
  1313. + if (dati->audio_parm != "")
  1314. + dati->daeseguire = dati->daeseguire + dati->audio_parm + " ";
  1315. + dati->daeseguire = (dati->daeseguire + dati->format_out + " ");
  1316. + if (dati->altro != "")
  1317. + dati->daeseguire = dati->daeseguire + dati->altro + " ";
  1318. + if ( (dati->video_codec_is != VIDEO_IS_X_264) && (dati->aspetto != "") )
  1319. + dati->daeseguire = dati->daeseguire + dati->aspetto + " ";
  1320. + dati->daeseguire = dati->daeseguire + "\"" + dati->nuovo_nome_file_out + "\"";
  1321. + }
  1322. +
  1323. + if (!dati->debug)
  1324. + printf ("\n\n");
  1325. +
  1326. + printf ("%s\n\n", dati->daeseguire.c_str());
  1327. +
  1328. + if (!dati->debug)
  1329. + {
  1330. + if (i==1)
  1331. + {
  1332. + seconds = time(&now);
  1333. + if ( esegui(dati->daeseguire.c_str()) !=0) return true;
  1334. + durata1 = difftime(time(&now),seconds);
  1335. + }
  1336. +
  1337. + if (i==2)
  1338. + {
  1339. + seconds2start = time(&now);
  1340. + if (esegui (dati->daeseguire.c_str()) !=0) return true;
  1341. + durata2 = difftime(time(&now),seconds2start);
  1342. + }
  1343. +
  1344. + if (i==3)
  1345. + {
  1346. + seconds3start = time(&now);
  1347. + if ( esegui(dati->daeseguire.c_str()) !=0) return true;
  1348. + durata3 = difftime(time(&now),seconds3start);
  1349. + }
  1350. + }
  1351. +
  1352. + }
  1353. + // durata totale
  1354. + durata = difftime(time(&now),seconds);
  1355. +
  1356. + // elimina i file stat delle passate
  1357. + // ffmpeg2pass-0.log ffmpeg2pass-0.log.mbtree
  1358. + if ( (dati->pass>1) && (!dati->debug) )
  1359. + {
  1360. + if( remove( "ffmpeg2pass-0.log" ) != 0 )
  1361. + perror( "Error deleting file" );
  1362. + if (dati->vcodec == VCODEC_X264)
  1363. + {
  1364. + if( remove( "ffmpeg2pass-0.log.mbtree" ) != 0 )
  1365. + perror( "Error deleting file" );
  1366. + }
  1367. + }
  1368. +
  1369. +
  1370. + // stampa i cronometri su stringa
  1371. + if (!dati->debug)
  1372. + {
  1373. + dati->riepilogo = "\n\nTempo conversione: "
  1374. + + str_stampatempo(durata);
  1375. +
  1376. + if ((dati->pass==2) || (dati->pass==3))
  1377. + {
  1378. + dati->riepilogo = dati->riepilogo
  1379. + + "\nPass 1: " +str_stampatempo(durata1)
  1380. + + "Pass 2: " +str_stampatempo(durata2);
  1381. + }
  1382. + if (dati->pass==3)
  1383. + {
  1384. + dati->riepilogo = dati->riepilogo
  1385. + + "Pass 3: " +str_stampatempo(durata3);
  1386. + }
  1387. + dati->riepilogo = dati->riepilogo + "\n";
  1388. + }
  1389. +
  1390. + // stampa le dimensioni in MB e data dei file in e out su stringa
  1391. + if (!dati->debug)
  1392. + {
  1393. + dati->riepilogo = dati->riepilogo
  1394. + + str_stampa_info_file (dati->nomefilein)
  1395. + + str_stampa_info_file (dati->nuovo_nome_file_out)
  1396. + + "\n";
  1397. +
  1398. + // stampa su terminale
  1399. + printf ("%s", dati->riepilogo.c_str() );
  1400. + }
  1401. +
  1402. + return false;
  1403. +}
  1404. diff -Naur -x '*~' src/routines/r-build-fin.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.h
  1405. --- src/routines/r-build-fin.h 1970-01-01 01:00:00.000000000 +0100
  1406. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.h 2013-08-26 15:36:41.883981953 +0200
  1407. @@ -0,0 +1,6 @@
  1408. +#ifndef R_BUILD_FIN_H
  1409. +#define BUILD_FIN_H
  1410. +
  1411. +bool build_fin_eseg (s_dati *dati);
  1412. +
  1413. +#endif
  1414. diff -Naur -x '*~' src/routines/r-file-sett.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.cpp
  1415. --- src/routines/r-file-sett.cpp 1970-01-01 01:00:00.000000000 +0100
  1416. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.cpp 2013-08-26 00:09:47.552378045 +0200
  1417. @@ -0,0 +1,99 @@
  1418. +#include "../main.h"
  1419. +#include "../funzioni.h"
  1420. +#include "r-file-sett.h"
  1421. +
  1422. +bool is_load_save (int argc, char * argv[], s_dati *dati)
  1423. +{
  1424. + // utility scrivi leggi settaggi su file
  1425. + // save | load nomefile (con o senza .estensione e senza spazi)
  1426. +
  1427. + for (int i=2; i<argc; i++)
  1428. + {
  1429. + if ( (std::string(argv[i]) == "save") || (std::string(argv[i]) == "load") )
  1430. + {
  1431. + if ( !check_num_param (argc,i,1) )
  1432. + return false;
  1433. + std::string nomefilesettaggi = removeExtension ( std::string(argv[i+1]).c_str() ) + FILESETTAGGI_EXT;
  1434. + //
  1435. + FILE * pFile;
  1436. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1437. + // scrivi
  1438. + if ( (std::string(argv[i]) == "save") )
  1439. + {
  1440. +
  1441. + pFile = fopen (nomefilesettaggi.c_str(),"w");
  1442. + if (pFile == NULL)
  1443. + {
  1444. + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
  1445. + perror ("Errore");
  1446. + return false;
  1447. + }
  1448. + else
  1449. + {
  1450. +
  1451. + scrivi_str_su_file (pFile , dati->filsett_vers);
  1452. + scrivi_str_su_file (pFile , dati->maps);
  1453. + scrivi_str_su_file (pFile , dati->bitrate_video);
  1454. + scrivi_str_su_file (pFile , dati->filter);
  1455. + scrivi_str_su_file (pFile , dati->set_264);
  1456. + scrivi_str_su_file (pFile , dati->preset);
  1457. + scrivi_int_su_file (pFile , dati->pass);
  1458. + scrivi_str_su_file (pFile , dati->audio_parm);
  1459. + scrivi_str_su_file (pFile , dati->format_out);
  1460. + scrivi_str_su_file (pFile , dati->vcodec);
  1461. + scrivi_str_su_file (pFile , dati->nuova_estensione);
  1462. +
  1463. + fclose (pFile);
  1464. + printf ("\nIl file: %s è stato salvato.\n\n", nomefilesettaggi.c_str() );
  1465. + break;
  1466. + }
  1467. +
  1468. +
  1469. + }
  1470. + // leggi
  1471. + if ( (std::string(argv[i]) == "load") )
  1472. + {
  1473. + pFile = fopen (nomefilesettaggi.c_str(),"r");
  1474. + if (pFile == NULL)
  1475. + {
  1476. + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
  1477. + perror ("Errore");
  1478. + return false;
  1479. + }
  1480. + else
  1481. + {
  1482. + std::string check_file_version ("");
  1483. + check_file_version = leggi_str_da_file (pFile);
  1484. + if (check_file_version != dati->filsett_vers)
  1485. + {
  1486. + fclose (pFile);
  1487. + printf ("\nIl file: %s non è compatibile con questa versione.\n\n",nomefilesettaggi.c_str() );
  1488. + return false;
  1489. + }
  1490. +
  1491. + dati->maps = leggi_str_da_file (pFile);
  1492. + dati->bitrate_video = leggi_str_da_file (pFile);
  1493. + dati->filter = leggi_str_da_file (pFile);
  1494. + dati->set_264 = leggi_str_da_file (pFile);
  1495. + dati->preset = leggi_str_da_file (pFile);
  1496. + dati->pass = leggi_int_da_file (pFile); // pass è int
  1497. + dati->audio_parm = leggi_str_da_file (pFile);
  1498. + dati->format_out = leggi_str_da_file (pFile);
  1499. + dati->vcodec = leggi_str_da_file (pFile);
  1500. + dati->nuova_estensione = leggi_str_da_file (pFile);
  1501. +
  1502. + fclose (pFile);
  1503. + printf ("\nIl file: %s è stato caricato.\n\n", nomefilesettaggi.c_str() );
  1504. + break;
  1505. + }
  1506. +
  1507. + }
  1508. +
  1509. + }
  1510. +
  1511. + }
  1512. + return true;
  1513. +}
  1514. +
  1515. +
  1516. +
  1517. diff -Naur -x '*~' src/routines/r-file-sett.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.h
  1518. --- src/routines/r-file-sett.h 1970-01-01 01:00:00.000000000 +0100
  1519. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.h 2013-08-23 21:57:49.000000000 +0200
  1520. @@ -0,0 +1,6 @@
  1521. +#ifndef R_FILE_SETT_H
  1522. +#define R_FILE_SETT_H
  1523. +
  1524. +bool is_load_save (int argc, char * argv[], s_dati *dati);
  1525. +
  1526. +#endif
  1527. diff -Naur -x '*~' src/routines/routines.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.cpp
  1528. --- src/routines/routines.cpp 1970-01-01 01:00:00.000000000 +0100
  1529. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.cpp 2013-08-26 00:12:49.120973731 +0200
  1530. @@ -0,0 +1,139 @@
  1531. +#include "../main.h"
  1532. +#include "../funzioni.h"
  1533. +#include "routines.h"
  1534. +
  1535. +void isdebug (int argc, char * argv[], s_dati *dati)
  1536. +{
  1537. + for (int i=2; i<argc; i++)
  1538. + {
  1539. + if (std::string(argv[i]) == "debug")
  1540. + {
  1541. + dati->debug = true;
  1542. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1543. + break;
  1544. + }
  1545. + }
  1546. +}
  1547. +
  1548. +bool is_map (int argc, char * argv[], s_dati *dati)
  1549. +{
  1550. + for (int i=2; i<argc; i++)
  1551. + {
  1552. + if (std::string(argv[i]) == "-map")
  1553. + {
  1554. + if ( !check_num_param (argc,i,1) )
  1555. + return false;
  1556. + if (dati->maps == "")
  1557. + {
  1558. + dati->maps = "-map " + std::string(argv[i+1]);
  1559. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1560. + }
  1561. + else
  1562. + {
  1563. + dati->maps = dati->maps + " -map " + std::string(argv[i+1]);
  1564. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1565. + }
  1566. + i++;
  1567. + }
  1568. + }
  1569. + return true;
  1570. +}
  1571. +
  1572. +void is_10bit (int argc, char * argv[], s_dati *dati)
  1573. +{
  1574. + for (int i=2; i<argc; i++)
  1575. + {
  1576. + if (std::string(argv[i]) == "-10bit")
  1577. + {
  1578. + dati->eseguibile = ESEGUIBILE_10BIT;
  1579. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1580. + break;
  1581. + }
  1582. + }
  1583. +}
  1584. +
  1585. +bool is_filter (int argc, char * argv[], s_dati *dati)
  1586. +{
  1587. + for (int i=2; i<argc; i++)
  1588. + {
  1589. + if (std::string(argv[i]) == "-vf")
  1590. + {
  1591. + if ( !check_num_param (argc,i,1) )
  1592. + return false;
  1593. + dati->filtervalore = std::string (argv[i+1]);
  1594. + dati->filter = "-vf " + dati->filtervalore;
  1595. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1596. + break;
  1597. + }
  1598. + }
  1599. + return true;
  1600. +}
  1601. +
  1602. +bool is_ss_is_t (int argc, char * argv[], s_dati *dati)
  1603. +{
  1604. + for (int i=2; i<argc; i++)
  1605. + {
  1606. + if (std::string(argv[i]) == "-ss")
  1607. + {
  1608. + if ( !check_num_param (argc,i,1) )
  1609. + return false;
  1610. + dati->tempoin = "-ss " + std::string(argv[i+1]);
  1611. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1612. + break;
  1613. + }
  1614. + }
  1615. +
  1616. + for (int i=2; i<argc; i++)
  1617. + {
  1618. + if (std::string(argv[i]) == "-t")
  1619. + {
  1620. + if ( !check_num_param (argc,i,1) )
  1621. + return false;
  1622. + dati->tempodur = "-t " + std::string(argv[i+1]);
  1623. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  1624. + break;
  1625. + }
  1626. + }
  1627. + return true;
  1628. +}
  1629. +
  1630. +void is_altro (int argc, char * argv[], s_dati *dati)
  1631. +{
  1632. + for (int i=2; i<argc; i++)
  1633. + {
  1634. + if (std::string(argv[i]) == "-nometa")
  1635. + {
  1636. + dati->altro = "-map_metadata -1";
  1637. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1638. + break;
  1639. + }
  1640. + }
  1641. +
  1642. + for (int i=2; i<argc; i++)
  1643. + {
  1644. + if (std::string(argv[i]) == "-scopy")
  1645. + {
  1646. + if (dati->altro != "")
  1647. + dati->altro = dati->altro + " -c:s copy";
  1648. + else
  1649. + dati->altro = "-c:s copy";
  1650. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1651. + break;
  1652. + }
  1653. + }
  1654. +}
  1655. +
  1656. +void is_log (int argc, char * argv[], s_dati *dati)
  1657. +{
  1658. +// -log logfile ffmpeg
  1659. + for (int i=2; i<argc; i++)
  1660. + {
  1661. + if (std::string(argv[i]) == "-log")
  1662. + {
  1663. + dati->logfile = "-psnr -report";
  1664. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  1665. + break;
  1666. + }
  1667. + }
  1668. +}
  1669. +
  1670. diff -Naur -x '*~' src/routines/routines.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.h
  1671. --- src/routines/routines.h 1970-01-01 01:00:00.000000000 +0100
  1672. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.h 2013-08-23 21:33:51.000000000 +0200
  1673. @@ -0,0 +1,15 @@
  1674. +#ifndef ROUTINES_H
  1675. +#define ROUTINES_H
  1676. +
  1677. +void isdebug (int argc, char * argv[], s_dati *dati);
  1678. +bool is_map (int argc, char * argv[], s_dati *dati);
  1679. +void is_10bit (int argc, char * argv[], s_dati *dati);
  1680. +bool is_filter (int argc, char * argv[], s_dati *dati);
  1681. +bool is_ss_is_t (int argc, char * argv[], s_dati *dati);
  1682. +void is_altro (int argc, char * argv[], s_dati *dati);
  1683. +void is_log (int argc, char * argv[], s_dati *dati);
  1684. +
  1685. +#endif
  1686. +
  1687. +
  1688. +
  1689. diff -Naur -x '*~' src/routines/r-util.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.cpp
  1690. --- src/routines/r-util.cpp 1970-01-01 01:00:00.000000000 +0100
  1691. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.cpp 2013-09-28 15:35:40.325120764 +0200
  1692. @@ -0,0 +1,496 @@
  1693. +#include "../main.h"
  1694. +#include "../funzioni.h"
  1695. +#include "r-util.h"
  1696. +
  1697. +int ConvStdTimeToSec(std::string time)
  1698. +{
  1699. + int val;
  1700. +
  1701. + val = ( atoi(time.substr(0,2).c_str()) * 3600 )
  1702. + + ( atoi(time.substr(3,2).c_str()) * 60 )
  1703. + + ( atoi(time.substr(6,2).c_str()) );
  1704. +
  1705. + return val;
  1706. +}
  1707. +
  1708. +
  1709. +bool is_util_mkvinfo (int argc, char * argv[], s_dati *dati)
  1710. +{
  1711. + for (int i=2; i<argc; i++)
  1712. + {
  1713. + if (std::string(argv[i]) == "mkvinfo")
  1714. + {
  1715. + if (dati->estensione_file_in == ".mkv")
  1716. + {
  1717. + std::string utility ((std::string)ESEGUIBILE_MKVINFO + " "
  1718. + + "\"" + dati->nomefilein + "\""
  1719. + );
  1720. + printf ("\n");
  1721. + if ( esegui(utility.c_str()) !=0) return false;
  1722. + printf ("\n\nEsempi estrazione flussi:\n\n");
  1723. + printf ("mkvextract tracks %s 1:video.mkv\n",dati->nomefilein.c_str());
  1724. + printf ("mkvextract tracks %s 2:audio.mp3\n",dati->nomefilein.c_str());
  1725. + printf ("mkvextract tracks %s 6:subs.srt\n\n",dati->nomefilein.c_str());
  1726. + printf ("\nDove n:tipofile.ext sono il numero ed il tipo di stream.\n\n");
  1727. + return false;
  1728. + }
  1729. + else
  1730. + {
  1731. + printf ("\n il file \"%s\" non è un file matroska .mkv\n\n", dati->nomedelfile.c_str() );
  1732. + return false;
  1733. + }
  1734. + }
  1735. + }
  1736. + return true;
  1737. +}
  1738. +
  1739. +bool is_util_mkvmerge (int argc, char * argv[], s_dati *dati)
  1740. +{
  1741. + for (int i=2; i<argc; i++)
  1742. + {
  1743. + if (std::string(argv[i]) == "mmg")
  1744. + {
  1745. + std::string mmgexe ("mmg");
  1746. + std::string utility = mmgexe + " " + "\"" + dati->nomefilein + "\"";
  1747. + printf ("\n");
  1748. + printf ("\n%s\n\n",utility.c_str() );
  1749. + if ( esegui(utility.c_str()) !=0) return false;
  1750. + return false;
  1751. + }
  1752. + }
  1753. + return true;
  1754. +
  1755. +}
  1756. +
  1757. +bool is_util_play (int argc, char * argv[], s_dati *dati)
  1758. +{
  1759. + // utility play (preview con -map -ss e -vf)
  1760. + for (int i=2; i<argc; i++)
  1761. + {
  1762. + if (std::string(argv[i]) == "play")
  1763. + {
  1764. + std::string utility;
  1765. + if ( dati->maps == "" )
  1766. + {
  1767. + utility = (std::string)ESEGUIBILE_PLAY + " "
  1768. + + "\"" + dati->nomefilein + "\" ";
  1769. + if (dati->filter != "")
  1770. + utility = utility + dati->filter + " ";
  1771. + if (dati->tempoin != "")
  1772. + utility = utility + dati->tempoin + " ";
  1773. + }
  1774. + else
  1775. + {
  1776. + utility = (std::string)ESEGUIBILE_FFMPEG + " -i "
  1777. + + "\"" + dati->nomefilein + "\" "
  1778. + + dati->maps + " ";
  1779. + if ( dati->tempoin != "")
  1780. + utility = utility + dati->tempoin + " ";
  1781. + utility = utility + VCODEC_COPY_ALL + " "
  1782. + + FORMAT_OUT_MATROSKA + " - | "
  1783. + + ESEGUIBILE_PLAY + " "
  1784. + + "- ";
  1785. + if ( dati->filter != "")
  1786. + utility = utility + dati->filter + " ";
  1787. + utility = utility + "&";
  1788. + }
  1789. + printf ("\n%s\n\n",utility.c_str());
  1790. + if ( esegui(utility.c_str()) !=0) return false;
  1791. + return false;
  1792. + }
  1793. + }
  1794. + return true;
  1795. +}
  1796. +
  1797. +
  1798. +
  1799. +bool is_util_probe (int argc, char * argv[], s_dati *dati)
  1800. +{
  1801. + for (int i=2; i<argc; i++)
  1802. + {
  1803. + if (std::string(argv[i]) == "probe")
  1804. + {
  1805. + std::string utility ((std::string)ESEGUIBILE_PROBE + " "
  1806. + + "\"" + dati->nomefilein + "\""
  1807. + + " " + FILTRO_FFMPEG_OUTPUT
  1808. + );
  1809. + printf ("\n");
  1810. + if ( esegui(utility.c_str()) !=0) return false;
  1811. + return false;
  1812. + }
  1813. + }
  1814. + return true;
  1815. +}
  1816. +
  1817. +bool is_util_help_filter (int argc, char * argv[])
  1818. +{
  1819. + for (int i=2; i<argc; i++)
  1820. + {
  1821. + if (std::string(argv[i]) == "-hf")
  1822. + {
  1823. + if ( !check_num_param (argc,i,1) )
  1824. + return false;
  1825. + std::string utility ((std::string)ESEGUIBILE_FFMPEG + " "
  1826. + + "-h filter=" + std::string(argv[i+1])
  1827. + + " " + FILTRO_FFMPEG_OUTPUT
  1828. + );
  1829. + printf ("\n");
  1830. + if ( esegui(utility.c_str()) !=0) return false;
  1831. + return false;
  1832. + }
  1833. + }
  1834. + return true;
  1835. +}
  1836. +
  1837. +
  1838. +bool is_util_vftest (int argc, char * argv[], s_dati *dati)
  1839. +{
  1840. + // utility vftest 2 video verticali
  1841. + // filtervalore per utility vftest
  1842. + for (int i=2; i<argc; i++)
  1843. + {
  1844. + if (std::string(argv[i]) == "vftest")
  1845. + {
  1846. + if (dati->filtervalore == "")
  1847. + {
  1848. + printf ("\nè necessario usare -vf filter,filter per usare vftest.\n\n" );
  1849. + return false;
  1850. + }
  1851. + // 2v
  1852. + std::string utility ((std::string)ESEGUIBILE_PLAY + " "
  1853. + + "\"" + dati->nomefilein + "\" "
  1854. + + "-vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]"
  1855. + + dati->filtervalore
  1856. + + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\" "
  1857. + );
  1858. + if (dati->tempoin != "")
  1859. + utility = utility + dati->tempoin + " ";
  1860. + printf ("\n%s\n\n", utility.c_str() );
  1861. + if ( esegui(utility.c_str()) !=0) return false;
  1862. + return false;
  1863. + }
  1864. + }
  1865. + return true;
  1866. +}
  1867. +
  1868. +
  1869. +bool is_util_vftestsp (int argc, char * argv[], s_dati *dati)
  1870. +{
  1871. + // utility vftestsp video split
  1872. + for (int i=2; i<argc; i++)
  1873. + {
  1874. + if (std::string(argv[i]) == "vftestsp")
  1875. + {
  1876. + if (dati->filtervalore == "")
  1877. + {
  1878. + printf ("\nè necessario usare -vf filter,filter per usare vftestsp.\n\n" );
  1879. + return false;
  1880. + }
  1881. + // 2v
  1882. + std::string utility ((std::string)ESEGUIBILE_PLAY + " "
  1883. + + "\"" + dati->nomefilein + "\" "
  1884. + + "-vf \"split [main][tmp]; [tmp] crop=iw/2:ih:iw/2:0,"
  1885. + + dati->filtervalore
  1886. + + " [filter]; [main][filter] overlay=W/2:0\" "
  1887. + );
  1888. + if (dati->tempoin != "")
  1889. + utility = utility + dati->tempoin + " ";
  1890. + printf ("\n%s\n\n", utility.c_str() );
  1891. + if ( esegui(utility.c_str()) !=0) return false;
  1892. + return false;
  1893. + }
  1894. + }
  1895. + return true;
  1896. +}
  1897. +
  1898. +
  1899. +bool is_util_calc_scale (int argc, char * argv[])
  1900. +{
  1901. + // utility calcola scala proporzionale
  1902. + // calc 720 0 16 9 o calc 0 480 4 3
  1903. + for (int i=2; i<argc; i++)
  1904. + {
  1905. + if (std::string(argv[i]) == "calc")
  1906. + {
  1907. + if ( !check_num_param (argc,i,4) )
  1908. + {
  1909. + printf ("\nUsare: calc 640 0 16 9 oppure 0 480 4 3.\n\n");
  1910. + return false;
  1911. + }
  1912. + int w, h, aw, ah;
  1913. + w = atoi(argv[i+1]);
  1914. + h = atoi(argv[i+2]);
  1915. + aw = atoi(argv[i+3]);
  1916. + ah = atoi(argv[i+4]);
  1917. + //check
  1918. + if ( (w == 0 && h == 0) || (aw == 0) || (ah == 0) )
  1919. + {
  1920. + printf ("\nUsare: calc 640 0 16 9 oppure 0 480 4 3.\n\n");
  1921. + return false;
  1922. + }
  1923. + calcola_proporzioni (w, h, aw, ah);
  1924. + calcola_proporzioni_8 (w, h, aw, ah);
  1925. + return false;
  1926. + }
  1927. + }
  1928. + return true;
  1929. +}
  1930. +
  1931. +
  1932. +bool is_muxer (int argc, char * argv[], s_dati *dati)
  1933. +{
  1934. + for (int i=2; i<argc; i++)
  1935. + {
  1936. + if ( std::string(argv[i]) == "muxer" )
  1937. + {
  1938. + if ( !check_num_param (argc,i,1) )
  1939. + {
  1940. + printf ("usare: %s -muxer nomefileaudio [container mkv(default)|avi|mp4]\n", dati->nomefilein.c_str() );
  1941. + printf ("Se -map non sono specificati viene usato:\n");
  1942. + printf ("-map 0:0 -map 1:0\n\n");
  1943. + return false;
  1944. + }
  1945. + std::string nome_file_audio = (argv[i+1]);
  1946. + std::string verifica = nome_file_audio.substr ( (nome_file_audio.length() -1) ,1);
  1947. + if (verifica == "/")
  1948. + {
  1949. + printf ("\nAttenzione: %s è una cartella.\n\n", nome_file_audio.c_str() );
  1950. + return false;
  1951. + }
  1952. + if ( !fileExists ( nome_file_audio.c_str() ) )
  1953. + {
  1954. + printf ("\nIl file: %s non esiste.\n\n", nome_file_audio.c_str() );
  1955. + return false;
  1956. + }
  1957. + std::string formato = FORMAT_OUT_MATROSKA;
  1958. + std::string tipo = NUOVA_EXT_MKV;
  1959. + if ( (argc-1) >= (i+2) )
  1960. + {
  1961. + std::string container = (argv[i+2]);
  1962. + if ( container == "avi")
  1963. + {
  1964. + formato = FORMAT_OUT_AVI;
  1965. + tipo = NUOVA_EXT_AVI;
  1966. + }
  1967. + else if ( container == "mp4")
  1968. + {
  1969. + formato = FORMAT_OUT_MP4;
  1970. + tipo = NUOVA_EXT_MP4;
  1971. + }
  1972. + }
  1973. + tipo = "_MUXED_" + tipo;
  1974. + std::string daeseguire;
  1975. + std::string nuovo_nome_file_out_muxed = check_fileout_name_e_rename (dati->nome_file_senza_ext, tipo);
  1976. + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " "
  1977. + + "-i "+ "\"" + dati->nomefilein + "\"" + " "
  1978. + + "-i " + "\"" + nome_file_audio + "\"" + " ";
  1979. + if (dati->maps == "")
  1980. + daeseguire = daeseguire + "-map 0:0 -map 1:0 " + " ";
  1981. + else
  1982. + daeseguire = daeseguire + dati->maps + " ";
  1983. + // un po inutile solo per test
  1984. + if (dati->tempodur != "")
  1985. + daeseguire = daeseguire + dati->tempodur + " ";
  1986. + // -----------------------------
  1987. + daeseguire = daeseguire + VCODEC_COPY_ALL + " "
  1988. + + formato + " "
  1989. + + + "\"" + nuovo_nome_file_out_muxed + "\"";
  1990. + printf ("\n%s\n\n", daeseguire.c_str() );
  1991. + if (! dati->debug)
  1992. + {
  1993. + if ( esegui(daeseguire.c_str()) !=0) return false;
  1994. + printf ("\n");
  1995. + stampa_info_file (nuovo_nome_file_out_muxed);
  1996. + printf ("\n");
  1997. + }
  1998. + return false;
  1999. + }
  2000. + }
  2001. + return true;
  2002. +}
  2003. +
  2004. +bool is_util_volumedetect (int argc, char * argv[], s_dati *dati)
  2005. +{
  2006. + // ffmpeg -i filein -vn -af volumedetect -f null /dev/null
  2007. + for (int i=2; i<argc; i++)
  2008. + {
  2009. + if (std::string(argv[i]) == "volumedet")
  2010. + {
  2011. + std::string utility = (std::string)ESEGUIBILE_FFMPEG + " -i "
  2012. + + "\"" + dati->nomefilein + "\"" + " ";
  2013. + if ( dati->tempoin != "")
  2014. + utility = utility + dati->tempoin + " ";
  2015. + if ( dati->tempodur != "")
  2016. + utility = utility + dati->tempodur + " ";
  2017. + if ( dati->maps != "")
  2018. + utility = utility + dati->maps + " ";
  2019. + utility = utility + "-vn " + "-af volumedetect "
  2020. + + FORMAT_NULL + " " + OUT_NULL;
  2021. + printf ("\n%s\n\n", utility.c_str() );
  2022. + if ( esegui(utility.c_str()) !=0) return false;
  2023. + return false;
  2024. + }
  2025. + }
  2026. + return true;
  2027. +}
  2028. +
  2029. +
  2030. +bool is_util_showwaves (int argc, char * argv[], s_dati *dati)
  2031. +{
  2032. + // utility play (preview con -map -ss e -vf)
  2033. + for (int i=2; i<argc; i++)
  2034. + {
  2035. + if (std::string(argv[i]) == "showwaves")
  2036. + {
  2037. + std::string utility;
  2038. +
  2039. + utility = (std::string)ESEGUIBILE_PLAY + " "
  2040. + + "-f lavfi 'amovie="
  2041. + + dati->nomefilein + " ";
  2042. + if (dati->tempoin != "")
  2043. + utility = utility + ":sp="
  2044. + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
  2045. + if (dati->a_filter_valore != "")
  2046. + utility = utility + ", " + dati->a_filter_valore;
  2047. + utility = utility + ",asplit[out0],showwaves=s=1200x800:mode=line[out1]'";
  2048. +
  2049. + printf ("\n%s\n\n",utility.c_str());
  2050. + if ( esegui(utility.c_str()) !=0) return false;
  2051. + return false;
  2052. + }
  2053. + }
  2054. + return true;
  2055. +}
  2056. +
  2057. +bool is_util_showspectrum (int argc, char * argv[], s_dati *dati)
  2058. +{
  2059. + // utility play (preview con -map -ss e -vf)
  2060. + for (int i=2; i<argc; i++)
  2061. + {
  2062. + if (std::string(argv[i]) == "showspectrum")
  2063. + {
  2064. + std::string utility;
  2065. +
  2066. + utility = (std::string)ESEGUIBILE_PLAY + " "
  2067. + + "-f lavfi 'amovie="
  2068. + + dati->nomefilein + " ";
  2069. + if (dati->tempoin != "")
  2070. + utility = utility + ":sp="
  2071. + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
  2072. + if (dati->a_filter_valore != "")
  2073. + utility = utility + ", " + dati->a_filter_valore;
  2074. + utility = utility + " ,asplit [a][out1];[a] showspectrum=s=1200x800:mode=combined:color=intensity:slide=1:scale=sqrt:saturation=3 [out0]'";
  2075. +
  2076. + printf ("\n%s\n\n",utility.c_str());
  2077. + if ( esegui(utility.c_str()) !=0) return false;
  2078. + return false;
  2079. + }
  2080. + }
  2081. + return true;
  2082. +}
  2083. +
  2084. +
  2085. +
  2086. +bool is_util_ebur128 (int argc, char * argv[], s_dati *dati)
  2087. +{
  2088. + // utility play (preview con -map -ss e -vf)
  2089. + for (int i=2; i<argc; i++)
  2090. + {
  2091. + if (std::string(argv[i]) == "ebur128")
  2092. + {
  2093. + std::string utility;
  2094. +
  2095. + utility = (std::string)ESEGUIBILE_PLAY + " "
  2096. + + "-f lavfi 'amovie="
  2097. + + dati->nomefilein + " ";
  2098. + if (dati->tempoin != "")
  2099. + utility = utility + ":sp="
  2100. + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
  2101. + if (dati->a_filter_valore != "")
  2102. + utility = utility + ", " + dati->a_filter_valore;
  2103. + utility = utility + " ,ebur128=video=1:meter=18 [out0][out1]'";
  2104. +
  2105. + printf ("\n%s\n\n",utility.c_str());
  2106. + if ( esegui(utility.c_str()) !=0) return false;
  2107. + return false;
  2108. + }
  2109. + }
  2110. + return true;
  2111. +}
  2112. +
  2113. +
  2114. +bool is_util_dbcalc (int argc, char * argv[], s_dati *dati)
  2115. +{
  2116. + for (int i=2; i<argc; i++)
  2117. + {
  2118. + if (std::string(argv[i]) == "dbcalc")
  2119. + {
  2120. + if ( !check_num_param (argc,i,1) )
  2121. + {
  2122. + printf ("\nusare: dbcalc db (20 -20)\n\n");
  2123. + return false;
  2124. + }
  2125. +
  2126. + if ( !is_number(argv[i+1]) )
  2127. + {
  2128. + printf ("\nusare: dbcalc db (20 -20)\n\n");
  2129. + return false;
  2130. + }
  2131. +
  2132. + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
  2133. + double amp = atof(argv[i+1]);
  2134. + if ( amp < -20.0 || amp > 20.0 || amp == 0.0 )
  2135. + {
  2136. + printf ("\nusare: dbcalc db (20 -20)\n\n");
  2137. + return false;
  2138. + }
  2139. + // db to ratio
  2140. + float f_ratio = pow (10.0, (amp/20.0) );
  2141. + char ratio [10];
  2142. + sprintf (ratio,"%.3f",f_ratio);
  2143. + setlocale (LC_ALL,""); // ripristino locale
  2144. + printf ("\n\n%.1f db = %s \n\n", amp ,ratio);
  2145. + printf ("emempio d'uso con -af volume e timeline:\n");
  2146. + printf ("-af \"volume=enable='between(t,0,44.95)':volume=0.5, volume=enable='gte(t,45)':volume=2\"\n\n");
  2147. + return false;
  2148. + }
  2149. + }
  2150. + return true;
  2151. +}
  2152. +
  2153. +
  2154. +bool is_util_time (int argc, char * argv[], s_dati *dati)
  2155. +{
  2156. + for (int i=2; i<argc; i++)
  2157. + {
  2158. + if (std::string(argv[i]) == "time")
  2159. + {
  2160. + int start, fine, durata;
  2161. + if ( !check_num_param (argc,i,2) )
  2162. + {
  2163. + printf ("\nusare: time in out (hh:mm:ss o sec)\n\n");
  2164. + return false;
  2165. + }
  2166. +
  2167. + if ( is_number(argv[i+1]) )
  2168. + start = atoi(argv[i+1]);
  2169. + else
  2170. + start = ConvStdTimeToSec ( std::string(argv[i+1]) );
  2171. +
  2172. + if ( is_number(argv[i+2]) )
  2173. + fine = atoi(argv[i+2]);
  2174. + else
  2175. + fine = ConvStdTimeToSec ( std::string(argv[i+2]) );
  2176. +
  2177. + durata = fine - start;
  2178. + if (durata <=0)
  2179. + {
  2180. + printf ("\nla durata risulta 0 o minore.\nUsare: time in out (hh:mm:ss o sec)\n\n");
  2181. + return false;
  2182. + }
  2183. + printf("\n-ss %i -t %i\n\n",start,durata);
  2184. + return false;
  2185. + }
  2186. + }
  2187. + return true;
  2188. +}
  2189. diff -Naur -x '*~' src/routines/r-util.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.h
  2190. --- src/routines/r-util.h 1970-01-01 01:00:00.000000000 +0100
  2191. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.h 2013-09-28 15:30:12.826249914 +0200
  2192. @@ -0,0 +1,20 @@
  2193. +#ifndef R_UTIL_H
  2194. +#define R_UTIL_H
  2195. +
  2196. +bool is_util_mkvinfo (int argc, char * argv[], s_dati *dati);
  2197. +bool is_util_mkvmerge (int argc, char * argv[], s_dati *dati);
  2198. +bool is_util_play (int argc, char * argv[], s_dati *dati);
  2199. +bool is_util_probe (int argc, char * argv[], s_dati *dati);
  2200. +bool is_util_help_filter (int argc, char * argv[]);
  2201. +bool is_util_vftest (int argc, char * argv[], s_dati *dati);
  2202. +bool is_util_vftestsp (int argc, char * argv[], s_dati *dati);
  2203. +bool is_util_calc_scale (int argc, char * argv[]);
  2204. +bool is_muxer (int argc, char * argv[], s_dati *dati);
  2205. +bool is_util_volumedetect (int argc, char * argv[], s_dati *dati);
  2206. +bool is_util_showwaves (int argc, char * argv[], s_dati *dati);
  2207. +bool is_util_showspectrum (int argc, char * argv[], s_dati *dati);
  2208. +bool is_util_ebur128 (int argc, char * argv[], s_dati *dati);
  2209. +bool is_util_dbcalc (int argc, char * argv[], s_dati *dati);
  2210. +bool is_util_time (int argc, char * argv[], s_dati *dati);
  2211. +
  2212. +#endif
  2213. diff -Naur -x '*~' src/routines/r-util-sox.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.cpp
  2214. --- src/routines/r-util-sox.cpp 1970-01-01 01:00:00.000000000 +0100
  2215. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.cpp 2013-09-02 13:52:54.136003052 +0200
  2216. @@ -0,0 +1,188 @@
  2217. +#include "../main.h"
  2218. +#include "../funzioni.h"
  2219. +#include "r-util-sox.h"
  2220. +
  2221. +void sox_help (std::string nome_del_file)
  2222. +{
  2223. + printf ("\nUsare: sox norm | comp | compf | fastdet | compfast [noshow mux]\n");
  2224. + printf ("noshow: non mostra sox progress\n");
  2225. + printf ("mux: muxa il file %s\n\n", nome_del_file.c_str() );
  2226. +}
  2227. +
  2228. +bool is_util_sox (int argc, char * argv[], s_dati *dati)
  2229. +{
  2230. + for (int i=2; i<argc; i++)
  2231. + {
  2232. + if (std::string(argv[i]) == "sox")
  2233. + {
  2234. + time_t now;
  2235. + double seconds, durata;
  2236. + std::string sox_effect;
  2237. + std::string sox_show ("-S");
  2238. + std::string nuovo_nome_file_out_mka = check_fileout_name_e_rename ( dati->nome_file_senza_ext, ((std::string)"_SOX_" + NUOVA_EXT_MKA) );
  2239. + std::string nuovo_nome_file_out_mux = check_fileout_name_e_rename ( dati->nome_file_senza_ext, ((std::string)"_MUX_" + NUOVA_EXT_MKV) );
  2240. + std::string daeseguire ("");
  2241. + std::string daeseguire_test ("");
  2242. + bool is_test (false);
  2243. + int prossimo = 2;
  2244. +
  2245. + if ( !check_num_param (argc,i,1) )
  2246. + {
  2247. + sox_help (nuovo_nome_file_out_mux);
  2248. + return false;
  2249. + }
  2250. +
  2251. + if (
  2252. + dati->audio_parm == AUDIO_PARM_NONE
  2253. + || dati->audio_parm == AUDIO_PARM_COPY
  2254. + || dati->vcodec == VCODEC_COPY_ALL
  2255. + )
  2256. + {
  2257. + printf ("\n\nsox è incompatibile con -an -acopy e -copy\n\n");
  2258. + return false;
  2259. + }
  2260. +
  2261. + if ( std::string(argv[i+1]) == "norm" )
  2262. + sox_effect = SOX_NORM;
  2263. + else if ( std::string(argv[i+1]) == "comp" )
  2264. + sox_effect = SOX_COMPAND_STD_2;
  2265. + else if ( std::string(argv[i+1]) == "compf" )
  2266. + sox_effect = SOX_COMPAND_FILM_STD;
  2267. + else if ( std::string(argv[i+1]) == "compfast" )
  2268. + sox_effect = SOX_COMPAND_FILM_STD_NO_NORM;
  2269. + else if ( std::string(argv[i+1]) == "fastdet" )
  2270. + {
  2271. + sox_effect = SOX_COMPAND_FILM_STD_NO_NORM;
  2272. + dati->a_filter_valore = "atempo=2";
  2273. + is_test = true;
  2274. + }
  2275. + else
  2276. + {
  2277. + sox_help (nuovo_nome_file_out_mux);
  2278. + return false;
  2279. + }
  2280. +
  2281. + if ( argc-1 >= i+prossimo )
  2282. + {
  2283. + for (int x=i; x<argc; x++)
  2284. + {
  2285. + if (std::string(argv[x]) == "noshow")
  2286. + {
  2287. + sox_show = "";
  2288. + prossimo = prossimo +1;
  2289. + break;
  2290. + }
  2291. + }
  2292. + }
  2293. +
  2294. + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " " + "-i "
  2295. + + "\"" + dati->nomefilein + "\"" + " ";
  2296. + if (dati->rate != "")
  2297. + daeseguire = daeseguire + dati->rate + " ";
  2298. + if (dati->maps != "")
  2299. + daeseguire = daeseguire + dati->maps + " ";
  2300. + if (is_test)
  2301. + daeseguire = daeseguire + "-af" + " "
  2302. + + "\"" + dati->a_filter_valore + "\"" + " ";
  2303. + if (dati->tempoin != "")
  2304. + daeseguire = daeseguire + dati->tempoin + " ";
  2305. + if (dati->tempodur != "")
  2306. + daeseguire = daeseguire + dati->tempodur + " ";
  2307. + daeseguire = daeseguire + "-vn -f sox - | sox "
  2308. + + SOX_TEMP_MY_SETT + " "
  2309. + + sox_show + " "
  2310. + + "-t sox - -t sox -" + " "
  2311. + + sox_effect + " | "
  2312. + + ESEGUIBILE_FFMPEG + " -y "
  2313. + + "-i - " + FORMAT_OUT_MATROSKA + " "
  2314. + + dati->audio_parm + " ";
  2315. + if ( sox_effect == SOX_COMPAND_FILM_STD_NO_NORM && !is_test )
  2316. + {
  2317. + if (dati->a_filter_valore != "" )
  2318. + daeseguire = daeseguire + "-af" + " "
  2319. + + "\"" + dati->a_filter_valore + "\"" + " ";
  2320. + }
  2321. + daeseguire = daeseguire+ "\"" + nuovo_nome_file_out_mka + "\"";
  2322. + printf ("\n\n%s\n\n", daeseguire.c_str() );
  2323. + if (is_test)
  2324. + {
  2325. + daeseguire_test = (std::string)ESEGUIBILE_FFMPEG + " -i "
  2326. + + "\"" + nuovo_nome_file_out_mka + "\"" + " "
  2327. + + "-vn " + "-af volumedetect "
  2328. + + FORMAT_NULL + " " + OUT_NULL;
  2329. + printf ("%s\n\n", daeseguire_test.c_str() );
  2330. + }
  2331. + if (! dati->debug)
  2332. + {
  2333. + seconds = time(&now);
  2334. + if ( esegui(daeseguire.c_str()) !=0) return false;
  2335. + if (is_test)
  2336. + {
  2337. + if ( esegui(daeseguire_test.c_str()) !=0) return false;
  2338. + }
  2339. + durata = difftime(time(&now),seconds);
  2340. + dati->riepilogo = dati->riepilogo
  2341. + + "\n\nTempo conversione audio: "
  2342. + + str_stampatempo(durata) + "\n"
  2343. + + str_stampa_info_file(dati->nomefilein)
  2344. + + str_stampa_info_file(nuovo_nome_file_out_mka);
  2345. + if (is_test)
  2346. + {
  2347. + if( remove( nuovo_nome_file_out_mka.c_str() ) != 0 )
  2348. + perror( "Error deleting file" );
  2349. + }
  2350. + }
  2351. +
  2352. + if ( argc-1 >= i+prossimo )
  2353. + {
  2354. + for (int x=i; x<argc; x++)
  2355. + {
  2356. + if ( std::string(argv[x]) == "mux" )
  2357. + {
  2358. + // even aggiungere i param video e tempo
  2359. + prossimo = prossimo +1;
  2360. + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " ";
  2361. + // dovrebbe funzionare ma non è affidabile
  2362. + if (dati->tempoin != "")
  2363. + daeseguire = daeseguire + dati->tempoin + " ";
  2364. + if (dati->tempodur != "")
  2365. + daeseguire = daeseguire + dati->tempodur + " ";
  2366. + // ----------------------------------------------
  2367. + daeseguire = daeseguire + "-i "
  2368. + + "\"" + dati->nomefilein + "\"" + " "
  2369. + + "-i "
  2370. + + "\"" + nuovo_nome_file_out_mka + "\"" + " ";
  2371. + if (dati->maps == "")
  2372. + daeseguire = daeseguire + "-map 0:v -map 1:a " + " ";
  2373. + else
  2374. + daeseguire = daeseguire + dati->maps.substr (0,8) + " "
  2375. + + "-map 1:a " + " ";
  2376. + //daeseguire = daeseguire + "-map 0:v -map 1:a" + " ";
  2377. + daeseguire = daeseguire + VCODEC_COPY_ALL + " "
  2378. + + FORMAT_OUT_MATROSKA + " "
  2379. + + "\"" + nuovo_nome_file_out_mux + "\"";
  2380. + printf ("%s\n\n", daeseguire.c_str() );
  2381. + if (! dati->debug)
  2382. + {
  2383. + if ( esegui(daeseguire.c_str()) !=0) return false;
  2384. + dati->riepilogo = dati->riepilogo
  2385. + + str_stampa_info_file(nuovo_nome_file_out_mux) + "\n";
  2386. + printf("%s",dati->riepilogo.c_str());
  2387. + return false;
  2388. + }
  2389. + }
  2390. + }
  2391. + }
  2392. +
  2393. + if (! dati->debug)
  2394. + {
  2395. + dati->riepilogo = dati->riepilogo
  2396. + + "\nProcessare ora il video con -an e/o muxare.\n\n";
  2397. + printf("%s",dati->riepilogo.c_str());
  2398. + }
  2399. + return false;
  2400. + }
  2401. + }
  2402. + return true;
  2403. +}
  2404. +
  2405. diff -Naur -x '*~' src/routines/r-util-sox.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.h
  2406. --- src/routines/r-util-sox.h 1970-01-01 01:00:00.000000000 +0100
  2407. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.h 2013-08-26 16:17:50.632137211 +0200
  2408. @@ -0,0 +1,25 @@
  2409. +#ifndef R_UTIL_SOX_H
  2410. +#define R_UTIL_SOX_H
  2411. +
  2412. +// attenzione che -norm e gain -n- 3 (che è la stessa cosa)
  2413. +// consumano MOLTO spazio x film lunghi > 10GB
  2414. +// meglio fare una passata con compfast poi fare avolumedetect sul file .mka ottenuto
  2415. +// e rifare compfast con -avolume n dove n è determinato dal maxvol di avolumedetect -5
  2416. +#define SOX_NORM "norm -3"
  2417. +#define SOX_COMPAND_STD_2 "compand 0.3,1 6:-70,-40,-20 -20 -90 0.2 gain -n -3" //2:1
  2418. +#define SOX_COMPAND_FILM_STD "compand 0.1,0.3 -90,-90,-70,-64,-43,-37,-31,-31,-21,-21,0,-20 0 0 0.1 gain -n -3"
  2419. +#define SOX_COMPAND_FILM_STD_NO_NORM "compand 0.1,0.3 -90,-90,-70,-64,-43,-37,-31,-31,-21,-21,0,-20 0 0 0.1"
  2420. +// cartella temp di sox per norm che richiede molto spazio
  2421. +#define SOX_TEMP_DEFAULT "--temp ."
  2422. +#define SOX_TEMP_MY_SETT "--temp /home/mc/rec/temp"
  2423. +/*
  2424. +old SOX_COMPAND_STD_2 ("compand 0.3,1 6:-70,-40,-20 -5 -90 0.2"); //2:1
  2425. +std::string sox_compand_std ("compand 0.3,1 6:-70,-60,-20 -5 -90 0.2"); //3 :1
  2426. +std::string sox_compand_film_orig ("compand 0.1,0.3 -90,-90,-70,-64,-43,-37,-31,-31,-21,-21,0,-20 0 0 0.1");
  2427. +std::string sox_compand_film ("compand 0.1,0.4 6:-70,-43,-20,-12,-10 -6 -80 0.1");
  2428. +std::string sox_compand_film_2 ("compand 0.1,0.3 3:-90,-90,-70,-64,-43,-37,-31,-28,-21,-19,0,-6 0 0 0.1");
  2429. +*/
  2430. +
  2431. +bool is_util_sox (int argc, char * argv[], s_dati *dati);
  2432. +
  2433. +#endif
  2434. diff -Naur -x '*~' src/routines/r-video-asp-avi.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-asp-avi.cpp
  2435. --- src/routines/r-video-asp-avi.cpp 1970-01-01 01:00:00.000000000 +0100
  2436. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-asp-avi.cpp 2013-08-26 00:12:17.653395042 +0200
  2437. @@ -0,0 +1,78 @@
  2438. +#include "../main.h"
  2439. +#include "../funzioni.h"
  2440. +#include "r-video-asp-avi.h"
  2441. +
  2442. +bool is_mpeg4_avi_xvid (int argc, char * argv[], s_dati *dati)
  2443. +{
  2444. + bool is_mpeg4 = false;
  2445. + bool is_avi = false;
  2446. + bool is_xvid = false;
  2447. + for (int i=2; i<argc; i++)
  2448. + {
  2449. + if (std::string(argv[i]) == "-mpeg4")
  2450. + {
  2451. + is_mpeg4 = true;
  2452. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2453. + }
  2454. + if (std::string(argv[i]) == "-avi")
  2455. + {
  2456. + is_avi = true;
  2457. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2458. + }
  2459. + if (std::string(argv[i]) == "-xvid")
  2460. + {
  2461. + is_xvid = true;
  2462. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2463. + }
  2464. + }
  2465. + if (
  2466. + is_mpeg4
  2467. + || is_avi
  2468. + || is_xvid
  2469. + )
  2470. + {
  2471. + dati->vcodec = VCODEC_MPEG4;
  2472. + dati->video_codec_is = VIDEO_IS_MPEG4;
  2473. + dati->preset="";
  2474. + dati->profile="";
  2475. + dati->set_264="";
  2476. + if (dati->b_v_rate == 0)
  2477. + dati->bitrate_video = BITRATE_VIDEO_MPEG4_DEFAULT;
  2478. + if (dati->pass == 3)
  2479. + dati->pass = 2;
  2480. + }
  2481. + if ( is_xvid )
  2482. + {
  2483. + if ( dati->nuova_estensione == NUOVA_EXT_MP4 )
  2484. + {
  2485. + printf ("\nAttenzione,\n-xvid non è compatibile con il formato -mp4\n");
  2486. + printf ("Usare -mpeg4 con il formato -mp4\n\n");
  2487. + return false;
  2488. + }
  2489. + dati->vcodec = (std::string)VCODEC_MPEG4 + " " + XVID_TAG;
  2490. + dati->video_codec_is = VIDEO_IS_MPEG4_XVID;
  2491. + }
  2492. + if (is_avi)
  2493. + {
  2494. + // check -mp4
  2495. + if ( dati->nuova_estensione == NUOVA_EXT_MP4 )
  2496. + {
  2497. + printf ("\nAttenzione,\nè stato selezionato anche il formato -mp4 insieme ad -avi -xvid\n");
  2498. + printf ("Verificare i parametri inseriti.\n\n");
  2499. + return false;
  2500. + }
  2501. + // audio avi - no aac no aac+ solo mp3
  2502. + if ( (dati->audio_codec_is != AUDIO_IS_LAME)
  2503. + && (dati->audio_codec_is != "")
  2504. + )
  2505. + {
  2506. + dati->audio_parm = AUDIO_PARM_LAME_C128;
  2507. + dati->audio_codec_is = AUDIO_IS_LAME;
  2508. + }
  2509. + dati->format_out = FORMAT_OUT_AVI;
  2510. + dati->nuova_estensione = NUOVA_EXT_AVI;
  2511. + }
  2512. +
  2513. + return true;
  2514. +}
  2515. +
  2516. diff -Naur -x '*~' src/routines/r-video-asp-avi.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-asp-avi.h
  2517. --- src/routines/r-video-asp-avi.h 1970-01-01 01:00:00.000000000 +0100
  2518. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-asp-avi.h 2013-08-23 21:37:42.000000000 +0200
  2519. @@ -0,0 +1,8 @@
  2520. +#ifndef R_VIDEO_ASP_AVI_H
  2521. +#define R_VIDEO_ASP_AVI_H
  2522. +
  2523. +bool is_mpeg4_avi_xvid
  2524. + (int argc, char * argv[], s_dati *dati);
  2525. +
  2526. +
  2527. +#endif
  2528. diff -Naur -x '*~' src/routines/r-video-generali.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.cpp
  2529. --- src/routines/r-video-generali.cpp 1970-01-01 01:00:00.000000000 +0100
  2530. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.cpp 2013-11-10 16:15:26.510972234 +0100
  2531. @@ -0,0 +1,214 @@
  2532. +#include "../main.h"
  2533. +#include "../funzioni.h"
  2534. +#include "r-video-generali.h"
  2535. +
  2536. +bool passate (int argc, char * argv[], s_dati *dati)
  2537. +{
  2538. + for (int i=2; i<argc; i++)
  2539. + {
  2540. + if (std::string(argv[i]) == "-pass")
  2541. + {
  2542. + if ( !check_num_param (argc,i,1) )
  2543. + return false;
  2544. + dati->pass = atoi(argv[i+1]);
  2545. + // check
  2546. + if (dati->pass < 1 || dati->pass >3)
  2547. + {
  2548. + printf ("\nInserire -pass 2 o 3.\n");
  2549. + return false;
  2550. + }
  2551. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  2552. + break;
  2553. + }
  2554. + }
  2555. + return true;
  2556. +}
  2557. +
  2558. +bool frame_rate (int argc, char * argv[], s_dati *dati)
  2559. +{
  2560. + for (int i=2; i<argc; i++)
  2561. + {
  2562. + if (std::string(argv[i]) == "-r")
  2563. + {
  2564. + if ( !check_num_param (argc,i,1) )
  2565. + return false;
  2566. + if ( is_number(argv[i+1]) )
  2567. + {
  2568. + dati->rate = "-r " + std::string(argv[i+1]);
  2569. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  2570. + break;
  2571. + }
  2572. + else
  2573. + {
  2574. + printf("\nInserire un frame rate corretto.\n\n");
  2575. + return false;
  2576. + }
  2577. + }
  2578. + }
  2579. + return true;
  2580. +}
  2581. +
  2582. +bool video_bit_rate (int argc, char * argv[], s_dati *dati)
  2583. +{
  2584. + // bitrate in k, es: -b 500 altimenti 730k
  2585. + for (int i=2; i<argc; i++)
  2586. + {
  2587. + if (std::string(argv[i]) == "-b")
  2588. + {
  2589. + if ( !check_num_param (argc,i,1) )
  2590. + {
  2591. + printf ("\nInserire un bitrate video corretto.\n\n");
  2592. + return false;
  2593. + }
  2594. + // check argomento 300 to 4000
  2595. + dati->b_v_rate = atoi(argv[i+1]);
  2596. + if ( dati->b_v_rate < 300 || dati->b_v_rate > 4000)
  2597. + {
  2598. + printf ("\nInserire un bitrate video corretto.\n\n");
  2599. + return false;
  2600. + }
  2601. + // fine check
  2602. + char temp [6];
  2603. + sprintf(temp,"%i",dati->b_v_rate);
  2604. + dati->bitrate_video = "-b:v " + (std::string)temp + "k";
  2605. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  2606. + break;
  2607. + }
  2608. + }
  2609. + return true;
  2610. +}
  2611. +
  2612. +
  2613. +bool is_crf (int argc, char * argv[], s_dati *dati)
  2614. +{
  2615. + for (int i=2; i<argc; i++)
  2616. + {
  2617. +
  2618. + if (std::string(argv[i]) == "-crf")
  2619. + {
  2620. + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
  2621. + float qcrf (19.0); //default -crf 19
  2622. + if ( argc-1 >= i+1 )
  2623. + {
  2624. + if ( is_number( argv[i+1]) )
  2625. + {
  2626. + qcrf = atof(argv[i+1]);
  2627. + if ( qcrf < 0 || qcrf > 50)
  2628. + {
  2629. + printf ("\nInserire un valore crf corretto (0.0-50.0).\n\n");
  2630. + return false;
  2631. + }
  2632. + }
  2633. + }
  2634. + char qfact [10];
  2635. + sprintf (qfact,"%.1f",qcrf);
  2636. + setlocale (LC_ALL,""); // ripristino locale
  2637. + std::string crfval = "-crf " + (std::string)qfact;
  2638. + if (dati->video_codec_is == VIDEO_IS_X_264)
  2639. + {
  2640. + dati->pass = 1;
  2641. + dati->bitrate_video = (std::string)crfval;
  2642. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2643. + }
  2644. + break;
  2645. + }
  2646. + }
  2647. + return true;
  2648. +}
  2649. +
  2650. +void is_mp4_out (int argc, char * argv[], s_dati *dati)
  2651. +{
  2652. + for (int i=2; i<argc; i++)
  2653. + {
  2654. + if (std::string(argv[i]) == "-mp4")
  2655. + {
  2656. + dati->format_out = FORMAT_OUT_MP4;
  2657. + dati->nuova_estensione = NUOVA_EXT_MP4;
  2658. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2659. + break;
  2660. + }
  2661. + }
  2662. +}
  2663. +
  2664. +bool is_aspect (int argc, char * argv[], s_dati *dati)
  2665. +{
  2666. + for (int i=2; i<argc; i++)
  2667. + {
  2668. + if (std::string(argv[i]) == "-aspect")
  2669. + {
  2670. + if ( !check_num_param (argc,i,1) )
  2671. + return false;
  2672. + dati->aspetto = "-aspect " + std::string(argv[i+1]);
  2673. + dati->param_tot_previsti = dati->param_tot_previsti +2;
  2674. + break;
  2675. + }
  2676. + }
  2677. + return true;
  2678. +}
  2679. +
  2680. +
  2681. +void is_vcopy_copy (int argc, char * argv[], s_dati *dati)
  2682. +{
  2683. + for (int i=2; i<argc; i++)
  2684. + {
  2685. + if (std::string(argv[i]) == "-vcopy")
  2686. + {
  2687. + dati->vcodec = VCODEC_VCOPY;
  2688. + dati->video_codec_is = "";
  2689. + // azzeramento altri paramentri video
  2690. + dati->rate="";
  2691. + dati->preset="";
  2692. + dati->profile="";
  2693. + dati->set_264="";
  2694. + dati->bitrate_video="";
  2695. + dati->filter="";
  2696. + dati->pass=1;
  2697. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2698. + break;
  2699. + }
  2700. + }
  2701. +
  2702. + for (int i=2; i<argc; i++)
  2703. + {
  2704. + if (std::string(argv[i]) == "-copy")
  2705. + {
  2706. + dati->vcodec = VCODEC_COPY_ALL;
  2707. + dati->video_codec_is = "";
  2708. + // azzeramento altri paramentri video e audio
  2709. + dati->rate="";
  2710. + dati->preset="";
  2711. + dati->profile="";
  2712. + dati->set_264="";
  2713. + dati->bitrate_video="";
  2714. + dati->filter="";
  2715. + dati->a_filter_valore="";
  2716. + dati->pass=1;
  2717. + if (dati->audio_parm != AUDIO_PARM_NONE )
  2718. + dati->audio_parm="";
  2719. + dati->audio_codec_is = "";
  2720. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2721. + break;
  2722. + }
  2723. + }
  2724. +
  2725. + for (int i=2; i<argc; i++)
  2726. + {
  2727. + if (std::string(argv[i]) == "-vn")
  2728. + {
  2729. + dati->vcodec = VCODEC_NONE;
  2730. + dati->video_codec_is = "";
  2731. + // azzeramento altri paramentri video e audio
  2732. + dati->rate="";
  2733. + dati->preset="";
  2734. + dati->profile="";
  2735. + dati->set_264="";
  2736. + dati->bitrate_video="";
  2737. + dati->filter="";
  2738. + dati->pass=1;
  2739. + dati->format_out = FORMAT_OUT_MATROSKA;
  2740. + dati->nuova_estensione = NUOVA_EXT_MKA;
  2741. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2742. + break;
  2743. + }
  2744. + }
  2745. +}
  2746. diff -Naur -x '*~' src/routines/r-video-generali.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.h
  2747. --- src/routines/r-video-generali.h 1970-01-01 01:00:00.000000000 +0100
  2748. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.h 2013-11-10 16:04:15.554770404 +0100
  2749. @@ -0,0 +1,12 @@
  2750. +#ifndef R_VIDEO_GENERALI_H
  2751. +#define R_VIDEO_GENERALI_H
  2752. +
  2753. +bool passate (int argc, char * argv[], s_dati *dati);
  2754. +bool frame_rate (int argc, char * argv[], s_dati *dati);
  2755. +bool video_bit_rate (int argc, char * argv[], s_dati *dati);
  2756. +void is_mp4_out (int argc, char * argv[], s_dati *dati);
  2757. +bool is_aspect (int argc, char * argv[], s_dati *dati);
  2758. +void is_vcopy_copy (int argc, char * argv[], s_dati *dati);
  2759. +bool is_crf (int argc, char * argv[], s_dati *dati);
  2760. +
  2761. +#endif
  2762. diff -Naur -x '*~' src/routines/r-video-x264.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.cpp
  2763. --- src/routines/r-video-x264.cpp 1970-01-01 01:00:00.000000000 +0100
  2764. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.cpp 2013-08-26 00:12:39.070682443 +0200
  2765. @@ -0,0 +1,145 @@
  2766. +#include "../main.h"
  2767. +#include "../funzioni.h"
  2768. +#include "r-video-x264.h"
  2769. +
  2770. +void no_fast (int argc, char * argv[], s_dati *dati)
  2771. +{
  2772. + for (int i=2; i<argc; i++)
  2773. + {
  2774. + if (std::string(argv[i]) == "-nofast")
  2775. + {
  2776. + dati->nofastfirst = true;
  2777. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2778. + break;
  2779. + }
  2780. + }
  2781. +}
  2782. +
  2783. +void is_preset (int argc, char * argv[], s_dati *dati)
  2784. +{
  2785. + for (int i=2; i<argc; i++)
  2786. + {
  2787. +
  2788. + if (std::string(argv[i]) == "-fast")
  2789. + {
  2790. + dati->preset = PRESET_FAST;
  2791. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2792. + break;
  2793. + }
  2794. + if (std::string(argv[i]) == "-medium")
  2795. + {
  2796. + dati->preset = PRESET_MEDIUM;
  2797. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2798. + break;
  2799. + }
  2800. + if (std::string(argv[i]) == "-slow")
  2801. + {
  2802. + dati->preset = PRESET_SLOW;
  2803. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2804. + break;
  2805. + }
  2806. +
  2807. + }
  2808. +}
  2809. +
  2810. +void is_profile (int argc, char * argv[], s_dati *dati)
  2811. +{
  2812. + for (int i=2; i<argc; i++)
  2813. + {
  2814. + if (std::string(argv[i]) == "-main")
  2815. + {
  2816. + dati->profile = PROFILE_MAIN;
  2817. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2818. + break;
  2819. + }
  2820. + if (std::string(argv[i]) == "-high")
  2821. + {
  2822. + dati->profile = PROFILE_HIGH;
  2823. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2824. + break;
  2825. + }
  2826. +
  2827. + }
  2828. +}
  2829. +
  2830. +void is_nopts (int argc, char * argv[], s_dati *dati)
  2831. +{
  2832. + for (int i=2; i<argc; i++)
  2833. + {
  2834. + if (std::string(argv[i]) == "-nopts")
  2835. + {
  2836. + dati->set_264 = OPT_264_NOPTS;
  2837. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2838. + break;
  2839. + }
  2840. + }
  2841. +}
  2842. +
  2843. +void is_opencl (int argc, char * argv[], s_dati *dati)
  2844. +{
  2845. + for (int i=2; i<argc; i++)
  2846. + {
  2847. + if (std::string(argv[i]) == "-opencl")
  2848. + {
  2849. + dati->set_264 = dati->set_264 + ":opencl";
  2850. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2851. + break;
  2852. + }
  2853. + }
  2854. +}
  2855. +
  2856. +void is_nr_denoise (int argc, char * argv[], s_dati *dati)
  2857. +{
  2858. + for (int i=2; i<argc; i++)
  2859. + {
  2860. + if (std::string(argv[i]) == "-nr200")
  2861. + {
  2862. + dati->set_264 = dati->set_264 + ":nr=200";
  2863. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2864. + break;
  2865. + }
  2866. + if (std::string(argv[i]) == "-nr500")
  2867. + {
  2868. + dati->set_264 = dati->set_264 + ":nr=500";
  2869. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2870. + break;
  2871. + }
  2872. + }
  2873. +}
  2874. +
  2875. +void is_level (int argc, char * argv[], s_dati *dati)
  2876. +{
  2877. + for (int i=2; i<argc; i++)
  2878. + {
  2879. + if (std::string(argv[i]) == "-level1")
  2880. + {
  2881. + dati->set_264 = dati->set_264 + ":" + LEVEL_1_0;
  2882. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2883. + break;
  2884. + }
  2885. + if (std::string(argv[i]) == "-level2")
  2886. + {
  2887. + dati->set_264 = dati->set_264 + ":" + LEVEL_2_0;
  2888. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2889. + break;
  2890. + }
  2891. + if (std::string(argv[i]) == "-level3")
  2892. + {
  2893. + dati->set_264 = dati->set_264 + ":" + LEVEL_3_0;
  2894. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2895. + break;
  2896. + }
  2897. + if (std::string(argv[i]) == "-level4")
  2898. + {
  2899. + dati->set_264 = dati->set_264 + ":" + LEVEL_4_0;
  2900. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2901. + break;
  2902. + }
  2903. + if (std::string(argv[i]) == "-level5")
  2904. + {
  2905. + dati->set_264 = dati->set_264 + ":" + LEVEL_5_0;
  2906. + dati->param_tot_previsti = dati->param_tot_previsti +1;
  2907. + break;
  2908. + }
  2909. + }
  2910. +}
  2911. diff -Naur -x '*~' src/routines/r-video-x264.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.h
  2912. --- src/routines/r-video-x264.h 1970-01-01 01:00:00.000000000 +0100
  2913. +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.h 2013-08-23 21:28:23.000000000 +0200
  2914. @@ -0,0 +1,12 @@
  2915. +#ifndef R_VIDEO_X264_H
  2916. +#define R_VIDEO_X264_H
  2917. +
  2918. +void no_fast (int argc, char * argv[], s_dati *dati);
  2919. +void is_preset (int argc, char * argv[], s_dati *dati);
  2920. +void is_profile (int argc, char * argv[], s_dati *dati);
  2921. +void is_nopts (int argc, char * argv[], s_dati *dati);
  2922. +void is_opencl (int argc, char * argv[], s_dati *dati);
  2923. +void is_nr_denoise (int argc, char * argv[], s_dati *dati);
  2924. +void is_level (int argc, char * argv[], s_dati *dati);
  2925. +
  2926. +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement