Advertisement
Guest User

2.38

a guest
Aug 23rd, 2013
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.19 KB | None | 0 0
  1. diff -Naur -x '*~' src/730-ffmpeg-tool-main.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/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/3/730-ffmpeg-tool/src/730-ffmpeg-tool-main.cpp 2013-08-23 14:30:52.156955283 +0200
  4. @@ -0,0 +1,520 @@
  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. +
  16. +
  17. +
  18. +
  19. +const std::string versione ("p-2.38");
  20. +const std::string filesettaggi_version ("v1.1");
  21. +
  22. +int main(int argc, char * argv[])
  23. +{
  24. + setlocale (LC_ALL,"");
  25. + // eseguibile
  26. + std::string eseguibile (eseguibile_ffmpeg);
  27. + std::string estensione_file_in ("");
  28. + std::string nuova_estensione (nuova_estensione_mkv);
  29. + bool debug = false;
  30. + std::string rate ("");
  31. + std::string maps("");
  32. + std::string vcodec (vcodec_x264);
  33. + std::string video_codec_is (VIDEO_IS_X_264);
  34. + std::string bitrate_video (bitrate_video_x264_default);
  35. + int b_v_rate = 0;
  36. + std::string preset (preset_faster);
  37. + std::string profile ("");
  38. + std::string set_264 (opt_264_1);
  39. + std::string audio_parm (audio_parm_a112);
  40. + std::string audio_codec_is (AUDIO_IS_FDKAAC);
  41. + int pass = 1;
  42. + bool nofastfirst (0);
  43. + std::string filter ("");
  44. + std::string filtervalore (""); // per utility vftest
  45. + std::string a_filter ("");
  46. + std::string tempoin ("");
  47. + std::string tempodur ("");
  48. + std::string logfile ("");
  49. + std::string altro ("");
  50. + std::string aspetto ("");
  51. + std::string format_out (format_out_mkv);
  52. + std::string nuovo_nome_file_out ("");
  53. + // stringa finale daeseguire
  54. + std::string daeseguire ("");
  55. + // variabili cronometri
  56. + time_t now;
  57. + double seconds, seconds2start, seconds3start;
  58. + double durata, durata1, durata2, durata3;
  59. + //
  60. +
  61. + // check che venga passato almeno il nome del file
  62. + if (argc < 2) {
  63. + printf ("\n");
  64. + printf ("Usare: %s nomefile\n", argv[0]);
  65. + printf ("Help: %s -h\n", argv[0]);
  66. + printf ("versione: %s\n", versione.c_str() );
  67. + printf ("\n");
  68. + return 1;
  69. + }
  70. +
  71. + // -h help
  72. + if (std::string(argv[1]) == "-h") {
  73. + stampa_help(argv[0]);
  74. + return 0;
  75. + }
  76. +
  77. +
  78. + // nome del file con path
  79. + const std::string nomefilein (argv[1]);
  80. + std::string verifica = nomefilein.substr ( (nomefilein.length() -1) ,1);
  81. + if (verifica == "/"){
  82. + printf ("\nAttenzione: %s è una cartella.\n\n", nomefilein.c_str() );
  83. + return 1;
  84. + }
  85. + // nome del file senza path
  86. + const std::string nomedelfile ( rimuovi_path(nomefilein) );
  87. + // estensione del file
  88. + estensione_file_in = tipo_ext (nomedelfile);
  89. + // nome del file senza ext
  90. + std::string nome_file_senza_ext ( removeExtension (nomedelfile.c_str()) );
  91. +
  92. + // check se il file input esiste
  93. + if ( !fileExists (nomefilein.c_str()) ){
  94. + printf ("\nIl file: %s non esiste.\n\n", nomefilein.c_str() );
  95. + return 1;
  96. + }
  97. +
  98. + // check minimale sul numero parametri immessi
  99. + int param_tot_previsti = 2;
  100. +
  101. +
  102. + // debug stampa solo i comandi senza eseguirli
  103. + isdebug (argc, argv, &param_tot_previsti, &debug);
  104. +
  105. +
  106. + // frame rate, -r 25
  107. + if ( !frame_rate (argc, argv, &param_tot_previsti, &rate) )
  108. + return 1;
  109. +
  110. +
  111. + // -map (multipli) es -map 0:0 -map 0:1
  112. + if ( !is_map (argc, argv, &param_tot_previsti, &maps) )
  113. + return 1;
  114. +
  115. +
  116. + // bitrate in k, es: -b 500 altimenti 730k
  117. + if ( !video_bit_rate (argc, argv, &param_tot_previsti, &b_v_rate, &bitrate_video) )
  118. + return 1;
  119. +
  120. +
  121. + // parametri video: default preset="-preset faster -tune film"
  122. + // -fast -medium -slow
  123. + is_preset (argc, argv, &param_tot_previsti, &preset);
  124. +
  125. +
  126. + // profile: -main -high, default auto
  127. + is_profile (argc, argv, &param_tot_previsti, &profile);
  128. +
  129. +
  130. + // opts264
  131. + // -nopts = parametri del preset senza tuning personale
  132. + is_nopts (argc, argv, &param_tot_previsti, &set_264);
  133. +
  134. +
  135. + // opencl lookahead
  136. + // -opencl
  137. + is_opencl (argc, argv, &param_tot_previsti, &set_264);
  138. +
  139. +
  140. + // -nr x264 fastdenoise da 100 a 1000 -nr200 -nr500
  141. + // non usare se usate -vf |denoiser|
  142. + is_nr_denoise (argc, argv, &param_tot_previsti, &set_264);
  143. +
  144. +
  145. + // -level1 to 5, default auto
  146. + is_level (argc, argv, &param_tot_previsti, &set_264);
  147. +
  148. +
  149. + // -10bit = x264 10 bit depth
  150. + is_10bit (argc, argv, &param_tot_previsti, &eseguibile);
  151. +
  152. + // eventualmente implementare -af audio filter
  153. +
  154. + // -avolume -20 20
  155. + if ( !is_avolume (argc, argv, &param_tot_previsti, &a_filter) )
  156. + return 1;
  157. +
  158. + // audio
  159. + // -a32 -a64 -a96 -a128 -acopy -an
  160. + // -alameq 0-9
  161. + // -alameb 32-320 (K)
  162. + if ( !is_audio (argc, argv, &param_tot_previsti, &audio_parm, &audio_codec_is, &a_filter) )
  163. + return 1;
  164. +
  165. + // -aboost // solo per fdk_aac - dopo avi altrimenti i confronti audio_parm non funzionano
  166. + is_aboost (argc, argv, &param_tot_previsti, &audio_parm, &audio_codec_is);
  167. +
  168. + // -pass passate 1,2 o 3 (3 solo x264)
  169. + if ( !passate (argc, argv , &param_tot_previsti, &pass) )
  170. + return 1;
  171. +
  172. +
  173. + // -nofast -fastfirstpass 0
  174. + no_fast (argc, argv, &param_tot_previsti, &nofastfirst);
  175. +
  176. +
  177. + // filtri -vf deshake,pp=ac/al
  178. + if ( !is_filter (argc, argv, &param_tot_previsti, &filter, &filtervalore) )
  179. + return 1;
  180. +
  181. +
  182. + // tempo start e durata, esempio -ss 00:03:00 -t 00:05:00 oppure -ss 120 -t 60
  183. + // -ss
  184. + if ( !is_ss_is_t (argc, argv, &param_tot_previsti, &tempoin, &tempodur) )
  185. + return 1;
  186. +
  187. +
  188. + // -log logfile ffmpeg
  189. + is_log (argc, argv, &param_tot_previsti, &logfile);
  190. +
  191. +
  192. + // -mp4 .mp4
  193. + is_mp4_out (argc, argv, &param_tot_previsti, &format_out, &nuova_estensione);
  194. +
  195. +
  196. + // -mpeg4
  197. + // -avi
  198. + // -xvid
  199. + if ( !is_mpeg4_avi_xvid
  200. + (argc, argv,
  201. + &param_tot_previsti,
  202. + &vcodec,
  203. + &preset,
  204. + &profile,
  205. + &set_264,
  206. + &b_v_rate,
  207. + &bitrate_video,
  208. + &pass,
  209. + &nuova_estensione,
  210. + &audio_parm,
  211. + &format_out,
  212. + &audio_codec_is,
  213. + &video_codec_is)
  214. + )
  215. + return 1;
  216. +
  217. +
  218. + //// altri parametri
  219. + // -nometa -map_metadata -1
  220. + // -scopy -c:s copy subtitles
  221. + is_altro (argc, argv, &param_tot_previsti, &altro);
  222. +
  223. +
  224. + // -vcopy = -c:v copy
  225. + // -copy = -c copy
  226. + is_vcopy_copy (argc, argv,
  227. + &param_tot_previsti,
  228. + &vcodec,
  229. + &rate,
  230. + &preset,
  231. + &profile,
  232. + &set_264,
  233. + &bitrate_video,
  234. + &filter,
  235. + &pass,
  236. + &audio_parm,
  237. + &a_filter,
  238. + &video_codec_is,
  239. + &audio_codec_is);
  240. +
  241. +
  242. + // -aspect 4:3 16/9 (da usare solo con video copy,
  243. + // se codificate -vf setdar=16/9)
  244. + if ( !is_aspect (argc, argv, &param_tot_previsti, &aspetto) )
  245. + return 1;
  246. +
  247. +
  248. + // -h help in posizione > 1
  249. + for (int i=2; i<argc; i++) {
  250. + if (std::string(argv[i]) == "-h") {
  251. + stampa_help(argv[0]);
  252. + return 0;
  253. + }
  254. + }
  255. +
  256. +
  257. + // utility mkvinfo
  258. + if ( !is_util_mkvinfo (argc, argv, nomefilein, nomedelfile, &estensione_file_in) )
  259. + return 0;
  260. +
  261. + // utility mgm (mkvmerge gui)
  262. + if ( !is_util_mkvmerge (argc, argv, nomefilein, nomedelfile, &estensione_file_in) )
  263. + return 0;
  264. +
  265. + // utility probe
  266. + if ( !is_util_probe (argc, argv, nomefilein) )
  267. + return 0;
  268. +
  269. +
  270. + // utility play (preview con -map -ss e -vf)
  271. + if ( !is_util_play (argc, argv,
  272. + nomefilein,
  273. + &filter,
  274. + &tempoin,
  275. + &maps)
  276. + )
  277. + return 0;
  278. +
  279. + // utility -hf filter, -h filter=unsharp
  280. + if ( !is_util_help_filter (argc, argv) )
  281. + return 0;
  282. +
  283. + // utility vftest 2 video verticali
  284. + // filtervalore per utility vftest
  285. + if ( !is_util_vftest (argc, argv,
  286. + nomefilein,
  287. + &filtervalore,
  288. + &tempoin)
  289. + )
  290. + return 0;
  291. +
  292. + // utility vftestsp video split
  293. + if ( !is_util_vftestsp (argc, argv,
  294. + nomefilein,
  295. + &filtervalore,
  296. + &tempoin)
  297. + )
  298. + return 0;
  299. +
  300. + // utility calcola scala proporzionale
  301. + // calc 720 0 16 9 o calc 0 480 4 3
  302. + if ( !is_util_calc_scale (argc, argv) )
  303. + return 0;
  304. +
  305. +
  306. + // utility scrivi leggi settaggi su file
  307. + // save | load nomefile (con o senza .estensione e senza spazi)
  308. + if ( !is_load_save (argc, argv,
  309. + &param_tot_previsti,
  310. + filesettaggi_version,
  311. + &maps,
  312. + &bitrate_video,
  313. + &filter,
  314. + &set_264,
  315. + &preset,
  316. + &pass,
  317. + &audio_parm,
  318. + &format_out,
  319. + &vcodec,
  320. + &nuova_estensione)
  321. + )
  322. + return 0;
  323. +
  324. + // utility
  325. + // muxer nomefile2audio
  326. + if ( !is_muxer (argc, argv,
  327. + nomefilein,
  328. + &nome_file_senza_ext,
  329. + &maps,
  330. + &tempodur,
  331. + &debug)
  332. + )
  333. + return 0;
  334. +
  335. + // utility
  336. + // volumedet = -af volumedetect
  337. + if ( !is_util_volumedetect (argc, argv,
  338. + nomefilein,
  339. + &tempoin,
  340. + &tempodur,
  341. + &maps)
  342. + )
  343. + return 0;
  344. +
  345. + // sox
  346. + if (! is_util_sox (argc, argv,
  347. + nomefilein,
  348. + &nome_file_senza_ext,
  349. + &audio_parm,
  350. + &vcodec,
  351. + &rate,
  352. + &maps,
  353. + &tempoin,
  354. + &tempodur,
  355. + &debug)
  356. + )
  357. + return 0;
  358. +
  359. +
  360. + // nome fileout
  361. + // check se fileout esiste e nel caso rinomina _N_.ext
  362. + nuovo_nome_file_out = check_fileout_name_e_rename (nome_file_senza_ext, nuova_estensione);
  363. +
  364. + //
  365. +
  366. + printf ("\n");
  367. +
  368. + // check parametri totali in input
  369. + if (param_tot_previsti > argc){
  370. + debug = true;
  371. + printf ("\n\nVerificare i parametri inseriti:\n");
  372. + printf ("Immessi %i, previsti %i\n\n",argc, param_tot_previsti);
  373. + }
  374. +
  375. +
  376. + // esecuzione
  377. +
  378. + for (int i=1; i<=pass; i++) {
  379. +
  380. + daeseguire = (eseguibile + " ");
  381. + if (logfile != "")
  382. + daeseguire = daeseguire +logfile + " ";
  383. + if (
  384. + (pass==2 && i==1)
  385. + || (pass==3 && (i==1 || i==2))
  386. + )
  387. + daeseguire = daeseguire + "-y ";
  388. + daeseguire = daeseguire + "-i "
  389. + + "\"" + nomefilein + "\"" + " ";
  390. + if (rate != "")
  391. + daeseguire = daeseguire + rate + " ";
  392. + if (maps!= "")
  393. + daeseguire = daeseguire + maps + " ";
  394. + if (tempoin != "")
  395. + daeseguire = daeseguire + tempoin + " ";
  396. + if (tempodur != "")
  397. + daeseguire = daeseguire + tempodur + " ";
  398. + if (filter != "")
  399. + daeseguire = daeseguire + filter + " ";
  400. + if (vcodec != "")
  401. + daeseguire = daeseguire + vcodec + " ";
  402. + if (video_codec_is == VIDEO_IS_X_264) {
  403. + if (preset != "")
  404. + daeseguire = daeseguire + preset + " ";
  405. + if (profile != "")
  406. + daeseguire = daeseguire + profile + " ";
  407. + if (set_264 != "")
  408. + daeseguire = daeseguire + set_264 + " ";
  409. + }
  410. + if (bitrate_video != "")
  411. + daeseguire = daeseguire + bitrate_video + " ";
  412. + if (pass>=2 && i==1) {
  413. + daeseguire = daeseguire + "-pass 1" + " ";
  414. + if ( (nofastfirst == 0) && (video_codec_is == VIDEO_IS_X_264) )
  415. + daeseguire = daeseguire + fast_1pass + " ";
  416. + }
  417. + if (
  418. + (pass==2 && i==2)
  419. + || (pass==3 && i==3)
  420. + )
  421. + daeseguire = daeseguire + "-pass 2" + " ";
  422. + if (pass==3 && i==2)
  423. + daeseguire = daeseguire + "-pass 3" + " ";
  424. + if (
  425. + (pass==2 && i==1)
  426. + || (pass==3 && (i==1 || i==2))
  427. + )
  428. + daeseguire = daeseguire + audio_parm_none + " " + format_null + " " + out_null;
  429. + if (
  430. + pass==1
  431. + || (pass==2 && i==2)
  432. + || (pass==3 && i==3)
  433. + ){
  434. + if (a_filter != "")
  435. + daeseguire = daeseguire + a_filter + " ";
  436. + if (audio_parm != "")
  437. + daeseguire = daeseguire + audio_parm + " ";
  438. + daeseguire = (daeseguire + format_out + " ");
  439. + if (altro != "")
  440. + daeseguire = daeseguire + altro + " ";
  441. + if ( (video_codec_is != VIDEO_IS_X_264) && (aspetto != "") )
  442. + daeseguire = daeseguire + aspetto + " ";
  443. + daeseguire = daeseguire + "\"" + nuovo_nome_file_out + "\"";
  444. + }
  445. +
  446. +
  447. + if (!debug)
  448. + printf ("\n\n");
  449. +
  450. + printf ("%s\n\n", daeseguire.c_str());
  451. +
  452. +
  453. + if (!debug){
  454. + if (i==1) {
  455. +
  456. + seconds = time(&now);
  457. + if ( esegui(daeseguire.c_str()) !=0) return 1;
  458. + durata1 = difftime(time(&now),seconds);
  459. +
  460. + }
  461. +
  462. + if (i==2) {
  463. +
  464. + seconds2start = time(&now);
  465. + if (esegui (daeseguire.c_str()) !=0) return 1;
  466. + durata2 = difftime(time(&now),seconds2start);
  467. +
  468. + }
  469. +
  470. + if (i==3) {
  471. +
  472. + seconds3start = time(&now);
  473. + if ( esegui(daeseguire.c_str()) !=0) return 1;
  474. + durata3 = difftime(time(&now),seconds3start);
  475. +
  476. + }
  477. + }
  478. +
  479. + }
  480. +
  481. + // durata totale
  482. + durata = difftime(time(&now),seconds);
  483. +
  484. + // elimina i file stat delle passate
  485. + // ffmpeg2pass-0.log ffmpeg2pass-0.log.mbtree
  486. + if ( (pass>1) && (!debug) ){
  487. + if( remove( "ffmpeg2pass-0.log" ) != 0 )
  488. + perror( "Error deleting file" );
  489. + if (vcodec == vcodec_x264){
  490. + if( remove( "ffmpeg2pass-0.log.mbtree" ) != 0 )
  491. + perror( "Error deleting file" );
  492. + }
  493. + }
  494. +
  495. +
  496. + // stampa i cronometri
  497. + if (!debug) {
  498. + printf ("\n\nTempo conversione: ");
  499. + stampatempo (durata);
  500. + if ((pass==2) || (pass==3)){
  501. + printf ("\nPass 1: ");
  502. + stampatempo (durata1);
  503. + printf ("Pass 2: ");
  504. + stampatempo (durata2);
  505. + }
  506. + if (pass==3){
  507. + printf ("Pass 3: ");
  508. + stampatempo (durata3);
  509. + }
  510. + printf ("\n");
  511. + }
  512. +
  513. + // stampa le dimensioni in MB e data dei file in e out
  514. + if (!debug) {
  515. + stampa_info_file (nomefilein);
  516. + stampa_info_file (nuovo_nome_file_out);
  517. + }
  518. +
  519. + return 0;
  520. +}
  521. +
  522. +
  523. +
  524. +
  525. diff -Naur -x '*~' src/f-help.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/f-help.cpp
  526. --- src/f-help.cpp 1970-01-01 01:00:00.000000000 +0100
  527. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/f-help.cpp 2013-08-23 14:44:45.517071929 +0200
  528. @@ -0,0 +1,69 @@
  529. +#include "funzioni.h"
  530. +
  531. +////
  532. +
  533. +void stampa_help(char * prg)
  534. +{
  535. + printf ("\n");
  536. + printf ("%s \n", prg);
  537. + printf (" nomefile [obbligatorio]\n");
  538. + printf (" [opzioni]\n");
  539. + printf (" -b bitrate video [kb] (-b 600, default: 730 AVC, 1500 ASP)\n");
  540. + printf (" -pass passate (-pass 2, -pass 3, default: singola)\n");
  541. + printf (" -nofast (-fastfirstpass 0, default 1)\n");
  542. + printf (" -audio (-a32 -a64 (aacplus 32k 64k)\n");
  543. + printf (" -a96 -a128 (aac_fdk: 96k 128k, default: 112k)\n");
  544. + printf (" -alameq 0-9 (lame vbr da 0 a 9, 5 ~ 130k, 6 ~ 115k)\n");
  545. + printf (" -alameb 32-320 (lame cbr da 32 a 320k)\n");
  546. + printf (" -an (no audio), -acopy (copia))\n");
  547. + printf (" -aboost (aac_fdk -afterburner 1)\n");
  548. + printf (" -avolume -20 20 (varia il volume audio da -20 a +20db.\n");
  549. + printf (" usare prima volumedet per stabilire il fattore)\n");
  550. + printf (" -vcopy (-c:v copy, default no)\n");
  551. + printf (" -mpeg4 (-c:v mpeg4 -c:a libmp3lame 128k, out.mkv)\n");
  552. + printf (" -avi (come -mpeg4, out.avi)\n");
  553. + printf (" -xvid (-vtag XVID, come mpeg4)\n");
  554. + printf (" -mp4 (.mp4, incompatibile con -avi -xvid)\n");
  555. + printf (" -copy (-c copy, default no)\n");
  556. + printf (" -scopy (-c:s copy, subtitles, default no -> ass)\n");
  557. + printf (" -map (multipli, es: -map 0:1 -map 0:0)\n");
  558. + printf (" -preset (-fast, -medium, -slow, default: faster)\n");
  559. + printf (" -profile (-main, -high, default: auto)\n");
  560. + printf (" -level (da -level1 a -level5, default: auto)\n");
  561. + printf (" -nopts (x264opts = nulla, default: le mie)\n");
  562. + printf (" -opencl (x264 OpenCL lookahead, default: no)\n");
  563. + printf (" -nr200 -nr500 (x264 noise reduction nr=200 or 500, default: no\n");
  564. + printf (" non usare in contemporanea a -vf [denoise])\n");
  565. + printf (" -10bit (x264 10bit depth, default: no)\n");
  566. + printf (" -vf filtri (-vf pp=ac,hqdn3d=3)\n");
  567. + printf (" -ss inizio HH:MM:SS o sec (-ss 00:01:00 -ss 60)\n");
  568. + printf (" -t durata HH:MM:SS o sec (-t 00:02:00 -t 120)\n");
  569. + printf (" -r rate (-r 25, default auto come sorgente)\n");
  570. + printf (" -nometa (come -map_metadata -1, default no)\n");
  571. + printf (" -aspect (4:3 4/3 16:9, da usare solo con -copy -vcopy -mpeg4)\n");
  572. + printf (" debug (stampa solo i comandi senza eseguire)\n");
  573. + printf (" -log (-psnr -report su logfile)\n");
  574. + printf (" [Utility]\n");
  575. + printf (" play (esegue ffplay nomefile con -vf -ss e -map)\n");
  576. + printf (" probe (esegue ffprobe nomefile)\n");
  577. + printf (" -hf filtro (help filtro, come ffmpeg -h filter=yadif)\n");
  578. + printf (" vftest (esegue ffplay nomefile in 2 finestre con -vf applicati e -ss)\n");
  579. + printf (" vftestsp (come spopra ma split verticale, per test unsharp,hqdn3d,hue ...)\n");
  580. + printf (" calc 640 0 16 9 (oppure 0 480 4 3, calcola scale con proporzioni in multipli di 8)\n");
  581. + printf (" mkvinfo (fornisce informazioni sugli stream di un .mkv per estrarli poi con mkvextract)\n");
  582. + printf (" mmg (mkvmerge gui)\n");
  583. + printf (" save | load nomefile (senza .estensione e senza spazi) \n");
  584. + printf (" salva carica i settaggi per uso seriale. \n");
  585. + printf (" volumedet (statiche sul livello dell'audio, supporta -map -t -ss)\n");
  586. + printf (" sox norm | comp | compf [noshow mux]\n");
  587. + printf (" (usa sox per normalizzare | compand l'audio in un file .mka.\n");
  588. + printf (" validi i set audio -t -ss e -map, noshow sox progress.\n");
  589. + printf (" mux muxa in un file .mkv.)\n");
  590. + printf (" muxer nomesecondofile [mkv|avi|mp4] (muxa il video del filein con l'audio del secondo file.\n");
  591. + printf (" se non sono specificati -map usa -map 0:0 -map 1:0)\n");
  592. + printf ("\n");
  593. + printf ("esempio:\n");
  594. + printf ("\n");
  595. + printf ("%s video.mp4 -b 800 -pass 2 -a32 fast -vf pp=ac,hqdn3d=3\n", prg);
  596. + printf ("\n");
  597. +}
  598. diff -Naur -x '*~' src/funzioni.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.cpp
  599. --- src/funzioni.cpp 1970-01-01 01:00:00.000000000 +0100
  600. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.cpp 2013-08-23 14:31:26.271344809 +0200
  601. @@ -0,0 +1,229 @@
  602. +#include "funzioni.h"
  603. +
  604. +////////////////////////////////////////////////////////////////
  605. +
  606. +void stampatempo (double time_target)
  607. +{
  608. + const int ONE_HOUR = 60 * 60;
  609. + const int ONE_MINUTE = 60;
  610. +
  611. + int hour;
  612. + int min;
  613. + int sec;
  614. +
  615. + hour=time_target/ONE_HOUR;
  616. + time_target-=hour*ONE_HOUR;
  617. + min=time_target/ONE_MINUTE;
  618. + time_target-=min*ONE_MINUTE;
  619. + sec=time_target;
  620. +
  621. + printf("%02dh:%02dm:%02ds\n",hour,min,sec);
  622. +
  623. +}
  624. +
  625. +////
  626. +
  627. +std::string removeExtension (const std::string filename)
  628. +{
  629. + size_t lastdot = filename.find_last_of(".");
  630. + if (lastdot == std::string::npos) return filename;
  631. + return filename.substr(0, lastdot);
  632. +}
  633. +
  634. +////
  635. +
  636. +bool fileExists(const std::string& filename)
  637. +{
  638. + struct stat buf;
  639. + if (stat(filename.c_str(), &buf) != -1)
  640. + {
  641. + return true;
  642. + }
  643. + return false;
  644. +}
  645. +
  646. +////
  647. +
  648. +std::string tipo_ext (std::string file)
  649. +{
  650. + int found = file.find_last_of(".");
  651. + if (found != -1)
  652. + return (file.substr(found));
  653. + else
  654. + return "";
  655. +}
  656. +
  657. +////
  658. +
  659. +int esegui (const char* daeseg)
  660. +{
  661. + FILE * f = popen( daeseg, "r" );
  662. + if ( f == 0 ) {
  663. + fprintf( stderr, "Could not execute\n" );
  664. + return 1;
  665. + }
  666. + const int BUFSIZE = 1000;
  667. + char buf[ BUFSIZE ];
  668. + while( fgets( buf, BUFSIZE, f ) ) {
  669. + fprintf( stdout, "%s", buf );
  670. + }
  671. + pclose( f );
  672. + return 0;
  673. +}
  674. +
  675. +////
  676. +
  677. +std::string rimuovi_path (std::string file)
  678. +{
  679. + unsigned found = file.find_last_of("/\\");
  680. + return (file.substr(found+1));
  681. +}
  682. +
  683. +////
  684. +
  685. +std::string leggi_str_da_file (FILE * pFile )
  686. +{
  687. + char buffer_string [255];
  688. + std::string var;
  689. + fgets (buffer_string , 255 , pFile);
  690. + var = buffer_string;
  691. + var.erase ( var.size() -1);
  692. + return var;
  693. +}
  694. +
  695. +////
  696. +
  697. +int leggi_int_da_file (FILE * pFile )
  698. +{
  699. + char buffer_string [255];
  700. + int var;
  701. + fgets (buffer_string , 255 , pFile);
  702. + var = atoi (buffer_string); // pass è int
  703. + return var;
  704. +}
  705. +
  706. +////
  707. +
  708. +void scrivi_str_su_file (FILE * pFile, std::string var)
  709. +{
  710. + char buffer_string [255];
  711. + sprintf (buffer_string, "%s\n",var.c_str()) ;
  712. + fputs (buffer_string,pFile);
  713. +}
  714. +
  715. +////
  716. +
  717. +void scrivi_int_su_file (FILE * pFile, int var)
  718. +{
  719. + char buffer_string [255];
  720. + sprintf (buffer_string, "%i\n",var);
  721. + fputs (buffer_string,pFile);
  722. +}
  723. +
  724. +////
  725. +
  726. +void calcola_proporzioni (int w, int h, int aw, int ah)
  727. +{
  728. + float tmp;
  729. + if (h == 0){
  730. + tmp = ( float (w) / float (aw) ) * float (ah);
  731. + h = tmp;
  732. + if (w%2 != 0) // w è dispari
  733. + w = w +1;
  734. + if (h%2 != 0)
  735. + h = h +1;
  736. + }
  737. + if (w == 0){
  738. + tmp = ( float (h) / float (ah) ) * float (aw);
  739. + w = tmp;
  740. + if (h%2 != 0)
  741. + h = h +1;
  742. + if (w%2 != 0)
  743. + w = w +1;
  744. + }
  745. + printf ("\npiù prossima:\n");
  746. + printf ("\n-vf scale=%i:%i:flags=lanczos:setsar=1/1:setdar=%i/%i\n",w,h,aw,ah);
  747. +}
  748. +
  749. +////
  750. +
  751. +void calcola_proporzioni_8 (int w, int h, int aw, int ah)
  752. +{
  753. + float tmp;
  754. + if (h == 0){
  755. + tmp = ( float (w) / float (aw) ) * float (ah);
  756. + h = tmp;
  757. + if (h%2 != 0)
  758. + h = h +1;
  759. + h = (h / 8) * 8;
  760. + w = (w / 8) * 8;
  761. + }
  762. + if (w == 0){
  763. + tmp = ( float (h) / float (ah) ) * float (aw);
  764. + w = tmp;
  765. + if (w%2 != 0)
  766. + w = w +1;
  767. + w = (w / 8) * 8;
  768. + h = (h / 8) * 8;
  769. + }
  770. + printf ("\nmultipla di 8:\n");
  771. + printf ("\n-vf scale=%i:%i:flags=lanczos:setsar=1/1:setdar=%i/%i\n\n",w,h,aw,ah);
  772. +}
  773. +
  774. +////
  775. +
  776. +void stampa_info_file (std::string nome_del_file)
  777. +{
  778. + struct stat filestatus;
  779. + float size;
  780. + char dimensioni [20];
  781. + struct tm * timeinfo;
  782. + char data [80];
  783. + stat( nome_del_file.c_str(), &filestatus );
  784. + size = filestatus.st_size;
  785. + if (size < (1024.0 * 1024.0 * 2) ){
  786. + size = size / (1024.0);
  787. + sprintf (dimensioni, "%6.1f KB", size );
  788. + }
  789. + if ( size < (1024.0 * 1024.0 * 1024.0 * 2) && size >= (1024.0 * 1024.0 * 2) ){
  790. + size = size / (1024.0 * 1024.0);
  791. + sprintf (dimensioni, "%6.1f MB", size );
  792. + }
  793. + if (size >= (1024.0 * 1024.0 * 1024.0 * 2) ){
  794. + size = size / (1024.0 * 1024.0 * 1024.0);
  795. + sprintf (dimensioni, "%6.2f GB", size );
  796. + }
  797. + timeinfo = localtime (&filestatus.st_mtime);
  798. + strftime (data,80,"%a %d %b %Y %T",timeinfo);
  799. + printf ("%s - %s - %s\n", dimensioni , data , nome_del_file.c_str() );
  800. +}
  801. +
  802. +////
  803. +
  804. +bool check_num_param (int argc, int i, int num_previsti_dopo)
  805. +{
  806. + if ( (argc - 1) < (i + num_previsti_dopo) ) {
  807. + printf ("\nErrore: parametri insufficienti.\n\n");
  808. + return false;
  809. + }
  810. + return true; // ok
  811. +}
  812. +
  813. +////
  814. +
  815. +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione)
  816. +{
  817. + // nome fileout
  818. + std::string nome_file_out (nome_del_file_senza_estensione + estensione);
  819. + // check se fileout esiste e nel caso rinomina _N_.ext
  820. + char buffer_ifile [3];
  821. + for (int i=2; i<=9; i++) {
  822. + if ( fileExists (nome_file_out.c_str()) ){
  823. + sprintf (buffer_ifile, "%i", i); // i è int
  824. + nome_file_out = nome_del_file_senza_estensione + "_" + buffer_ifile + "_" + estensione;
  825. + }
  826. + }
  827. + return (nome_file_out);
  828. +}
  829. +
  830. +////
  831. diff -Naur -x '*~' src/funzioni.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.h
  832. --- src/funzioni.h 1970-01-01 01:00:00.000000000 +0100
  833. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.h 2013-08-21 03:34:09.285011885 +0200
  834. @@ -0,0 +1,34 @@
  835. +#ifndef FUNZIONI_H
  836. +#define FUNZIONI_H
  837. +
  838. +#ifndef NEED_LIBS_H
  839. +#define NEED_LIBS_H
  840. +#include <string>
  841. +#include <stdio.h>
  842. +#include <sys/types.h>
  843. +#include <sys/stat.h>
  844. +#include <time.h>
  845. +#include <stdlib.h> /* atoi */
  846. +#include <locale.h>
  847. +#endif
  848. +
  849. +////
  850. +void stampatempo (double time_target);
  851. +std::string removeExtension (const std::string filename);
  852. +bool fileExists(const std::string& filename);
  853. +std::string tipo_ext (std::string file);
  854. +int esegui (const char* daeseg); // 0
  855. +std::string rimuovi_path (std::string file);
  856. +std::string leggi_str_da_file (FILE * pFile );
  857. +int leggi_int_da_file (FILE * pFile );
  858. +void scrivi_str_su_file (FILE * pFile, std::string var);
  859. +void scrivi_int_su_file (FILE * pFile, int var);
  860. +void calcola_proporzioni (int w, int h, int aw, int ah);
  861. +void calcola_proporzioni_8 (int w, int h, int aw, int ah);
  862. +void stampa_info_file (std::string nome_del_file);
  863. +bool check_num_param (int argc, int i, int num_previsti_dopo);
  864. +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione);
  865. +////
  866. +void stampa_help(char * testo);
  867. +////
  868. +#endif
  869. diff -Naur -x '*~' src/main.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/main.h
  870. --- src/main.h 1970-01-01 01:00:00.000000000 +0100
  871. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/main.h 2013-08-21 17:28:23.595559625 +0200
  872. @@ -0,0 +1,73 @@
  873. +#ifndef MAIN_H
  874. +#define MAIN_H
  875. +
  876. +#ifndef NEED_LIBS_H
  877. +#define NEED_LIBS_H
  878. +#include <string>
  879. +#include <stdio.h>
  880. +#include <sys/types.h>
  881. +#include <sys/stat.h>
  882. +#include <time.h>
  883. +#include <stdlib.h> /* atoi */
  884. +#include <locale.h>
  885. +#endif
  886. +
  887. +// eseguibile ffmpeg
  888. +const std::string eseguibile_ffmpeg ("ffmpeg2");
  889. +// eseguibile 10bit
  890. +const std::string eseguibile10bit ("ffmpeg-x10bit");
  891. +// eseguibile play
  892. +const std::string eseguibileplay ("ffplay2");
  893. +// eseguibile probe
  894. +const std::string eseguibileprobe ("ffprobe2");
  895. +// eseguibile mkvinfo
  896. +const std::string eseguibilemkvinfo ("mkvinfo-gui -g");
  897. +// default e opzioni
  898. +const std::string nuova_estensione_avi (".avi");
  899. +const std::string nuova_estensione_mp4 (".mp4");
  900. +const std::string nuova_estensione_mkv (".mkv");
  901. +const std::string vcodec_x264 ("-c:v libx264");
  902. +const std::string vcodec_mpeg4 ("-c:v mpeg4 -mpv_flags strict_gop");
  903. +const std::string vcodec_vcopy ("-c:v copy");
  904. +const std::string vcodec_copy ("-c copy");
  905. +const std::string xvid_tag ("-vtag XVID");
  906. +const std::string VIDEO_IS_X_264 ("video_is_x_264");
  907. +const std::string VIDEO_IS_MPEG4 ("video_is_mpeg4");
  908. +const std::string VIDEO_IS_MPEG4_XVID ("video_is_mpeg4_xvid");
  909. +const std::string bitrate_video_x264_default ("-b:v 730k");
  910. +const std::string bitrate_video_mpeg4_default ("-b:v 1500k");
  911. +const std::string preset_faster ("-preset faster -tune film");
  912. +const std::string preset_fast ("-preset fast -tune film");
  913. +const std::string preset_medium ("-preset medium -tune film");
  914. +const std::string preset_slow ("-preset slow -tune film");
  915. +const std::string profile_main ("-profile:v main");
  916. +const std::string profile_high ("-profile:v high");
  917. +const std::string opt_264_1 ("-x264opts ref=4:bframes=4:direct=auto:aq-strength=1.3:ssim");
  918. +const std::string set_264_nopts ("-x264opts ssim");
  919. +const std::string livello1 ("level=1.0:ref=1:bframes=0:vbv-bufsize=218:vbv-maxrate=80");
  920. +const std::string livello2 ("level=2.0:ref=2:b-pyramid=none:vbv-bufsize=2500:vbv-maxrate=2500");
  921. +const std::string livello3 ("level=3.0:vbv-bufsize=12500:vbv-maxrate=12500");
  922. +const std::string livello4 ("level=4.0:vbv-bufsize=25000:vbv-maxrate=20000");
  923. +const std::string livello5 ("level=5.0:vbv-bufsize=168750:vbv-maxrate=168750");
  924. +const std::string audio_parm_a32 ("-c:a libaacplus -b:a 32k -ar 48k -ac 2");
  925. +const std::string audio_parm_a64 ("-c:a libaacplus -b:a 64k -ar 48k -ac 2");
  926. +const std::string audio_parm_a96 ("-c:a libfdk_aac -b:a 96k -ar 48k -ac 2");
  927. +const std::string audio_parm_a112 ("-c:a libfdk_aac -b:a 112k -ar 48k -ac 2");
  928. +const std::string audio_parm_a128 ("-c:a libfdk_aac -b:a 128k -ar 48k -ac 2");
  929. +const std::string audio_parm_copy ("-c:a copy");
  930. +const std::string audio_parm_none ("-an");
  931. +const std::string audio_parm_lame ("-c:a libmp3lame -b:a 128k -ar 48k -ac 2");
  932. +const std::string audio_boost ("-afterburner 1"); // solo per fdk_aac
  933. +const std::string AUDIO_IS_LAME ("audio_is_lame");
  934. +const std::string AUDIO_IS_FDKAAC ("audio_is_fdkaac");
  935. +const std::string AUDIO_IS_AACPLUS ("audio_is_aacplus");
  936. +const std::string filesettaggi_ext (".fftlset");
  937. +const std::string format_null ("-f null");
  938. +const std::string fast_1pass ( "-fastfirstpass 1");
  939. +const std::string format_out_avi ("-f avi");
  940. +const std::string format_out_mp4 ("-f mp4");
  941. +const std::string format_out_mkv ("-f matroska");
  942. +const std::string out_null ("/dev/null"); // linux
  943. +
  944. +#endif
  945. +
  946. diff -Naur -x '*~' src/makefile /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/makefile
  947. --- src/makefile 1970-01-01 01:00:00.000000000 +0100
  948. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/makefile 2013-08-21 13:41:16.000000000 +0200
  949. @@ -0,0 +1,19 @@
  950. +all:
  951. + g++ -O3 -o 730-ffmpeg-tool \
  952. + funzioni.cpp \
  953. + f-help.cpp \
  954. + routines/routines.cpp \
  955. + routines/r-video-generali.cpp \
  956. + routines/r-video-x264.cpp \
  957. + routines/r-video-asp-avi.cpp \
  958. + routines/r-audio.cpp \
  959. + routines/r-util.cpp \
  960. + routines/r-util-sox.cpp \
  961. + routines/r-file-sett.cpp \
  962. + 730-ffmpeg-tool-main.cpp -s
  963. +
  964. +
  965. +clean:
  966. + rm -f *.o *.a *~ routines/*.o routines/*~ 730-ffmpeg-tool
  967. +
  968. +
  969. diff -Naur -x '*~' src/routines/r-audio.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.cpp
  970. --- src/routines/r-audio.cpp 1970-01-01 01:00:00.000000000 +0100
  971. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.cpp 2013-08-22 16:21:39.137170592 +0200
  972. @@ -0,0 +1,125 @@
  973. +#include "../main.h"
  974. +#include "../funzioni.h"
  975. +#include "r-audio.h"
  976. +
  977. +bool is_audio (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is, std::string *a_filter)
  978. +{
  979. + // audio
  980. + // -a32 -a64 -a96 -a128 -acopy -an
  981. + // -alameq 0-9
  982. + for (int i=2; i<argc; i++) {
  983. +
  984. + if (std::string(argv[i]) == "-a32") {
  985. + *audio_parm = audio_parm_a32;
  986. + *audio_codec_is = AUDIO_IS_AACPLUS;
  987. + *param_tot_previsti = *param_tot_previsti +1;
  988. + break;
  989. + }
  990. + if (std::string(argv[i]) == "-a64") {
  991. + *audio_parm = audio_parm_a64;
  992. + *audio_codec_is = AUDIO_IS_AACPLUS;
  993. + *param_tot_previsti = *param_tot_previsti +1;
  994. + break;
  995. + }
  996. + if (std::string(argv[i]) == "-a96") {
  997. + *audio_parm = audio_parm_a96;
  998. + *audio_codec_is = AUDIO_IS_FDKAAC;
  999. + *param_tot_previsti = *param_tot_previsti +1;
  1000. + break;
  1001. + }
  1002. + if (std::string(argv[i]) == "-a128") {
  1003. + *audio_parm = audio_parm_a128;
  1004. + *audio_codec_is = AUDIO_IS_FDKAAC;
  1005. + *param_tot_previsti = *param_tot_previsti +1;
  1006. + break;
  1007. + }
  1008. + if (std::string(argv[i]) == "-acopy") {
  1009. + *audio_parm = audio_parm_copy;
  1010. + *audio_codec_is = "";
  1011. + *a_filter = "";
  1012. + *param_tot_previsti = *param_tot_previsti +1;
  1013. + break;
  1014. + }
  1015. + if (std::string(argv[i]) == "-an") {
  1016. + *audio_parm = audio_parm_none;
  1017. + *audio_codec_is = "";
  1018. + *a_filter = "";
  1019. + *param_tot_previsti = *param_tot_previsti +1;
  1020. + break;
  1021. + }
  1022. + if (std::string(argv[i]) == "-alameq") {
  1023. + if ( !check_num_param (argc,i,1) )
  1024. + return false;
  1025. + // check argomento 0 to 9
  1026. + int q = atoi(argv[i+1]);
  1027. + if ( q < 0 || q > 9) {
  1028. + printf ("\nInserire un q corretto (0-9).\n");
  1029. + return false;
  1030. + }
  1031. + std::string audio_parm_lameq = "-c:a libmp3lame -q:a " + std::string(argv[i+1]) + " -ar 48k -ac 2";
  1032. + *audio_parm = audio_parm_lameq;
  1033. + *audio_codec_is = AUDIO_IS_LAME;
  1034. + *param_tot_previsti = *param_tot_previsti +2;
  1035. + break;
  1036. + }
  1037. + if (std::string(argv[i]) == "-alameb") {
  1038. + if ( !check_num_param (argc,i,1) )
  1039. + return false;
  1040. + // check argomento 32 to 320
  1041. + int ba = atoi(argv[i+1]);
  1042. + if ( ba < 32 || ba > 320) {
  1043. + printf ("\nInserire un bitrate audio corretto (32-320).\n");
  1044. + return false;
  1045. + }
  1046. + std::string audio_parm_lameb = "-c:a libmp3lame -b:a " + std::string(argv[i+1]) + "k -ar 48k -ac 2";
  1047. + *audio_parm = audio_parm_lameb;
  1048. + *audio_codec_is = AUDIO_IS_LAME;
  1049. + *param_tot_previsti = *param_tot_previsti +2;
  1050. + break;
  1051. + }
  1052. + }
  1053. + return true;
  1054. +}
  1055. +
  1056. +void is_aboost (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is)
  1057. +{
  1058. + // -aboost // solo per fdk_aac
  1059. + for (int i=2; i<argc; i++) {
  1060. + if (std::string(argv[i]) == "-aboost"){
  1061. + // solo audio fdk_aac
  1062. + if ( *audio_codec_is == AUDIO_IS_FDKAAC ){
  1063. + *audio_parm = *audio_parm + " " + audio_boost;
  1064. + *param_tot_previsti = *param_tot_previsti +1;
  1065. + }
  1066. + break;
  1067. + }
  1068. + }
  1069. +}
  1070. +
  1071. +bool is_avolume (int argc, char * argv[], int *param_tot_previsti, std::string *a_filter)
  1072. +{
  1073. + for (int i=2; i<argc; i++) {
  1074. + if (std::string(argv[i]) == "-avolume") {
  1075. + if ( !check_num_param (argc,i,1) ){
  1076. + printf ("\nInserire un fattore di amplificazione corretto (da -20 a 20).\n");
  1077. + printf ("Usare: volumedet per stabilirlo.\n");
  1078. + return false;
  1079. + }
  1080. + int amp = atoi(argv[i+1]);
  1081. + if ( amp < -20 || amp > 20) {
  1082. + printf ("\nInserire un fattore di amplificazione corretto (da -20 a 20).\n");
  1083. + printf ("Usare: volumedet per stabilirlo.\n");
  1084. + return false;
  1085. + }
  1086. + if ( *a_filter == "" )
  1087. + *a_filter = "-af volume=volume=" + std::string(argv[i+1]) + "dB:precision=fixed";
  1088. + else
  1089. + *a_filter = *a_filter + "," + "-af volume=volume=" + std::string(argv[i+1]) + "15dB:precision=fixed";
  1090. + *param_tot_previsti = *param_tot_previsti +2;
  1091. + break;
  1092. + }
  1093. + }
  1094. + return true;
  1095. +}
  1096. +
  1097. +
  1098. diff -Naur -x '*~' src/routines/r-audio.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.h
  1099. --- src/routines/r-audio.h 1970-01-01 01:00:00.000000000 +0100
  1100. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.h 2013-08-22 16:04:27.507157986 +0200
  1101. @@ -0,0 +1,8 @@
  1102. +#ifndef R_AUDIO_H
  1103. +#define R_AUDIO_H
  1104. +
  1105. +bool is_audio (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is, std::string *a_filter );
  1106. +void is_aboost (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is);
  1107. +bool is_avolume (int argc, char * argv[], int *param_tot_previsti, std::string *a_filter);
  1108. +
  1109. +#endif
  1110. diff -Naur -x '*~' src/routines/r-file-sett.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.cpp
  1111. --- src/routines/r-file-sett.cpp 1970-01-01 01:00:00.000000000 +0100
  1112. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.cpp 2013-08-21 04:25:15.137351238 +0200
  1113. @@ -0,0 +1,102 @@
  1114. +#include "../main.h"
  1115. +#include "../funzioni.h"
  1116. +#include "r-file-sett.h"
  1117. +
  1118. +bool is_load_save (int argc, char * argv[],
  1119. + int *param_tot_previsti,
  1120. + const std::string filesettaggi_version,
  1121. + std::string *maps,
  1122. + std::string *bitrate_video,
  1123. + std::string *filter,
  1124. + std::string *set_264,
  1125. + std::string *preset,
  1126. + int *pass,
  1127. + std::string *audio_parm,
  1128. + std::string *format_out,
  1129. + std::string *vcodec,
  1130. + std::string *nuova_estensione)
  1131. +{
  1132. + // utility scrivi leggi settaggi su file
  1133. + // save | load nomefile (con o senza .estensione e senza spazi)
  1134. +
  1135. + for (int i=2; i<argc; i++) {
  1136. + if ( (std::string(argv[i]) == "save") || (std::string(argv[i]) == "load") ) {
  1137. + if ( !check_num_param (argc,i,1) )
  1138. + return false;
  1139. + std::string nomefilesettaggi = removeExtension ( std::string(argv[i+1]).c_str() ) + filesettaggi_ext;
  1140. + //
  1141. + FILE * pFile;
  1142. + *param_tot_previsti = *param_tot_previsti +2;
  1143. + // scrivi
  1144. + if ( (std::string(argv[i]) == "save") ) {
  1145. +
  1146. + pFile = fopen (nomefilesettaggi.c_str(),"w");
  1147. + if (pFile == NULL) {
  1148. + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
  1149. + perror ("Errore");
  1150. + return false;
  1151. + }
  1152. + else {
  1153. +
  1154. + scrivi_str_su_file (pFile , filesettaggi_version);
  1155. + scrivi_str_su_file (pFile , *maps);
  1156. + scrivi_str_su_file (pFile , *bitrate_video);
  1157. + scrivi_str_su_file (pFile , *filter);
  1158. + scrivi_str_su_file (pFile , *set_264);
  1159. + scrivi_str_su_file (pFile , *preset);
  1160. + scrivi_int_su_file (pFile , *pass);
  1161. + scrivi_str_su_file (pFile , *audio_parm);
  1162. + scrivi_str_su_file (pFile , *format_out);
  1163. + scrivi_str_su_file (pFile , *vcodec);
  1164. + scrivi_str_su_file (pFile , *nuova_estensione);
  1165. +
  1166. + fclose (pFile);
  1167. + printf ("\nIl file: %s è stato salvato.\n\n", nomefilesettaggi.c_str() );
  1168. + break;
  1169. + }
  1170. +
  1171. +
  1172. + }
  1173. + // leggi
  1174. + if ( (std::string(argv[i]) == "load") ) {
  1175. + pFile = fopen (nomefilesettaggi.c_str(),"r");
  1176. + if (pFile == NULL) {
  1177. + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
  1178. + perror ("Errore");
  1179. + return false;
  1180. + }
  1181. + else {
  1182. + std::string check_file_version ("");
  1183. + check_file_version = leggi_str_da_file (pFile);
  1184. + if (check_file_version != filesettaggi_version){
  1185. + fclose (pFile);
  1186. + printf ("\nIl file: %s non è compatibile con questa versione.\n\n",nomefilesettaggi.c_str() );
  1187. + return false;
  1188. + }
  1189. +
  1190. + *maps = leggi_str_da_file (pFile);
  1191. + *bitrate_video = leggi_str_da_file (pFile);
  1192. + *filter = leggi_str_da_file (pFile);
  1193. + *set_264 = leggi_str_da_file (pFile);
  1194. + *preset = leggi_str_da_file (pFile);
  1195. + *pass = leggi_int_da_file (pFile); // pass è int
  1196. + *audio_parm = leggi_str_da_file (pFile);
  1197. + *format_out = leggi_str_da_file (pFile);
  1198. + *vcodec = leggi_str_da_file (pFile);
  1199. + *nuova_estensione = leggi_str_da_file (pFile);
  1200. +
  1201. + fclose (pFile);
  1202. + printf ("\nIl file: %s è stato caricato.\n\n", nomefilesettaggi.c_str() );
  1203. + break;
  1204. + }
  1205. +
  1206. + }
  1207. +
  1208. + }
  1209. +
  1210. + }
  1211. + return true;
  1212. +}
  1213. +
  1214. +
  1215. +
  1216. diff -Naur -x '*~' src/routines/r-file-sett.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.h
  1217. --- src/routines/r-file-sett.h 1970-01-01 01:00:00.000000000 +0100
  1218. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.h 2013-08-21 04:25:15.050682055 +0200
  1219. @@ -0,0 +1,19 @@
  1220. +#ifndef R_FILE_SETT_H
  1221. +#define R_FILE_SETT_H
  1222. +
  1223. +bool is_load_save (int argc, char * argv[],
  1224. + int *param_tot_previsti,
  1225. + std::string filesettaggi_version,
  1226. + std::string *maps,
  1227. + std::string *bitrate_video,
  1228. + std::string *filter,
  1229. + std::string *set_264,
  1230. + std::string *preset,
  1231. + int *pass,
  1232. + std::string *audio_parm,
  1233. + std::string *format_out,
  1234. + std::string *vcodec,
  1235. + std::string *nuova_estensione);
  1236. +
  1237. +
  1238. +#endif
  1239. diff -Naur -x '*~' src/routines/routines.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.cpp
  1240. --- src/routines/routines.cpp 1970-01-01 01:00:00.000000000 +0100
  1241. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.cpp 2013-08-21 04:25:14.927345141 +0200
  1242. @@ -0,0 +1,119 @@
  1243. +#include "../main.h"
  1244. +#include "../funzioni.h"
  1245. +#include "routines.h"
  1246. +
  1247. +void isdebug (int argc, char * argv[], int *param_tot_previsti, bool *debug)
  1248. +{
  1249. + for (int i=2; i<argc; i++) {
  1250. + if (std::string(argv[i]) == "debug") {
  1251. + *debug = true;
  1252. + *param_tot_previsti = *param_tot_previsti +1;
  1253. + break;
  1254. + }
  1255. + }
  1256. +}
  1257. +
  1258. +bool is_map (int argc, char * argv[], int *param_tot_previsti, std::string *maps)
  1259. +{
  1260. + for (int i=2; i<argc; i++) {
  1261. + if (std::string(argv[i]) == "-map") {
  1262. + if ( !check_num_param (argc,i,1) )
  1263. + return false;
  1264. + if (*maps == ""){
  1265. + *maps = "-map " + std::string(argv[i+1]);
  1266. + *param_tot_previsti = *param_tot_previsti +2;
  1267. + }
  1268. + else{
  1269. + *maps = *maps + " -map " + std::string(argv[i+1]);
  1270. + *param_tot_previsti = *param_tot_previsti +2;
  1271. + }
  1272. + i++;
  1273. + }
  1274. + }
  1275. + return true;
  1276. +}
  1277. +
  1278. +void is_10bit (int argc, char * argv[], int *param_tot_previsti, std::string *eseguibile)
  1279. +{
  1280. + for (int i=2; i<argc; i++) {
  1281. + if (std::string(argv[i]) == "-10bit") {
  1282. + *eseguibile = eseguibile10bit;
  1283. + *param_tot_previsti = *param_tot_previsti +1;
  1284. + break;
  1285. + }
  1286. + }
  1287. +}
  1288. +
  1289. +bool is_filter (int argc, char * argv[], int *param_tot_previsti, std::string *filter, std::string *filtervalore)
  1290. +{
  1291. + for (int i=2; i<argc; i++) {
  1292. + if (std::string(argv[i]) == "-vf") {
  1293. + if ( !check_num_param (argc,i,1) )
  1294. + return false;
  1295. + *filtervalore = std::string (argv[i+1]);
  1296. + *filter = "-vf " + *filtervalore;
  1297. + *param_tot_previsti = *param_tot_previsti +2;
  1298. + break;
  1299. + }
  1300. + }
  1301. + return true;
  1302. +}
  1303. +
  1304. +bool is_ss_is_t (int argc, char * argv[], int *param_tot_previsti, std::string *tempoin, std::string *tempodur)
  1305. +{
  1306. + for (int i=2; i<argc; i++) {
  1307. + if (std::string(argv[i]) == "-ss") {
  1308. + if ( !check_num_param (argc,i,1) )
  1309. + return false;
  1310. + *tempoin = "-ss " + std::string(argv[i+1]);
  1311. + *param_tot_previsti = *param_tot_previsti +2;
  1312. + break;
  1313. + }
  1314. + }
  1315. +
  1316. + for (int i=2; i<argc; i++) {
  1317. + if (std::string(argv[i]) == "-t") {
  1318. + if ( !check_num_param (argc,i,1) )
  1319. + return false;
  1320. + *tempodur = "-t " + std::string(argv[i+1]);
  1321. + *param_tot_previsti = *param_tot_previsti +2;
  1322. + break;
  1323. + }
  1324. + }
  1325. + return true;
  1326. +}
  1327. +
  1328. +void is_altro (int argc, char * argv[], int *param_tot_previsti, std::string *altro)
  1329. +{
  1330. + for (int i=2; i<argc; i++) {
  1331. + if (std::string(argv[i]) == "-nometa") {
  1332. + *altro = "-map_metadata -1";
  1333. + *param_tot_previsti = *param_tot_previsti +1;
  1334. + break;
  1335. + }
  1336. + }
  1337. +
  1338. + for (int i=2; i<argc; i++) {
  1339. + if (std::string(argv[i]) == "-scopy") {
  1340. + if (*altro != "")
  1341. + *altro = *altro + " -c:s copy";
  1342. + else
  1343. + *altro = "-c:s copy";
  1344. + *param_tot_previsti = *param_tot_previsti +1;
  1345. + break;
  1346. + }
  1347. + }
  1348. +}
  1349. +
  1350. +void is_log (int argc, char * argv[], int *param_tot_previsti, std::string *logfile)
  1351. +{
  1352. +// -log logfile ffmpeg
  1353. + for (int i=2; i<argc; i++) {
  1354. + if (std::string(argv[i]) == "-log") {
  1355. + *logfile = "-psnr -report";
  1356. + *param_tot_previsti = *param_tot_previsti +1;
  1357. + break;
  1358. + }
  1359. + }
  1360. +}
  1361. +
  1362. diff -Naur -x '*~' src/routines/routines.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.h
  1363. --- src/routines/routines.h 1970-01-01 01:00:00.000000000 +0100
  1364. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.h 2013-08-21 04:25:15.007347463 +0200
  1365. @@ -0,0 +1,15 @@
  1366. +#ifndef ROUTINES_H
  1367. +#define ROUTINES_H
  1368. +
  1369. +void isdebug (int argc, char * argv[], int *param_tot_previsti, bool *debug);
  1370. +bool is_map (int argc, char * argv[], int *param_tot_previsti, std::string *maps);
  1371. +void is_10bit (int argc, char * argv[], int *param_tot_previsti, std::string *eseguibile);
  1372. +bool is_filter (int argc, char * argv[], int *param_tot_previsti, std::string *filter, std::string *filtervalore);
  1373. +bool is_ss_is_t (int argc, char * argv[], int *param_tot_previsti, std::string *tempoin, std::string *tempodur);
  1374. +void is_altro (int argc, char * argv[], int *param_tot_previsti, std::string *altro);
  1375. +void is_log (int argc, char * argv[], int *param_tot_previsti, std::string *logfile);
  1376. +
  1377. +#endif
  1378. +
  1379. +
  1380. +
  1381. diff -Naur -x '*~' src/routines/r-util.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.cpp
  1382. --- src/routines/r-util.cpp 1970-01-01 01:00:00.000000000 +0100
  1383. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.cpp 2013-08-23 14:41:48.455456816 +0200
  1384. @@ -0,0 +1,304 @@
  1385. +#include "../main.h"
  1386. +#include "../funzioni.h"
  1387. +#include "r-util.h"
  1388. +
  1389. +bool is_util_mkvinfo (int argc, char * argv[], const std::string nomefilein, const std::string nomedelfile, std::string *estensione_file_in)
  1390. +{
  1391. + for (int i=2; i<argc; i++) {
  1392. + if (std::string(argv[i]) == "mkvinfo") {
  1393. + if (*estensione_file_in == ".mkv"){
  1394. + std::string utility (eseguibilemkvinfo + " "
  1395. + + "\"" + nomefilein + "\""
  1396. + );
  1397. + printf ("\n");
  1398. + if ( esegui(utility.c_str()) !=0) return false;
  1399. + printf ("\n\nEsempi estrazione flussi:\n\n");
  1400. + printf ("mkvextract tracks %s 1:video.mkv\n",nomefilein.c_str());
  1401. + printf ("mkvextract tracks %s 2:audio.mp3\n",nomefilein.c_str());
  1402. + printf ("mkvextract tracks %s 6:subs.srt\n\n",nomefilein.c_str());
  1403. + printf ("\nDove n:tipofile.ext sono il numero ed il tipo di stream.\n\n");
  1404. + return false;
  1405. + }
  1406. + else{
  1407. + printf ("\n il file \"%s\" non è un file matroska .mkv\n\n", nomedelfile.c_str() );
  1408. + return false;
  1409. + }
  1410. + }
  1411. + }
  1412. + return true;
  1413. +}
  1414. +
  1415. +bool is_util_mkvmerge (int argc, char * argv[], const std::string nomefilein, const std::string nomedelfile, std::string *estensione_file_in)
  1416. +{
  1417. + for (int i=2; i<argc; i++) {
  1418. + if (std::string(argv[i]) == "mmg") {
  1419. + std::string mmgexe ("mmg");
  1420. + std::string utility = mmgexe + " " + "\"" + nomefilein + "\"";
  1421. + printf ("\n");
  1422. + printf ("\n%s\n\n",utility.c_str() );
  1423. + if ( esegui(utility.c_str()) !=0) return false;
  1424. + return false;
  1425. + }
  1426. + }
  1427. + return true;
  1428. +
  1429. +}
  1430. +
  1431. +bool is_util_play (int argc, char * argv[],
  1432. + const std::string nomefilein,
  1433. + std::string *filter,
  1434. + std::string *tempoin,
  1435. + std::string *maps
  1436. + )
  1437. +{
  1438. + // utility play (preview con -map -ss e -vf)
  1439. + for (int i=2; i<argc; i++) {
  1440. + if (std::string(argv[i]) == "play") {
  1441. + std::string utility;
  1442. + if ( *maps == "" ) {
  1443. + utility = eseguibileplay + " "
  1444. + + "\"" + nomefilein + "\" ";
  1445. + if (*filter != "")
  1446. + utility = utility + *filter + " ";
  1447. + if (*tempoin != "")
  1448. + utility = utility + *tempoin + " ";
  1449. + }
  1450. + else {
  1451. + utility = eseguibile_ffmpeg + " -i "
  1452. + + "\"" + nomefilein + "\" "
  1453. + + *maps + " ";
  1454. + if ( *tempoin != "")
  1455. + utility = utility + *tempoin + " ";
  1456. + utility = utility + vcodec_copy + " "
  1457. + + "-f matroska - | "
  1458. + + eseguibileplay + " "
  1459. + + "- ";
  1460. + if ( *filter != "")
  1461. + utility = utility + *filter + " ";
  1462. + utility = utility + "&";
  1463. + }
  1464. + printf ("\n%s\n\n",utility.c_str());
  1465. + if ( esegui(utility.c_str()) !=0) return false;
  1466. + return false;
  1467. + }
  1468. + }
  1469. + return true;
  1470. +}
  1471. +
  1472. +
  1473. +
  1474. +bool is_util_probe (int argc, char * argv[], const std::string nomefilein)
  1475. +{
  1476. + for (int i=2; i<argc; i++) {
  1477. + if (std::string(argv[i]) == "probe") {
  1478. + std::string utility (eseguibileprobe + " "
  1479. + + "\"" + nomefilein + "\""
  1480. + );
  1481. + printf ("\n");
  1482. + if ( esegui(utility.c_str()) !=0) return false;
  1483. + return false;
  1484. + }
  1485. + }
  1486. + return true;
  1487. +}
  1488. +
  1489. +bool is_util_help_filter (int argc, char * argv[])
  1490. +{
  1491. + for (int i=2; i<argc; i++) {
  1492. + if (std::string(argv[i]) == "-hf") {
  1493. + if ( !check_num_param (argc,i,1) )
  1494. + return false;
  1495. + std::string utility (eseguibile_ffmpeg + " "
  1496. + + "-h filter=" + std::string(argv[i+1])
  1497. + );
  1498. + printf ("\n");
  1499. + if ( esegui(utility.c_str()) !=0) return false;
  1500. + return false;
  1501. + }
  1502. + }
  1503. + return true;
  1504. +}
  1505. +
  1506. +
  1507. +bool is_util_vftest (int argc, char * argv[],
  1508. + const std::string nomefilein,
  1509. + std::string *filtervalore,
  1510. + std::string *tempoin)
  1511. +{
  1512. + // utility vftest 2 video verticali
  1513. + // filtervalore per utility vftest
  1514. + for (int i=2; i<argc; i++) {
  1515. + if (std::string(argv[i]) == "vftest") {
  1516. + if (*filtervalore == "") {
  1517. + printf ("\nè necessario usare -vf filter,filter per usare vftest.\n\n" );
  1518. + return false;
  1519. + }
  1520. + // 2v
  1521. + std::string utility (eseguibileplay + " "
  1522. + + "\"" + nomefilein + "\" "
  1523. + + "-vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]"
  1524. + + *filtervalore
  1525. + + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\" "
  1526. + );
  1527. + if (*tempoin != "")
  1528. + utility = utility + *tempoin + " ";
  1529. + printf ("\n%s\n\n", utility.c_str() );
  1530. + if ( esegui(utility.c_str()) !=0) return false;
  1531. + return false;
  1532. + }
  1533. + }
  1534. + return true;
  1535. +}
  1536. +
  1537. +
  1538. +bool is_util_vftestsp (int argc, char * argv[],
  1539. + const std::string nomefilein,
  1540. + std::string *filtervalore,
  1541. + std::string *tempoin)
  1542. +{
  1543. + // utility vftestsp video split
  1544. + for (int i=2; i<argc; i++) {
  1545. + if (std::string(argv[i]) == "vftestsp") {
  1546. + if (*filtervalore == "") {
  1547. + printf ("\nè necessario usare -vf filter,filter per usare vftestsp.\n\n" );
  1548. + return false;
  1549. + }
  1550. + // 2v
  1551. + std::string utility (eseguibileplay + " "
  1552. + + "\"" + nomefilein + "\" "
  1553. + + "-vf \"split [main][tmp]; [tmp] crop=iw/2:ih:iw/2:0,"
  1554. + + *filtervalore
  1555. + + " [filter]; [main][filter] overlay=W/2:0\" "
  1556. + );
  1557. + if (*tempoin != "")
  1558. + utility = utility + *tempoin + " ";
  1559. + printf ("\n%s\n\n", utility.c_str() );
  1560. + if ( esegui(utility.c_str()) !=0) return false;
  1561. + return false;
  1562. + }
  1563. + }
  1564. + return true;
  1565. +}
  1566. +
  1567. +
  1568. +bool is_util_calc_scale (int argc, char * argv[])
  1569. +{
  1570. + // utility calcola scala proporzionale
  1571. + // calc 720 0 16 9 o calc 0 480 4 3
  1572. + for (int i=2; i<argc; i++) {
  1573. + if (std::string(argv[i]) == "calc") {
  1574. + if ( !check_num_param (argc,i,4) )
  1575. + return false;
  1576. + int w, h, aw, ah;
  1577. + w = atoi(argv[i+1]);
  1578. + h = atoi(argv[i+2]);
  1579. + aw = atoi(argv[i+3]);
  1580. + ah = atoi(argv[i+4]);
  1581. + //check
  1582. + if ( (w == 0 && h == 0) || (aw == 0) || (ah == 0) ){
  1583. + printf ("\nUsare: calc 640 0 16 9 oppure 0 480 4 3.\n\n");
  1584. + return false;
  1585. + }
  1586. + calcola_proporzioni (w, h, aw, ah);
  1587. + calcola_proporzioni_8 (w, h, aw, ah);
  1588. + return false;
  1589. + }
  1590. + }
  1591. + return true;
  1592. +}
  1593. +
  1594. +
  1595. +bool is_muxer (int argc, char * argv[],
  1596. + const std::string nomefilein,
  1597. + std::string *nome_file_senza_ext,
  1598. + std::string *maps,
  1599. + std::string *tempodur,
  1600. + bool *debug)
  1601. +{
  1602. + for (int i=2; i<argc; i++) {
  1603. + if ( std::string(argv[i]) == "muxer" ){
  1604. + if ( !check_num_param (argc,i,1) ){
  1605. + printf ("usare: %s -muxer nomefileaudio [container mkv(default)|avi|mp4]\n", nomefilein.c_str() );
  1606. + printf ("Se -map non sono specificati viene usato:\n");
  1607. + printf ("-map 0:0 -map 1:0\n\n");
  1608. + return false;
  1609. + }
  1610. + std::string nome_file_audio = (argv[i+1]);
  1611. + std::string verifica = nome_file_audio.substr ( (nome_file_audio.length() -1) ,1);
  1612. + if (verifica == "/"){
  1613. + printf ("\nAttenzione: %s è una cartella.\n\n", nome_file_audio.c_str() );
  1614. + return false;
  1615. + }
  1616. + if ( !fileExists ( nome_file_audio.c_str() ) ){
  1617. + printf ("\nIl file: %s non esiste.\n\n", nome_file_audio.c_str() );
  1618. + return false;
  1619. + }
  1620. + std::string formato = format_out_mkv;
  1621. + std::string tipo = nuova_estensione_mkv;
  1622. + if ( (argc-1) >= (i+2) ){
  1623. + std::string container = (argv[i+2]);
  1624. + if ( container == "avi"){
  1625. + formato = format_out_avi;
  1626. + tipo = nuova_estensione_avi;
  1627. + }
  1628. + else if ( container == "mp4"){
  1629. + formato = format_out_mp4;
  1630. + tipo = nuova_estensione_mp4;
  1631. + }
  1632. + }
  1633. + tipo = "_MUXED_" + tipo;
  1634. + std::string daeseguire;
  1635. + std::string nuovo_nome_file_out_muxed = check_fileout_name_e_rename (*nome_file_senza_ext, tipo);
  1636. + daeseguire = eseguibile_ffmpeg + " "
  1637. + + "-i "+ "\"" + nomefilein + "\"" + " "
  1638. + + "-i " + "\"" + nome_file_audio + "\"" + " ";
  1639. + if (*maps == "")
  1640. + daeseguire = daeseguire + "-map 0:0 -map 1:0 " + " ";
  1641. + else
  1642. + daeseguire = daeseguire + *maps + " ";
  1643. + // un po inutile solo per test
  1644. + if (*tempodur != "")
  1645. + daeseguire = daeseguire + *tempodur + " ";
  1646. + // -----------------------------
  1647. + daeseguire = daeseguire + vcodec_copy + " "
  1648. + + formato + " "
  1649. + + + "\"" + nuovo_nome_file_out_muxed + "\"";
  1650. + printf ("\n%s\n\n", daeseguire.c_str() );
  1651. + if (! *debug){
  1652. + if ( esegui(daeseguire.c_str()) !=0) return false;
  1653. + printf ("\n");
  1654. + stampa_info_file (nuovo_nome_file_out_muxed);
  1655. + printf ("\n");
  1656. + }
  1657. + return false;
  1658. + }
  1659. + }
  1660. + return true;
  1661. +}
  1662. +
  1663. +bool is_util_volumedetect (int argc, char * argv[],
  1664. + const std::string nomefilein,
  1665. + std::string *tempoin,
  1666. + std::string *tempodur,
  1667. + std::string *maps)
  1668. +{
  1669. + // ffmpeg -i filein -vn -af volumedetect -f null /dev/null
  1670. + for (int i=2; i<argc; i++) {
  1671. + if (std::string(argv[i]) == "volumedet") {
  1672. + std::string utility = eseguibile_ffmpeg + " -i "
  1673. + + "\"" + nomefilein + "\"" + " ";
  1674. + if ( *tempoin != "")
  1675. + utility = utility + *tempoin + " ";
  1676. + if ( *tempodur != "")
  1677. + utility = utility + *tempodur + " ";
  1678. + if ( *maps != "")
  1679. + utility = utility + *maps + " ";
  1680. + utility = utility + "-vn " + "-af volumedetect "
  1681. + + format_null + " " + out_null;
  1682. + printf ("\n%s\n\n", utility.c_str() );
  1683. + if ( esegui(utility.c_str()) !=0) return false;
  1684. + return false;
  1685. + }
  1686. + }
  1687. + return true;
  1688. +}
  1689. diff -Naur -x '*~' src/routines/r-util.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.h
  1690. --- src/routines/r-util.h 1970-01-01 01:00:00.000000000 +0100
  1691. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.h 2013-08-23 14:30:29.796263380 +0200
  1692. @@ -0,0 +1,35 @@
  1693. +#ifndef R_UTIL_H
  1694. +#define R_UTIL_H
  1695. +
  1696. +bool is_util_mkvinfo (int argc, char * argv[], std::string nomefilein, std::string nomedelfile, std::string *estensione_file_in);
  1697. +bool is_util_mkvmerge (int argc, char * argv[], std::string nomefilein, std::string nomedelfile, std::string *estensione_file_in);
  1698. +bool is_util_play (int argc, char * argv[],
  1699. + std::string nomefilein,
  1700. + std::string *filter,
  1701. + std::string *tempoin,
  1702. + std::string *maps
  1703. + );
  1704. +bool is_util_probe (int argc, char * argv[], std::string nomefilein);
  1705. +bool is_util_help_filter (int argc, char * argv[]);
  1706. +bool is_util_vftest (int argc, char * argv[],
  1707. + std::string nomefilein,
  1708. + std::string *filtervalore,
  1709. + std::string *tempoin);
  1710. +bool is_util_vftestsp (int argc, char * argv[],
  1711. + std::string nomefilein,
  1712. + std::string *filtervalore,
  1713. + std::string *tempoin);
  1714. +bool is_util_calc_scale (int argc, char * argv[]);
  1715. +bool is_muxer (int argc, char * argv[],
  1716. + std::string nomefilein,
  1717. + std::string *nome_file_senza_ext,
  1718. + std::string *maps,
  1719. + std::string *tempodur,
  1720. + bool *debug);
  1721. +bool is_util_volumedetect (int argc, char * argv[],
  1722. + std::string nomefilein,
  1723. + std::string *tempoin,
  1724. + std::string *tempodur,
  1725. + std::string *maps);
  1726. +
  1727. +#endif
  1728. diff -Naur -x '*~' src/routines/r-util-sox.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.cpp
  1729. --- src/routines/r-util-sox.cpp 1970-01-01 01:00:00.000000000 +0100
  1730. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.cpp 2013-08-22 20:00:11.448639365 +0200
  1731. @@ -0,0 +1,132 @@
  1732. +#include "../main.h"
  1733. +#include "../funzioni.h"
  1734. +#include "r-util-sox.h"
  1735. +
  1736. +bool is_util_sox (int argc, char * argv[],
  1737. + const std::string nomefilein,
  1738. + std::string *nome_file_senza_ext,
  1739. + std::string *audio_parm,
  1740. + std::string *vcodec,
  1741. + std::string *rate,
  1742. + std::string *maps,
  1743. + std::string *tempoin,
  1744. + std::string *tempodur,
  1745. + bool *debug)
  1746. +{
  1747. + for (int i=2; i<argc; i++) {
  1748. + if (std::string(argv[i]) == "sox") {
  1749. + time_t now;
  1750. + double seconds, durata;
  1751. + std::string sox_norm ("norm -3");
  1752. + std::string sox_compand_std_2 ("compand 0.3,1 6:-70,-40,-20 -11 -90 0.2 gain -n -3"); //2:1
  1753. + std::string 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");
  1754. + /*
  1755. + old sox_compand_std_2 ("compand 0.3,1 6:-70,-40,-20 -5 -90 0.2"); //2:1
  1756. + std::string sox_compand_std ("compand 0.3,1 6:-70,-60,-20 -5 -90 0.2"); //3 :1
  1757. + 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");
  1758. + std::string sox_compand_film ("compand 0.1,0.4 6:-70,-43,-20,-12,-10 -6 -80 0.1");
  1759. + 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");
  1760. + */
  1761. + std::string sox_effect;
  1762. + std::string sox_show ("-S ");
  1763. + std::string nuovo_nome_file_out_mka = check_fileout_name_e_rename (*nome_file_senza_ext, "_SOX_.mka");
  1764. + std::string nuovo_nome_file_out_mux = check_fileout_name_e_rename (*nome_file_senza_ext, "_MUX_.mkv");
  1765. + std::string daeseguire ("");
  1766. + int prossimo = 2;
  1767. + if ( !check_num_param (argc,i,1) ){
  1768. + printf ("Usare: sox norm | comp | compf [noshow mux]\n");
  1769. + printf ("noshow: non mostra sox progress\n");
  1770. + printf ("mux: muxa il file %s\n\n", nuovo_nome_file_out_mux.c_str() );
  1771. + return false;
  1772. + }
  1773. + if (
  1774. + *audio_parm == audio_parm_none
  1775. + || *audio_parm == audio_parm_copy
  1776. + || *vcodec == vcodec_copy
  1777. + ) {
  1778. + printf ("\n\nsox è incompatibile con -an -acopy e -copy\n\n");
  1779. + return false;
  1780. + }
  1781. + if ( std::string(argv[i+1]) == "norm" )
  1782. + sox_effect = sox_norm;
  1783. + else if ( std::string(argv[i+1]) == "comp" )
  1784. + sox_effect = sox_compand_std_2;
  1785. + else if ( std::string(argv[i+1]) == "compf" )
  1786. + sox_effect = sox_compand_film_std;
  1787. + else {
  1788. + printf ("\n\n");
  1789. + printf ("Usare: sox norm | comp | compf [noshow mux]\n");
  1790. + printf ("noshow: non mostra sox progress\n");
  1791. + printf ("mux: muxa il file %s\n\n", nuovo_nome_file_out_mux.c_str() );
  1792. + return false;
  1793. + }
  1794. +
  1795. + if ( (argc-1) >= (i+2) ){
  1796. + if ( std::string(argv[i+2]) == "noshow" ){
  1797. + sox_show = "";
  1798. + prossimo = prossimo +1;
  1799. + }
  1800. + }
  1801. + daeseguire = eseguibile_ffmpeg + " " + "-i "
  1802. + + "\"" + nomefilein + "\"" + " ";
  1803. + if (*rate != "")
  1804. + daeseguire = daeseguire + *rate + " ";
  1805. + if (*maps != "")
  1806. + daeseguire = daeseguire + *maps + " ";
  1807. + if (*tempoin != "")
  1808. + daeseguire = daeseguire + *tempoin + " ";
  1809. + if (*tempodur != "")
  1810. + daeseguire = daeseguire + *tempodur + " ";
  1811. + daeseguire = daeseguire + "-vn -f sox - | sox "
  1812. + + sox_show + "-t sox - -t sox -" + " "
  1813. + + sox_effect + " | "
  1814. + + eseguibile_ffmpeg + " -y "
  1815. + + "-i - -f matroska" + " "
  1816. + + *audio_parm + " " +
  1817. + + "\"" + nuovo_nome_file_out_mka + "\"";
  1818. + printf ("\n\n%s\n\n", daeseguire.c_str() );
  1819. + if (! *debug){
  1820. + seconds = time(&now);
  1821. + if ( esegui(daeseguire.c_str()) !=0) return false;
  1822. + durata = difftime(time(&now),seconds);
  1823. + printf ("\n\nTempo conversione: ");
  1824. + stampatempo (durata);
  1825. + printf ("\n");
  1826. + stampa_info_file (nuovo_nome_file_out_mka);
  1827. + printf ("\n");
  1828. + }
  1829. + if ( (argc-1) >= (i+prossimo) ){
  1830. + if ( std::string(argv[i+prossimo]) == "mux" ){
  1831. + // even aggiungere i param video e tempo
  1832. + prossimo = prossimo +1;
  1833. + daeseguire = eseguibile_ffmpeg + " "
  1834. + + "-i "
  1835. + + "\"" + nomefilein + "\"" + " "
  1836. + + "-i "
  1837. + + "\"" + nuovo_nome_file_out_mka + "\"" + " "
  1838. + + "-map 0:0 -map 1:0 " + " "
  1839. + + vcodec_copy + " "
  1840. + + "-f matroska" + " "
  1841. + + + "\"" + nuovo_nome_file_out_mux + "\"";
  1842. + printf ("%s\n\n", daeseguire.c_str() );
  1843. + if (! *debug){
  1844. + if ( esegui(daeseguire.c_str()) !=0) return false;
  1845. + printf ("\n\nTempo conversione: ");
  1846. + stampatempo (durata);
  1847. + printf ("\n");
  1848. + stampa_info_file (nuovo_nome_file_out_mux);
  1849. + printf ("\n");
  1850. + }
  1851. + }
  1852. + else
  1853. + printf ("Processare ora il video con -an e/o muxare.\n\n");
  1854. + }
  1855. + else
  1856. + printf ("Processare ora il video con -an e/o muxare.\n\n");
  1857. +
  1858. + return false;
  1859. + }
  1860. + }
  1861. + return true;
  1862. +}
  1863. +
  1864. diff -Naur -x '*~' src/routines/r-util-sox.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.h
  1865. --- src/routines/r-util-sox.h 1970-01-01 01:00:00.000000000 +0100
  1866. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.h 2013-08-21 04:25:15.184019259 +0200
  1867. @@ -0,0 +1,15 @@
  1868. +#ifndef R_UTIL_SOX_H
  1869. +#define R_UTIL_SOX_H
  1870. +
  1871. +bool is_util_sox (int argc, char * argv[],
  1872. + std::string nomefilein,
  1873. + std::string *nome_file_senza_ext,
  1874. + std::string *audio_parm,
  1875. + std::string *vcodec,
  1876. + std::string *rate,
  1877. + std::string *maps,
  1878. + std::string *tempoin,
  1879. + std::string *tempodur,
  1880. + bool *debug);
  1881. +
  1882. +#endif
  1883. diff -Naur -x '*~' src/routines/r-video-asp-avi.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.cpp
  1884. --- src/routines/r-video-asp-avi.cpp 1970-01-01 01:00:00.000000000 +0100
  1885. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.cpp 2013-08-21 20:07:24.587579371 +0200
  1886. @@ -0,0 +1,83 @@
  1887. +#include "../main.h"
  1888. +#include "../funzioni.h"
  1889. +#include "r-video-asp-avi.h"
  1890. +
  1891. +bool is_mpeg4_avi_xvid
  1892. + (int argc, char * argv[],
  1893. + int *param_tot_previsti,
  1894. + std::string *vcodec,
  1895. + std::string *preset,
  1896. + std::string *profile,
  1897. + std::string *set_264,
  1898. + int *b_v_rate,
  1899. + std::string *bitrate_video,
  1900. + int *pass,
  1901. + std::string *nuova_estensione,
  1902. + std::string *audio_parm,
  1903. + std::string *format_out,
  1904. + std::string *audio_codec_is,
  1905. + std::string *video_codec_is
  1906. + )
  1907. +{
  1908. + bool is_mpeg4 = false;
  1909. + bool is_avi = false;
  1910. + bool is_xvid = false;
  1911. + for (int i=2; i<argc; i++) {
  1912. + if (std::string(argv[i]) == "-mpeg4") {
  1913. + is_mpeg4 = true;
  1914. + *param_tot_previsti = *param_tot_previsti +1;
  1915. + }
  1916. + if (std::string(argv[i]) == "-avi") {
  1917. + is_avi = true;
  1918. + *param_tot_previsti = *param_tot_previsti +1;
  1919. + }
  1920. + if (std::string(argv[i]) == "-xvid") {
  1921. + is_xvid = true;
  1922. + *param_tot_previsti = *param_tot_previsti +1;
  1923. + }
  1924. + }
  1925. + if (
  1926. + is_mpeg4
  1927. + || is_avi
  1928. + || is_xvid
  1929. + ){
  1930. + *vcodec = vcodec_mpeg4;
  1931. + *video_codec_is = VIDEO_IS_MPEG4;
  1932. + *preset="";
  1933. + *profile="";
  1934. + *set_264="";
  1935. + if (*b_v_rate == 0)
  1936. + *bitrate_video = bitrate_video_mpeg4_default;
  1937. + if (*pass == 3)
  1938. + *pass = 2;
  1939. + }
  1940. + if ( is_xvid ){
  1941. + if ( *nuova_estensione == nuova_estensione_mp4 ){
  1942. + printf ("\nAttenzione,\n-xvid non è compatibile con il formato -mp4\n");
  1943. + printf ("Usare -mpeg4 con il formato -mp4\n\n");
  1944. + return false;
  1945. + }
  1946. + *vcodec = vcodec_mpeg4 + " " + xvid_tag;
  1947. + *video_codec_is = VIDEO_IS_MPEG4_XVID;
  1948. + }
  1949. + if (is_avi){
  1950. + // check -mp4
  1951. + if ( *nuova_estensione == nuova_estensione_mp4 ){
  1952. + printf ("\nAttenzione,\nè stato selezionato anche il formato -mp4 insieme ad -avi -xvid\n");
  1953. + printf ("Verificare i parametri inseriti.\n\n");
  1954. + return false;
  1955. + }
  1956. + // audio avi - no aac no aac+ solo mp3
  1957. + if ( (*audio_codec_is != AUDIO_IS_LAME)
  1958. + && (*audio_codec_is != "")
  1959. + ){
  1960. + *audio_parm = audio_parm_lame;
  1961. + *audio_codec_is = AUDIO_IS_LAME;
  1962. + }
  1963. + *format_out = format_out_avi;
  1964. + *nuova_estensione = nuova_estensione_avi;
  1965. + }
  1966. +
  1967. + return true;
  1968. +}
  1969. +
  1970. diff -Naur -x '*~' src/routines/r-video-asp-avi.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.h
  1971. --- src/routines/r-video-asp-avi.h 1970-01-01 01:00:00.000000000 +0100
  1972. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.h 2013-08-21 17:23:35.340588386 +0200
  1973. @@ -0,0 +1,22 @@
  1974. +#ifndef R_VIDEO_ASP_AVI_H
  1975. +#define R_VIDEO_ASP_AVI_H
  1976. +
  1977. +bool is_mpeg4_avi_xvid
  1978. + (int argc, char * argv[],
  1979. + int *param_tot_previsti,
  1980. + std::string *vcodec,
  1981. + std::string *preset,
  1982. + std::string *profile,
  1983. + std::string *set_264,
  1984. + int *b_v_rate,
  1985. + std::string *bitrate_video,
  1986. + int *pass,
  1987. + std::string *nuova_estensione,
  1988. + std::string *audio_parm,
  1989. + std::string *format_out,
  1990. + std::string *audio_codec_is,
  1991. + std::string *video_codec_is
  1992. + );
  1993. +
  1994. +
  1995. +#endif
  1996. diff -Naur -x '*~' src/routines/r-video-generali.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.cpp
  1997. --- src/routines/r-video-generali.cpp 1970-01-01 01:00:00.000000000 +0100
  1998. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.cpp 2013-08-22 16:12:07.980554268 +0200
  1999. @@ -0,0 +1,138 @@
  2000. +#include "../main.h"
  2001. +#include "../funzioni.h"
  2002. +#include "r-video-generali.h"
  2003. +
  2004. +bool passate (int argc, char * argv[], int *param_tot_previsti, int *pass)
  2005. +{
  2006. + for (int i=2; i<argc; i++) {
  2007. + if (std::string(argv[i]) == "-pass") {
  2008. + if ( !check_num_param (argc,i,1) )
  2009. + return false;
  2010. + *pass = atoi(argv[i+1]);
  2011. + // check
  2012. + if (*pass < 1 || *pass >3){
  2013. + printf ("\nInserire -pass 2 o 3.\n");
  2014. + return false;
  2015. + }
  2016. + *param_tot_previsti = *param_tot_previsti +2;
  2017. + break;
  2018. + }
  2019. + }
  2020. + return true;
  2021. +}
  2022. +
  2023. +bool frame_rate (int argc, char * argv[], int *param_tot_previsti, std::string *rate)
  2024. +{
  2025. + for (int i=2; i<argc; i++) {
  2026. + if (std::string(argv[i]) == "-r") {
  2027. + if ( !check_num_param (argc,i,1) )
  2028. + return false;
  2029. + *rate = "-r " + std::string(argv[i+1]);
  2030. + *param_tot_previsti = *param_tot_previsti +2;
  2031. + break;
  2032. + }
  2033. + }
  2034. + return true;
  2035. +}
  2036. +
  2037. +bool video_bit_rate (int argc, char * argv[], int *param_tot_previsti, int *b_v_rate, std::string *bitrate_video)
  2038. +{
  2039. + // bitrate in k, es: -b 500 altimenti 730k
  2040. + for (int i=2; i<argc; i++) {
  2041. + if (std::string(argv[i]) == "-b") {
  2042. + if ( !check_num_param (argc,i,1) )
  2043. + return false;
  2044. + // check argomento 300 to 4000
  2045. + *b_v_rate = atoi(argv[i+1]);
  2046. + if ( *b_v_rate < 300 || *b_v_rate > 4000) {
  2047. + printf ("\nInserire un bitrate video corretto.\n");
  2048. + return false;
  2049. + }
  2050. + // fine check
  2051. + *bitrate_video = "-b:v " + std::string(argv[i+1]) + "k";
  2052. + *param_tot_previsti = *param_tot_previsti +2;
  2053. + break;
  2054. + }
  2055. + }
  2056. + return true;
  2057. +}
  2058. +
  2059. +void is_mp4_out (int argc, char * argv[], int *param_tot_previsti, std::string *format_out, std::string *nuova_estensione)
  2060. +{
  2061. + for (int i=2; i<argc; i++) {
  2062. + if (std::string(argv[i]) == "-mp4") {
  2063. + *format_out = format_out_mp4;
  2064. + *nuova_estensione = nuova_estensione_mp4;
  2065. + *param_tot_previsti = *param_tot_previsti +1;
  2066. + break;
  2067. + }
  2068. + }
  2069. +}
  2070. +
  2071. +bool is_aspect (int argc, char * argv[], int *param_tot_previsti, std::string *aspetto)
  2072. +{
  2073. + for (int i=2; i<argc; i++) {
  2074. + if (std::string(argv[i]) == "-aspect") {
  2075. + if ( !check_num_param (argc,i,1) )
  2076. + return false;
  2077. + *aspetto = "-aspect " + std::string(argv[i+1]);
  2078. + *param_tot_previsti = *param_tot_previsti +2;
  2079. + break;
  2080. + }
  2081. + }
  2082. + return true;
  2083. +}
  2084. +
  2085. +
  2086. +void is_vcopy_copy (int argc, char * argv[],
  2087. + int *param_tot_previsti,
  2088. + std::string *vcodec,
  2089. + std::string *rate,
  2090. + std::string *preset,
  2091. + std::string *profile,
  2092. + std::string *set_264,
  2093. + std::string *bitrate_video,
  2094. + std::string *filter,
  2095. + int *pass,
  2096. + std::string *audio_parm,
  2097. + std::string *a_filter,
  2098. + std::string *video_codec_is,
  2099. + std::string *audio_codec_is)
  2100. +{
  2101. + for (int i=2; i<argc; i++) {
  2102. + if (std::string(argv[i]) == "-vcopy") {
  2103. + *vcodec = vcodec_vcopy;
  2104. + *video_codec_is = "";
  2105. + // azzeramento altri paramentri video
  2106. + *rate="";
  2107. + *preset="";
  2108. + *profile="";
  2109. + *set_264="";
  2110. + *bitrate_video="";
  2111. + *filter="";
  2112. + *pass=1;
  2113. + *param_tot_previsti = *param_tot_previsti +1;
  2114. + break;
  2115. + }
  2116. + }
  2117. +
  2118. + for (int i=2; i<argc; i++) {
  2119. + if (std::string(argv[i]) == "-copy") {
  2120. + *vcodec = vcodec_copy;
  2121. + *video_codec_is = "";
  2122. + // azzeramento altri paramentri video e audio
  2123. + *rate="";
  2124. + *preset="";
  2125. + *profile="";
  2126. + *set_264="";
  2127. + *bitrate_video="";
  2128. + *filter="";
  2129. + *a_filter="";
  2130. + *pass=1;
  2131. + *audio_parm="";
  2132. + *audio_codec_is = "";
  2133. + *param_tot_previsti = *param_tot_previsti +1;
  2134. + break;
  2135. + }
  2136. + }
  2137. +}
  2138. diff -Naur -x '*~' src/routines/r-video-generali.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.h
  2139. --- src/routines/r-video-generali.h 1970-01-01 01:00:00.000000000 +0100
  2140. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.h 2013-08-22 16:09:22.785748353 +0200
  2141. @@ -0,0 +1,24 @@
  2142. +#ifndef R_VIDEO_GENERALI_H
  2143. +#define R_VIDEO_GENERALI_H
  2144. +
  2145. +bool passate (int argc, char * argv[], int *param_tot_previsti, int *pass);
  2146. +bool frame_rate (int argc, char * argv[], int *param_tot_previsti, std::string *rate);
  2147. +bool video_bit_rate (int argc, char * argv[], int *param_tot_previsti, int *b_v_rate, std::string *bitrate_video);
  2148. +void is_mp4_out (int argc, char * argv[], int *param_tot_previsti, std::string *format_out, std::string *nuova_estensione);
  2149. +bool is_aspect (int argc, char * argv[], int *param_tot_previsti, std::string *aspetto);
  2150. +void is_vcopy_copy (int argc, char * argv[],
  2151. + int *param_tot_previsti,
  2152. + std::string *vcodec,
  2153. + std::string *rate,
  2154. + std::string *preset,
  2155. + std::string *profile,
  2156. + std::string *set_264,
  2157. + std::string *bitrate_video,
  2158. + std::string *filter,
  2159. + int *pass,
  2160. + std::string *audio_parm,
  2161. + std::string *a_filter,
  2162. + std::string *video_codec_is,
  2163. + std::string *audio_codec_is);
  2164. +
  2165. +#endif
  2166. diff -Naur -x '*~' src/routines/r-video-x264.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.cpp
  2167. --- src/routines/r-video-x264.cpp 1970-01-01 01:00:00.000000000 +0100
  2168. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.cpp 2013-08-21 12:09:58.040152055 +0200
  2169. @@ -0,0 +1,123 @@
  2170. +#include "../main.h"
  2171. +#include "../funzioni.h"
  2172. +#include "r-video-x264.h"
  2173. +
  2174. +void no_fast (int argc, char * argv[], int *param_tot_previsti, bool *nofastfirst)
  2175. +{
  2176. + for (int i=2; i<argc; i++) {
  2177. + if (std::string(argv[i]) == "-nofast") {
  2178. + *nofastfirst = true;
  2179. + *param_tot_previsti = *param_tot_previsti +1;
  2180. + break;
  2181. + }
  2182. + }
  2183. +}
  2184. +
  2185. +void is_preset (int argc, char * argv[], int *param_tot_previsti, std::string *preset)
  2186. +{
  2187. + for (int i=2; i<argc; i++) {
  2188. +
  2189. + if (std::string(argv[i]) == "-fast") {
  2190. + *preset = preset_fast;
  2191. + *param_tot_previsti = *param_tot_previsti +1;
  2192. + break;
  2193. + }
  2194. + if (std::string(argv[i]) == "-medium") {
  2195. + *preset = preset_medium;
  2196. + *param_tot_previsti = *param_tot_previsti +1;
  2197. + break;
  2198. + }
  2199. + if (std::string(argv[i]) == "-slow") {
  2200. + *preset = preset_slow;
  2201. + *param_tot_previsti = *param_tot_previsti +1;
  2202. + break;
  2203. + }
  2204. +
  2205. + }
  2206. +}
  2207. +
  2208. +void is_profile (int argc, char * argv[], int *param_tot_previsti, std::string *profile)
  2209. +{
  2210. + for (int i=2; i<argc; i++) {
  2211. + if (std::string(argv[i]) == "-main") {
  2212. + *profile = profile_main;
  2213. + *param_tot_previsti = *param_tot_previsti +1;
  2214. + break;
  2215. + }
  2216. + if (std::string(argv[i]) == "-high") {
  2217. + *profile = profile_high;
  2218. + *param_tot_previsti = *param_tot_previsti +1;
  2219. + break;
  2220. + }
  2221. +
  2222. + }
  2223. +}
  2224. +
  2225. +void is_nopts (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
  2226. +{
  2227. + for (int i=2; i<argc; i++) {
  2228. + if (std::string(argv[i]) == "-nopts") {
  2229. + *set_264 = set_264_nopts;
  2230. + *param_tot_previsti = *param_tot_previsti +1;
  2231. + break;
  2232. + }
  2233. + }
  2234. +}
  2235. +
  2236. +void is_opencl (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
  2237. +{
  2238. + for (int i=2; i<argc; i++) {
  2239. + if (std::string(argv[i]) == "-opencl") {
  2240. + *set_264 = *set_264 + ":opencl";
  2241. + *param_tot_previsti = *param_tot_previsti +1;
  2242. + break;
  2243. + }
  2244. + }
  2245. +}
  2246. +
  2247. +void is_nr_denoise (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
  2248. +{
  2249. + for (int i=2; i<argc; i++) {
  2250. + if (std::string(argv[i]) == "-nr200") {
  2251. + *set_264 = *set_264 + ":nr=200";
  2252. + *param_tot_previsti = *param_tot_previsti +1;
  2253. + break;
  2254. + }
  2255. + if (std::string(argv[i]) == "-nr500") {
  2256. + *set_264 = *set_264 + ":nr=500";
  2257. + *param_tot_previsti = *param_tot_previsti +1;
  2258. + break;
  2259. + }
  2260. + }
  2261. +}
  2262. +
  2263. +void is_level (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
  2264. +{
  2265. + for (int i=2; i<argc; i++) {
  2266. + if (std::string(argv[i]) == "-level1") {
  2267. + *set_264 = *set_264 + ":" + livello1;
  2268. + *param_tot_previsti = *param_tot_previsti +1;
  2269. + break;
  2270. + }
  2271. + if (std::string(argv[i]) == "-level2") {
  2272. + *set_264 = *set_264 + ":" + livello2;
  2273. + *param_tot_previsti = * param_tot_previsti +1;
  2274. + break;
  2275. + }
  2276. + if (std::string(argv[i]) == "-level3") {
  2277. + *set_264 = *set_264 + ":" + livello3;
  2278. + *param_tot_previsti = *param_tot_previsti +1;
  2279. + break;
  2280. + }
  2281. + if (std::string(argv[i]) == "-level4") {
  2282. + *set_264 = *set_264 + ":" + livello4;
  2283. + *param_tot_previsti = *param_tot_previsti +1;
  2284. + break;
  2285. + }
  2286. + if (std::string(argv[i]) == "-level5") {
  2287. + *set_264 = *set_264 + ":" + livello5;
  2288. + *param_tot_previsti = *param_tot_previsti +1;
  2289. + break;
  2290. + }
  2291. + }
  2292. +}
  2293. diff -Naur -x '*~' src/routines/r-video-x264.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.h
  2294. --- src/routines/r-video-x264.h 1970-01-01 01:00:00.000000000 +0100
  2295. +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.h 2013-08-21 03:11:30.675569527 +0200
  2296. @@ -0,0 +1,12 @@
  2297. +#ifndef R_VIDEO_X264_H
  2298. +#define R_VIDEO_X264_H
  2299. +
  2300. +void no_fast (int argc, char * argv[], int *param_tot_previsti, bool *nofastfirst);
  2301. +void is_preset (int argc, char * argv[], int *param_tot_previsti, std::string *preset);
  2302. +void is_profile (int argc, char * argv[], int *param_tot_previsti, std::string *profile);
  2303. +void is_nopts (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
  2304. +void is_opencl (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
  2305. +void is_nr_denoise (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
  2306. +void is_level (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
  2307. +
  2308. +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement