Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- --- src/730-ffmpeg-tool-main.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/730-ffmpeg-tool-main.cpp 2013-11-10 16:04:15.524769531 +0100
- @@ -0,0 +1,344 @@
- +#include "main.h"
- +#include "funzioni.h"
- +#include "routines/routines.h"
- +#include "routines/r-video-generali.h"
- +#include "routines/r-video-x264.h"
- +#include "routines/r-video-asp-avi.h"
- +#include "routines/r-audio.h"
- +#include "routines/r-util.h"
- +#include "routines/r-util-sox.h"
- +#include "routines/r-file-sett.h"
- +#include "routines/r-build-fin.h"
- +
- +
- +
- +
- +const std::string versione ("v-3.46");
- +const std::string filesettaggi_version ("v1.1");
- +
- +int main(int argc, char * argv[])
- +{
- + setlocale (LC_ALL,"");
- +
- + s_dati dati;
- +
- + dati.eseguibile = ESEGUIBILE_FFMPEG;
- + dati.estensione_file_in = "";
- + dati.nuova_estensione = NUOVA_EXT_MKV;
- + dati.debug = false;
- + dati.rate = "";
- + dati.maps = "";
- + dati.vcodec = VCODEC_X264;
- + dati.video_codec_is = VIDEO_IS_X_264;
- + dati.bitrate_video = BITRATE_VIDEO_X264_DEFAULT;
- + dati.b_v_rate = 0;
- + dati.preset = PRESET_FASTER;
- + dati.profile = "";
- + dati.set_264 = OPT_264_1;
- + dati.audio_parm = AUDIO_PARM_AF112;
- + dati.audio_codec_is = AUDIO_IS_FDKAAC;
- + dati.pass = 1;
- + dati.nofastfirst = false;
- + dati.filter = "";
- + dati.filtervalore = ""; // per utility vftest
- + dati.a_filter_valore = "";
- + dati.tempoin = "";
- + dati.tempodur = "";
- + dati.logfile = "";
- + dati.altro = "";
- + dati.aspetto = "";
- + dati.format_out = FORMAT_OUT_MATROSKA;
- + dati.nuovo_nome_file_out = "";
- + // stringa finale daeseguire
- + dati.daeseguire = "";
- + dati.filsett_vers = filesettaggi_version;
- +
- +
- + // check che venga passato almeno il nome del file
- + if (argc < 2)
- + {
- + printf ("\n");
- + printf ("Usare: %s nomefile\n", argv[0]);
- + printf ("Help: %s -h\n", argv[0]);
- + printf ("versione: %s\n", versione.c_str() );
- + printf ("\n");
- + return 1;
- + }
- +
- + // -h help
- + if (std::string(argv[1]) == "-h")
- + {
- + stampa_help(argv[0]);
- + return 0;
- + }
- +
- +
- + // nome del file con path
- + dati.nomefilein = (argv[1]);
- + std::string verifica = tipo_ext (dati.nomefilein);
- + if (verifica == "")
- + {
- + printf ("\nAttenzione: %s non ha alcuna estensione.\n\n", dati.nomefilein.c_str() );
- + return 1;
- + }
- + // nome del file senza path
- + dati.nomedelfile = ( rimuovi_path(dati.nomefilein) );
- + // estensione del file
- + dati.estensione_file_in = tipo_ext (dati.nomedelfile);
- + // nome del file senza ext
- + dati.nome_file_senza_ext = ( removeExtension (dati.nomedelfile.c_str()) );
- +
- + // check se il file input esiste
- + if ( !fileExists (dati.nomefilein.c_str()) )
- + {
- + printf ("\nIl file: %s non esiste.\n\n", dati.nomefilein.c_str() );
- + return 1;
- + }
- +
- + // check minimale sul numero parametri immessi
- + dati.param_tot_previsti = 2;
- +
- +
- + // debug stampa solo i comandi senza eseguirli
- + isdebug (argc, argv, &dati);
- +
- +
- + // frame rate, -r 25
- + if ( !frame_rate (argc, argv, &dati) )
- + return 1;
- +
- +
- + // -map (multipli) es -map 0:0 -map 0:1
- + if ( !is_map (argc, argv, &dati) )
- + return 1;
- +
- +
- + // bitrate in k, es: -b 500 default: 730k AVC 1500k ASP
- + if ( !video_bit_rate (argc, argv, &dati) )
- + return 1;
- +
- +
- + // parametri video: default preset="-preset faster -tune film"
- + // -fast -medium -slow
- + is_preset (argc, argv, &dati);
- +
- +
- + // profile: -main -high, default auto
- + is_profile (argc, argv, &dati);
- +
- +
- + // opts264
- + // -nopts = parametri del preset senza tuning personale
- + is_nopts (argc, argv, &dati);
- +
- +
- + // opencl lookahead
- + // -opencl
- + is_opencl (argc, argv, &dati);
- +
- +
- + // -nr x264 fastdenoise da 100 a 1000 -nr200 -nr500
- + // non usare se usate -vf |denoiser|
- + is_nr_denoise (argc, argv, &dati);
- +
- +
- + // -level1 to 5, default auto
- + is_level (argc, argv, &dati);
- +
- +
- + // -10bit = x264 10 bit depth
- + is_10bit (argc, argv, &dati);
- +
- + // -af audio filter (solo i parametri -af " " va aggiunto alla fine)
- + if ( !is_afilter (argc, argv, &dati) )
- + return 1;
- +
- + // -avolume -20 20 (db)
- + if ( !is_avolume (argc, argv, &dati) )
- + return 1;
- +
- + // -acomp ffmpeg audio compader filter
- + if ( !is_acomp (argc, argv, &dati) )
- + return 1;
- +
- + // audio
- + // -a32 -a64 -a96 -a128 -acopy -an
- + // -aaq 80-160
- + // -alameq 0-9
- + // -alame 32-320 (K)
- + if ( !is_audio (argc, argv, &dati) )
- + return 1;
- +
- + // -aboost // solo per fdk_aac - dopo avi altrimenti i confronti audio_parm non funzionano
- + is_aboost (argc, argv, &dati);
- +
- + // -pass passate 1,2 o 3 (3 solo x264)
- + if ( !passate (argc, argv , &dati) )
- + return 1;
- +
- +
- + // -nofast -fastfirstpass 0 (solo x264)
- + no_fast (argc, argv, &dati);
- +
- +
- + // filtri -vf deshake,pp=ac/al
- + if ( !is_filter (argc, argv, &dati) )
- + return 1;
- +
- +
- + // tempo start e durata, esempio -ss 00:03:00 -t 00:05:00 oppure -ss 120 -t 60
- + // -ss -t
- + if ( !is_ss_is_t (argc, argv, &dati) )
- + return 1;
- +
- +
- + // -log logfile ffmpeg
- + is_log (argc, argv, &dati);
- +
- +
- + // -mp4 .mp4
- + is_mp4_out (argc, argv, &dati);
- +
- +
- + // -mpeg4
- + // -avi
- + // -xvid
- + if ( !is_mpeg4_avi_xvid (argc, argv, &dati) )
- + return 1;
- +
- + // -crf 19.0 (0-50) solo se VIDEO_IS_X_264
- + if ( !is_crf (argc, argv, &dati) )
- + return 1;
- +
- + //// altri parametri
- + // -nometa -map_metadata -1
- + // -scopy -c:s copy subtitles
- + is_altro (argc, argv, &dati);
- +
- +
- + // -vcopy = -c:v copy
- + // -copy = -c copy
- + // -vn = -vn
- + is_vcopy_copy (argc, argv, &dati);
- +
- +
- + // -aspect 4:3 16/9 (da usare solo con video copy,
- + // se codificate -vf setdar=16/9)
- + if ( !is_aspect (argc, argv, &dati) )
- + return 1;
- +
- +
- + // -h help in posizione > 1
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-h")
- + {
- + stampa_help(argv[0]);
- + return 0;
- + }
- + }
- +
- +
- + // utility mkvinfo
- + if ( !is_util_mkvinfo (argc, argv, &dati) )
- + return 0;
- +
- + // utility mgm (mkvmerge gui)
- + if ( !is_util_mkvmerge (argc, argv, &dati) )
- + return 0;
- +
- + // utility probe
- + if ( !is_util_probe (argc, argv, &dati) )
- + return 0;
- +
- +
- + // utility play (preview con -map -ss e -vf)
- + if ( !is_util_play (argc, argv, &dati))
- + return 0;
- +
- + // utility -hf filter, -h filter=unsharp
- + if ( !is_util_help_filter (argc, argv) )
- + return 0;
- +
- + // utility vftest 2 video verticali
- + // filtervalore per utility vftest
- + if ( !is_util_vftest (argc, argv, &dati) )
- + return 0;
- +
- + // utility vftestsp video split
- + if ( !is_util_vftestsp (argc, argv, &dati) )
- + return 0;
- +
- + // utility calcola scala proporzionale
- + // calc 720 0 16 9 oppure calc 0 480 4 3
- + if ( !is_util_calc_scale (argc, argv) )
- + return 0;
- +
- + // utility showwaves
- + if ( !is_util_showwaves (argc, argv, &dati) )
- + return 0;
- +
- + // utility showspectrum
- + if ( !is_util_showspectrum (argc, argv, &dati) )
- + return 0;
- +
- + // utility ebur128 (ebu r128)
- + if ( !is_util_ebur128 (argc, argv, &dati) )
- + return 0;
- +
- + // utility dbcalc db to ratio
- + if ( !is_util_dbcalc (argc, argv, &dati) )
- + return 0;
- +
- + // utility scrivi leggi settaggi su file
- + // save | load nomefile (con o senza .estensione e senza spazi)
- + if ( !is_load_save (argc, argv, &dati) )
- + return 0;
- +
- + // utility
- + // muxer nomefile2audio
- + if ( !is_muxer (argc, argv, &dati)
- + )
- + return 0;
- +
- + // utility
- + // volumedet = -af volumedetect
- + if ( !is_util_volumedetect (argc, argv, &dati) )
- + return 0;
- +
- + // sox
- + if ( !is_util_sox (argc, argv, &dati) )
- + return 0;
- +
- + // utility time
- + if ( !is_util_time (argc, argv, &dati) )
- + return 0;
- +
- + // nome fileout
- + // check se fileout esiste e nel caso rinomina _N_.ext
- + dati.nuovo_nome_file_out = check_fileout_name_e_rename (dati.nome_file_senza_ext, dati.nuova_estensione);
- +
- + //
- +
- + printf ("\n");
- +
- + // check parametri totali in input
- + if (dati.param_tot_previsti > argc)
- + {
- + dati.debug = true;
- + printf ("\n\nVerificare i parametri inseriti:\n");
- + printf ("Immessi %i, previsti %i\n\n",argc, dati.param_tot_previsti);
- + }
- +
- +
- + // esecuzione
- +
- + if ( !build_fin_eseg (&dati) )
- + return 1;
- +
- + return 0;
- +}
- +
- +
- +
- +
- diff -Naur -x '*~' src/f-help.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/f-help.cpp
- --- src/f-help.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/f-help.cpp 2013-11-10 16:19:21.894492187 +0100
- @@ -0,0 +1,80 @@
- +#include "funzioni.h"
- +
- +////
- +
- +void stampa_help(char * prg)
- +{
- + printf ("\n");
- + printf ("%s \n", prg);
- + printf (" nomefile [obbligatorio]\n");
- + printf (" [opzioni]\n");
- + printf (" -b bitrate video [kb] (-b 600, default: 730 AVC, 1500 ASP)\n");
- + printf (" -crf [0.0-50.0] (solo x264, default 19.0, 1 pass crf)\n");
- + printf (" -pass passate (-pass 2, -pass 3, default: singola)\n");
- + printf (" -nofast (-fastfirstpass 0, default 1)\n");
- + printf (" -audio (-a32 -a64 (aacplus 32k 64k)\n");
- + printf (" -a96 -a128 (aac_fdk: 96k 128k, default: 112k)\n");
- + printf (" -aaq [80-160] (faac vbr q 80 ~96k, 90 ~100k, 120 ~128k, 160 ~156k, default 100 ~118k)\n");
- + printf (" -alameq [0-9] (lame vbr q 0 ~245k, 5 ~130k, 6 ~115k, 9 ~65k, default 6)\n");
- + printf (" -alame [32-320] (lame cbr da 32 a 320k, default 128 )\n");
- + printf (" -an (no audio), -acopy (copia))\n");
- + printf (" -aboost (aac_fdk -afterburner 1)\n");
- + printf (" -avolume -20 20 (varia il volume audio da -20 a +20db.\n");
- + printf (" usare prima volumedet per stabilire il fattore)\n");
- + printf (" -acomp [std|film2|film3] [n] gain da -30 a 12 (default film, 0, ffmpeg compader audio)\n");
- + printf (" -vcopy (-c:v copy, default no)\n");
- + printf (" -vn (no video, out.mka)\n");
- + printf (" -mpeg4 (-c:v mpeg4 -c:a libmp3lame 128k, out.mkv)\n");
- + printf (" -avi (come -mpeg4, out.avi)\n");
- + printf (" -xvid (-vtag XVID, come mpeg4)\n");
- + printf (" -mp4 (.mp4, incompatibile con -avi -xvid)\n");
- + printf (" -copy (-c copy, default no)\n");
- + printf (" -scopy (-c:s copy, subtitles, default no -> ass)\n");
- + printf (" -map (multipli, es: -map 0:1 -map 0:0)\n");
- + printf (" -preset (-fast, -medium, -slow, default: faster)\n");
- + printf (" -profile (-main, -high, default: auto)\n");
- + printf (" -level (da -level1 a -level5, default: auto)\n");
- + printf (" -nopts (x264opts = nulla, default: le mie)\n");
- + printf (" -opencl (x264 OpenCL lookahead, default: no)\n");
- + printf (" -nr200 -nr500 (x264 noise reduction nr=200 or 500, default: no\n");
- + printf (" non usare in contemporanea a -vf [denoise])\n");
- + printf (" -10bit (x264 10bit depth, default: no)\n");
- + printf (" -vf filtri (-vf pp=ac,hqdn3d=3)\n");
- + printf (" -af filtri audio (-vf \"volume=enable='between(t,0,45)':volume=-6db\")\n");
- + printf (" -ss inizio HH:MM:SS o sec (-ss 00:01:00 -ss 60)\n");
- + printf (" -t durata HH:MM:SS o sec (-t 00:02:00 -t 120)\n");
- + printf (" -r rate (-r 25, default auto come sorgente)\n");
- + printf (" -nometa (come -map_metadata -1, default no)\n");
- + printf (" -aspect (4:3 4/3 16:9, da usare solo con -copy -vcopy -mpeg4)\n");
- + printf (" debug (stampa solo i comandi senza eseguire)\n");
- + printf (" -log (-psnr -report su logfile)\n");
- + printf (" [Utility]\n");
- + printf (" play (esegue ffplay nomefile con -vf -ss e -map)\n");
- + printf (" probe (esegue ffprobe nomefile)\n");
- + printf (" -hf filtro (help filtro, come ffmpeg -h filter=yadif)\n");
- + printf (" vftest (esegue ffplay nomefile in 2 finestre con -vf applicati e -ss)\n");
- + printf (" vftestsp (come spopra ma split verticale, per test unsharp,hqdn3d,hue ...)\n");
- + printf (" showwaves (visualizza onda audio, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
- + printf (" showspectrum (visualizza spettro audio, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
- + printf (" ebur128 (loudnesss audio ebu r128, supporta -af -acomp -avolume e -ss solo secondi es: -tt 3440)\n");
- + printf (" calc 640 0 16 9 (oppure 0 480 4 3, calcola scale con proporzioni in multipli di 8)\n");
- + printf (" mkvinfo (fornisce informazioni sugli stream di un .mkv per estrarli poi con mkvextract)\n");
- + printf (" mmg (mkvmerge gui)\n");
- + printf (" save | load nomefile (senza .estensione e senza spazi) \n");
- + printf (" salva carica i settaggi per uso seriale. \n");
- + printf (" volumedet (statistiche sul livello dell'audio, supporta -map -t -ss)\n");
- + printf (" dbcalc db (20 -20) da db a fattore di amplificazione\n");
- + printf (" sox norm | comp | compf | fastdet | compfast [noshow mux]\n");
- + printf (" (usa sox per normalizzare | compand l'audio in un file .mka.\n");
- + printf (" compfast non normalizza, gli altri richiedono molto spazio disco,\n");
- + printf (" validi i set audio -t -ss e -map, noshow sox progress, con compfast -avolume\n");
- + printf (" mux muxa in un file .mkv.)\n");
- + printf (" muxer nomesecondofile [mkv|avi|mp4] (muxa il video del filein con l'audio del secondo file.\n");
- + printf (" se non sono specificati -map usa -map 0:0 -map 1:0)\n");
- + printf (" time in out (hh:mm:ss o sec) calcola durata -t\n");
- + printf ("\n");
- + printf ("esempio:\n");
- + printf ("\n");
- + printf ("%s video.mp4 -b 800 -pass 2 -a32 fast -vf pp=ac,hqdn3d=3\n", prg);
- + printf ("\n");
- +}
- diff -Naur -x '*~' src/funzioni.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.cpp
- --- src/funzioni.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.cpp 2013-09-08 16:35:15.472650505 +0200
- @@ -0,0 +1,306 @@
- +#include "funzioni.h"
- +
- +////////////////////////////////////////////////////////////////
- +
- +void stampatempo (double time_target)
- +{
- + const int ONE_HOUR = 60 * 60;
- + const int ONE_MINUTE = 60;
- +
- + int hour;
- + int min;
- + int sec;
- +
- + hour=time_target/ONE_HOUR;
- + time_target-=hour*ONE_HOUR;
- + min=time_target/ONE_MINUTE;
- + time_target-=min*ONE_MINUTE;
- + sec=time_target;
- +
- + printf("%02dh:%02dm:%02ds\n",hour,min,sec);
- +
- +}
- +
- +////
- +
- +std::string str_stampatempo (double time_target)
- +{
- +
- + const int ONE_HOUR = 60 * 60;
- + const int ONE_MINUTE = 60;
- +
- + int hour;
- + int min;
- + int sec;
- +
- + hour=time_target/ONE_HOUR;
- + time_target-=hour*ONE_HOUR;
- + min=time_target/ONE_MINUTE;
- + time_target-=min*ONE_MINUTE;
- + sec=time_target;
- + char buffer [20];
- + sprintf(buffer,"%02dh:%02dm:%02ds\n",hour,min,sec);
- + return ( buffer );
- +
- +}
- +
- +
- +////
- +
- +std::string removeExtension (const std::string filename)
- +{
- + size_t lastdot = filename.find_last_of(".");
- + if (lastdot == std::string::npos) return filename;
- + return filename.substr(0, lastdot);
- +}
- +
- +////
- +
- +bool fileExists(const std::string& filename)
- +{
- + struct stat buf;
- + if (stat(filename.c_str(), &buf) != -1)
- + {
- + return true;
- + }
- + return false;
- +}
- +
- +////
- +
- +std::string tipo_ext (std::string file)
- +{
- + int found = file.find_last_of(".");
- + if (found != -1)
- + return (file.substr(found));
- + else
- + return "";
- +}
- +
- +////
- +
- +int esegui (const char* daeseg)
- +{
- + FILE * f = popen( daeseg, "r" );
- + if ( f == 0 )
- + {
- + fprintf( stderr, "Could not execute\n" );
- + return 1;
- + }
- + const int BUFSIZE = 1000;
- + char buf[ BUFSIZE ];
- + while( fgets( buf, BUFSIZE, f ) )
- + {
- + fprintf( stdout, "%s", buf );
- + }
- + pclose( f );
- + return 0;
- +}
- +
- +////
- +
- +std::string rimuovi_path (std::string file)
- +{
- + unsigned found = file.find_last_of("/\\");
- + return (file.substr(found+1));
- +}
- +
- +////
- +
- +std::string leggi_str_da_file (FILE * pFile )
- +{
- + char buffer_string [255];
- + std::string var;
- + fgets (buffer_string , 255 , pFile);
- + var = buffer_string;
- + var.erase ( var.size() -1);
- + return var;
- +}
- +
- +////
- +
- +int leggi_int_da_file (FILE * pFile )
- +{
- + char buffer_string [255];
- + int var;
- + fgets (buffer_string , 255 , pFile);
- + var = atoi (buffer_string); // pass è int
- + return var;
- +}
- +
- +////
- +
- +void scrivi_str_su_file (FILE * pFile, std::string var)
- +{
- + char buffer_string [255];
- + sprintf (buffer_string, "%s\n",var.c_str()) ;
- + fputs (buffer_string,pFile);
- +}
- +
- +////
- +
- +void scrivi_int_su_file (FILE * pFile, int var)
- +{
- + char buffer_string [255];
- + sprintf (buffer_string, "%i\n",var);
- + fputs (buffer_string,pFile);
- +}
- +
- +////
- +
- +void calcola_proporzioni (int w, int h, int aw, int ah)
- +{
- + float tmp;
- + if (h == 0)
- + {
- + tmp = ( float (w) / float (aw) ) * float (ah);
- + h = tmp;
- + if (w%2 != 0) // w è dispari
- + w = w +1;
- + if (h%2 != 0)
- + h = h +1;
- + }
- + else if (w == 0)
- + {
- + tmp = ( float (h) / float (ah) ) * float (aw);
- + w = tmp;
- + if (h%2 != 0)
- + h = h +1;
- + if (w%2 != 0)
- + w = w +1;
- + }
- + printf ("\npiù prossima:\n");
- + printf ("\n-vf scale=%i:%i:flags=lanczos,setsar=1/1,setdar=%i/%i\n",w,h,aw,ah);
- +}
- +
- +////
- +
- +void calcola_proporzioni_8 (int w, int h, int aw, int ah)
- +{
- + float tmp;
- + if (h == 0)
- + {
- + tmp = ( float (w) / float (aw) ) * float (ah);
- + h = tmp;
- + if (h%2 != 0)
- + h = h +1;
- + h = (h / 8) * 8;
- + w = (w / 8) * 8;
- + }
- + else if (w == 0)
- + {
- + tmp = ( float (h) / float (ah) ) * float (aw);
- + w = tmp;
- + if (w%2 != 0)
- + w = w +1;
- + w = (w / 8) * 8;
- + h = (h / 8) * 8;
- + }
- + printf ("\nmultipla di 8:\n");
- + printf ("\n-vf scale=%i:%i:flags=lanczos,setsar=1/1,setdar=%i/%i\n\n",w,h,aw,ah);
- +}
- +
- +////
- +
- +void stampa_info_file (std::string nome_del_file)
- +{
- + struct stat filestatus;
- + float size;
- + char dimensioni [20];
- + struct tm * timeinfo;
- + char data [80];
- + stat( nome_del_file.c_str(), &filestatus );
- + size = filestatus.st_size;
- + if (size < (1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0);
- + sprintf (dimensioni, "%6.1f KB", size );
- + }
- + else if ( size < (1024.0 * 1024.0 * 1024.0 * 2) && size >= (1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0 * 1024.0);
- + sprintf (dimensioni, "%6.1f MB", size );
- + }
- + else if (size >= (1024.0 * 1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0 * 1024.0 * 1024.0);
- + sprintf (dimensioni, "%6.2f GB", size );
- + }
- + timeinfo = localtime (&filestatus.st_mtime);
- + strftime (data,80,"%a %d %b %Y %T",timeinfo);
- + printf ("%s - %s - %s\n", dimensioni , data , nome_del_file.c_str() );
- +}
- +
- +////
- +
- +std::string str_stampa_info_file (std::string nome_del_file)
- +{
- + struct stat filestatus;
- + float size;
- + char dimensioni [20];
- + struct tm * timeinfo;
- + char data [80];
- + stat( nome_del_file.c_str(), &filestatus );
- + size = filestatus.st_size;
- + if (size < (1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0);
- + sprintf (dimensioni, "%6.1f KB", size );
- + }
- + else if ( size < (1024.0 * 1024.0 * 1024.0 * 2) && size >= (1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0 * 1024.0);
- + sprintf (dimensioni, "%6.1f MB", size );
- + }
- + else if (size >= (1024.0 * 1024.0 * 1024.0 * 2) )
- + {
- + size = size / (1024.0 * 1024.0 * 1024.0);
- + sprintf (dimensioni, "%6.2f GB", size );
- + }
- + timeinfo = localtime (&filestatus.st_mtime);
- + strftime (data,80,"%a %d %b %Y %T",timeinfo);
- + char buffer [255];
- + sprintf (buffer,"%s - %s - %s\n", dimensioni , data , nome_del_file.c_str() );
- + return ( buffer );
- +}
- +
- +
- +////
- +
- +bool check_num_param (int argc, int i, int num_previsti_dopo)
- +{
- + if ( (argc - 1) < (i + num_previsti_dopo) )
- + {
- + printf ("\nErrore: parametri insufficienti.\n\n");
- + return false;
- + }
- + return true; // ok
- +}
- +
- +////
- +
- +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione)
- +{
- + // nome fileout
- + std::string nome_file_out (nome_del_file_senza_estensione + estensione);
- + // check se fileout esiste e nel caso rinomina _N_.ext
- + char buffer_ifile [3];
- + for (int i=2; i<=9; i++)
- + {
- + if ( fileExists (nome_file_out.c_str()) )
- + {
- + sprintf (buffer_ifile, "%i", i); // i è int
- + nome_file_out = nome_del_file_senza_estensione + "_" + buffer_ifile + "_" + estensione;
- + }
- + }
- + return (nome_file_out);
- +}
- +
- +////
- +
- +bool is_number(const std::string& s)
- +{
- + return ( strspn( s.c_str(), "-.0123456789" ) == s.size() );
- +}
- +
- +////
- diff -Naur -x '*~' src/funzioni.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.h
- --- src/funzioni.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/funzioni.h 2013-08-28 16:11:25.551934004 +0200
- @@ -0,0 +1,38 @@
- +#ifndef FUNZIONI_H
- +#define FUNZIONI_H
- +
- +#ifndef NEED_LIBS_H
- +#define NEED_LIBS_H
- +#include <string>
- +#include <stdio.h>
- +#include <sys/types.h>
- +#include <sys/stat.h>
- +#include <time.h>
- +#include <stdlib.h> /* atoi */
- +#include <locale.h>
- +#include <string.h>
- +#endif
- +
- +////
- +void stampatempo (double time_target);
- +std::string str_stampatempo (double time_target);
- +std::string removeExtension (const std::string filename);
- +bool fileExists(const std::string& filename);
- +std::string tipo_ext (std::string file);
- +int esegui (const char* daeseg); // 0
- +std::string rimuovi_path (std::string file);
- +std::string leggi_str_da_file (FILE * pFile );
- +int leggi_int_da_file (FILE * pFile );
- +void scrivi_str_su_file (FILE * pFile, std::string var);
- +void scrivi_int_su_file (FILE * pFile, int var);
- +void calcola_proporzioni (int w, int h, int aw, int ah);
- +void calcola_proporzioni_8 (int w, int h, int aw, int ah);
- +void stampa_info_file (std::string nome_del_file);
- +std::string str_stampa_info_file (std::string nome_del_file);
- +bool check_num_param (int argc, int i, int num_previsti_dopo);
- +std::string check_fileout_name_e_rename (std::string nome_del_file_senza_estensione, std::string estensione);
- +bool is_number(const std::string& s);
- +////
- +void stampa_help(char * testo);
- +////
- +#endif
- diff -Naur -x '*~' src/main.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/main.h
- --- src/main.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/main.h 2013-09-15 17:55:31.520040800 +0200
- @@ -0,0 +1,120 @@
- +#ifndef MAIN_H
- +#define MAIN_H
- +
- +#ifndef NEED_LIBS_H
- +#define NEED_LIBS_H
- +#include <string>
- +#include <stdio.h>
- +#include <sys/types.h>
- +#include <sys/stat.h>
- +#include <time.h>
- +#include <stdlib.h> /* atoi */
- +#include <locale.h>
- +#include <math.h> /* pow */
- +#include <string.h>
- +#endif
- +
- +struct s_dati
- +{
- + std::string nomefilein; // con path
- + std::string nomedelfile; // senza path
- + std::string nome_file_senza_ext;
- + std::string estensione_file_in;
- + std::string eseguibile;
- + std::string nuova_estensione;
- + bool debug;
- + std::string rate;
- + std::string maps;
- + std::string vcodec;
- + std::string video_codec_is;
- + std::string bitrate_video;
- + int b_v_rate;
- + std::string preset;
- + std::string profile;
- + std::string set_264;
- + std::string audio_parm;
- + std::string audio_codec_is;
- + int pass;
- + bool nofastfirst;
- + std::string filter;
- + std::string filtervalore;
- + std::string a_filter_valore;
- + std::string tempoin;
- + std::string tempodur;
- + std::string logfile;
- + std::string altro;
- + std::string aspetto;
- + std::string format_out;
- + std::string nuovo_nome_file_out;
- + std::string daeseguire;
- + std::string filsett_vers;
- + int param_tot_previsti;
- + std::string riepilogo;
- +};
- +
- +
- +// eseguibile ffmpeg
- +#define ESEGUIBILE_FFMPEG "ffmpeg2"
- +// eseguibile 10bit
- +#define ESEGUIBILE_10BIT "ffmpeg-x10bit"
- +// eseguibile play
- +#define ESEGUIBILE_PLAY "ffplay2"
- +// eseguibile probe
- +#define ESEGUIBILE_PROBE "ffprobe2"
- +// eseguibile mkvinfo
- +#define ESEGUIBILE_MKVINFO "mkvinfo-gui -g"
- +// default e opzioni
- +#define NUOVA_EXT_AVI ".avi"
- +#define NUOVA_EXT_MP4 ".mp4"
- +#define NUOVA_EXT_MKV ".mkv"
- +#define NUOVA_EXT_MKA ".mka"
- +#define VCODEC_X264 "-c:v libx264"
- +#define VCODEC_MPEG4 "-c:v mpeg4 -mpv_flags strict_gop"
- +#define VCODEC_VCOPY "-c:v copy"
- +#define VCODEC_NONE "-vn"
- +#define VCODEC_COPY_ALL "-c copy"
- +#define XVID_TAG "-vtag XVID"
- +#define VIDEO_IS_X_264 "video_is_x_264"
- +#define VIDEO_IS_MPEG4 "video_is_mpeg4"
- +#define VIDEO_IS_MPEG4_XVID "video_is_mpeg4_xvid"
- +#define BITRATE_VIDEO_X264_DEFAULT "-b:v 730k"
- +#define BITRATE_VIDEO_MPEG4_DEFAULT "-b:v 1500k"
- +#define PRESET_FASTER "-preset faster -tune film"
- +#define PRESET_FAST "-preset fast -tune film"
- +#define PRESET_MEDIUM "-preset medium -tune film"
- +#define PRESET_SLOW "-preset slow -tune film"
- +#define PROFILE_MAIN "-profile:v main"
- +#define PROFILE_HIGH "-profile:v high"
- +#define OPT_264_1 "-x264opts ref=4:bframes=4:direct=auto:aq-strength=1.3:ssim"
- +#define OPT_264_NOPTS "-x264opts ssim"
- +#define LEVEL_1_0 "level=1.0:ref=1:bframes=0:vbv-bufsize=218:vbv-maxrate=80"
- +#define LEVEL_2_0 "level=2.0:ref=2:b-pyramid=none:vbv-bufsize=2500:vbv-maxrate=2500"
- +#define LEVEL_3_0 "level=3.0:vbv-bufsize=12500:vbv-maxrate=12500"
- +#define LEVEL_4_0 "level=4.0:vbv-bufsize=25000:vbv-maxrate=20000"
- +#define LEVEL_5_0 "level=5.0:vbv-bufsize=168750:vbv-maxrate=168750"
- +#define AUDIO_PARM_AP32 "-c:a libaacplus -b:a 32k -ar 48k -ac 2"
- +#define AUDIO_PARM_AP64 "-c:a libaacplus -b:a 64k -ar 48k -ac 2"
- +#define AUDIO_PARM_AF96 "-c:a libfdk_aac -b:a 96k -ar 48k -ac 2"
- +#define AUDIO_PARM_AF112 "-c:a libfdk_aac -b:a 112k -ar 48k -ac 2"
- +#define AUDIO_PARM_AF128 "-c:a libfdk_aac -b:a 128k -ar 48k -ac 2"
- +#define AUDIO_PARM_COPY "-c:a copy"
- +#define AUDIO_PARM_NONE "-an"
- +#define AUDIO_PARM_LAME_C128 "-c:a libmp3lame -b:a 128k -ar 48k -ac 2"
- +#define AUDIO_BOOST_FDK "-afterburner 1" // solo per fdk_aac
- +#define AUDIO_IS_LAME "audio_is_lame"
- +#define AUDIO_IS_FDKAAC "audio_is_fdkaac"
- +#define AUDIO_IS_AACPLUS "audio_is_aacplus"
- +#define AUDIO_IS_FAAC "audio_is_faac"
- +#define FILESETTAGGI_EXT ".fftlset"
- +#define FAST_1_PASS "-fastfirstpass 1"
- +#define FORMAT_NULL "-f null"
- +#define FORMAT_OUT_AVI "-f avi"
- +#define FORMAT_OUT_MP4 "-f mp4"
- +#define FORMAT_OUT_MATROSKA "-f matroska"
- +#define OUT_NULL "/dev/null" // linux
- +#define FILTRO_FFMPEG_OUTPUT "2>&1 | grep -Ev 'configuration|built on|FFmpeg developers|libavutil|libavcodec|libavformat|libavfilter|libavdevice|libavdevice|libswscale|libswresample|libpostproc'"
- +
- +#endif
- +
- +
- +
- diff -Naur -x '*~' src/makefile /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/makefile
- --- src/makefile 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/makefile 2013-09-15 16:07:21.000000000 +0200
- @@ -0,0 +1,20 @@
- +all:
- + g++ -O3 -o 730-ffmpeg-tool-2 \
- + funzioni.cpp \
- + f-help.cpp \
- + routines/routines.cpp \
- + routines/r-video-generali.cpp \
- + routines/r-video-x264.cpp \
- + routines/r-video-asp-avi.cpp \
- + routines/r-audio.cpp \
- + routines/r-util.cpp \
- + routines/r-util-sox.cpp \
- + routines/r-file-sett.cpp \
- + routines/r-build-fin.cpp \
- + 730-ffmpeg-tool-main.cpp -s
- +
- +
- +clean:
- + rm -f *.o *.a *~ routines/*.o routines/*~ 730-ffmpeg-tool-2
- +
- +
- diff -Naur -x '*~' src/routines/r-audio.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.cpp
- --- src/routines/r-audio.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.cpp 2013-10-04 13:01:09.258847993 +0200
- @@ -0,0 +1,267 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-audio.h"
- +
- +bool is_audio (int argc, char * argv[], s_dati *dati)
- +{
- + // audio
- + for (int i=2; i<argc; i++)
- + {
- +
- + if (std::string(argv[i]) == "-a32")
- + {
- + dati->audio_parm = AUDIO_PARM_AP32;
- + dati->audio_codec_is = AUDIO_IS_AACPLUS;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a64")
- + {
- + dati->audio_parm = AUDIO_PARM_AP64;
- + dati->audio_codec_is = AUDIO_IS_AACPLUS;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a96")
- + {
- + dati->audio_parm = AUDIO_PARM_AF96;
- + dati->audio_codec_is = AUDIO_IS_FDKAAC;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a128")
- + {
- + dati->audio_parm = AUDIO_PARM_AF128;
- + dati->audio_codec_is = AUDIO_IS_FDKAAC;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-aaq")
- + {
- + // check argomento 80 to 160
- + int q (100); //default 100 vbr 118k
- + if ( argc-1 >= i+1 )
- + {
- + if ( is_number( argv[i+1]) )
- + {
- + q = atoi(argv[i+1]);
- + if ( q < 80 || q > 160)
- + {
- + printf ("\nInserire un q corretto (80-160) vbr 80 ~96k, 90 ~100k, 120 ~128k, 160 ~156k.\n\n");
- + return false;
- + }
- + }
- + }
- + char qfact [4];
- + sprintf(qfact,"%i",q);
- +
- + std::string audio_parm_aaq = "-c:a libfaac -q:a " + (std::string)qfact + " -ar 48k -ac 2";
- + dati->audio_parm = audio_parm_aaq;
- + dati->audio_codec_is = AUDIO_IS_FAAC;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-acopy")
- + {
- + dati->audio_parm = AUDIO_PARM_COPY;
- + dati->audio_codec_is = "";
- + dati->a_filter_valore = "";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-an")
- + {
- + dati->audio_parm = AUDIO_PARM_NONE;
- + dati->audio_codec_is = "";
- + dati->a_filter_valore = "";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-alameq")
- + {
- + // check argomento 0 to 9
- + int q (6); //default 6 vbr 115k
- + if ( argc-1 >= i+1 )
- + {
- + if ( is_number( argv[i+1]) )
- + {
- + q = atoi(argv[i+1]);
- + if ( q < 0 || q > 9)
- + {
- + printf ("\nInserire un q corretto (0-9) vbr 0=245k 6=115k 9=65k.\n\n");
- + return false;
- + }
- + }
- + }
- + char qfact [2];
- + sprintf(qfact,"%i",q);
- +
- + std::string audio_parm_lameq = "-c:a libmp3lame -q:a " + (std::string)qfact + " -ar 48k -ac 2";
- + dati->audio_parm = audio_parm_lameq;
- + dati->audio_codec_is = AUDIO_IS_LAME;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-alame")
- + {
- + int ba (128); // default
- + if ( argc-1 >= i+1 )
- + {
- + if ( is_number(argv[i+1]) )
- + {
- + ba = atoi(argv[i+1]);
- + // check argomento 32 to 320
- + if ( ba < 32 || ba > 320)
- + {
- + printf ("\nInserire un bitrate audio corretto (32-320).\n\n");
- + return false;
- + }
- + }
- + }
- + char buffer [5];
- + sprintf(buffer,"%i",ba);
- + std::string audio_parm_lameb = "-c:a libmp3lame -b:a " + (std::string)buffer + "k -ar 48k -ac 2";
- + dati->audio_parm = audio_parm_lameb;
- + dati->audio_codec_is = AUDIO_IS_LAME;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_aboost (int argc, char * argv[], s_dati *dati)
- +{
- + // -aboost // solo per fdk_aac
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-aboost")
- + {
- + // solo audio fdk_aac
- + if ( dati->audio_codec_is == AUDIO_IS_FDKAAC )
- + {
- + dati->audio_parm = dati->audio_parm + " " + AUDIO_BOOST_FDK;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + }
- + break;
- + }
- + }
- +}
- +
- +bool is_avolume (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-avolume")
- + {
- + if ( !check_num_param (argc,i,1) )
- + {
- + printf ("\nInserire un fattore di amplificazione in db (da -20.0 a 20.0).\n");
- + printf ("Usare: volumedet per stabilirlo con precisione.\n");
- + return false;
- + }
- + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
- + double amp = atof(argv[i+1]);
- + if ( amp < -20.0 || amp > 20.0 || amp == 0.0 )
- + {
- + printf ("\nInserire un fattore di amplificazione in db (da -20.0 a 20.0).\n");
- + printf ("Usare: volumedet per stabilirlo con precisione.\n");
- + return false;
- + }
- + // db to ratio
- + float f_ratio = pow (10.0, (amp/20.0) );
- + char ratio [10];
- + sprintf (ratio,"%.3f",f_ratio);
- + setlocale (LC_ALL,""); // ripristino locale
- + if ( dati->a_filter_valore == "" )
- + dati->a_filter_valore = "volume=" + (std::string)ratio;
- + else
- + dati->a_filter_valore = dati->a_filter_valore + "," + "volume=" + (std::string)ratio;
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool is_afilter (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-af")
- + {
- + if ( !check_num_param (argc,i,1) )
- + {
- + printf ("-af necessita di un parametro.\n\n");
- + return false;
- + }
- + std::string temp;
- + temp = (argv[i+1]);
- + if ( dati->a_filter_valore == "" )
- + dati->a_filter_valore = temp;
- + else
- + dati->a_filter_valore = dati->a_filter_valore + "," + temp;
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool is_acomp (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-acomp")
- + {
- + int prossimo = 1;
- + std::string compader = FFMPEG_COMPAND_FILM_1; //default
- +
- + if ( argc-1 >= i+prossimo )
- + {
- + if (std::string(argv[i+prossimo]) == "std")
- + {
- + compader = FFMPEG_COMPAND_1;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + prossimo = prossimo + 1;
- + }
- + else if (std::string(argv[i+prossimo]) == "film2")
- + {
- + compader = FFMPEG_COMPAND_FILM_2;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + prossimo = prossimo + 1;
- + }
- + else if (std::string(argv[i+prossimo]) == "film3")
- + {
- + compader = FFMPEG_COMPAND_FILM_3;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + prossimo = prossimo + 1;
- + }
- + }
- +
- + std::string comp_gain = "0"; //default GAIN = 0
- + if ( argc-1 >= i+prossimo )
- + {
- + std::string is_gain = (argv[i+prossimo]);
- + if ( is_number(is_gain) )
- + {
- + int test = atoi( is_gain.c_str() );
- + if (test < 13 && test > -30)
- + {
- + comp_gain = is_gain;
- + }
- + }
- + }
- + compader.replace(compader.find("GAIN"),4,comp_gain);
- +
- + if ( dati->a_filter_valore == "" )
- + dati->a_filter_valore = compader;
- + else
- + dati->a_filter_valore = dati->a_filter_valore + "," + compader;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- + return true;
- +}
- +
- diff -Naur -x '*~' src/routines/r-audio.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.h
- --- src/routines/r-audio.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-audio.h 2013-08-29 20:05:15.326016089 +0200
- @@ -0,0 +1,18 @@
- +#ifndef R_AUDIO_H
- +#define R_AUDIO_H
- +
- +// default GAIN = 0
- +#define FFMPEG_COMPAND_1 "compand=.3 .3:1 1:-90/-60 -60/-40 -40/-30 -20/-20 :6:GAIN:-90:0.2"
- +#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
- +#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
- +#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"
- +
- +#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
- +
- +bool is_audio (int argc, char * argv[], s_dati *dati);
- +void is_aboost (int argc, char * argv[], s_dati *dati);
- +bool is_avolume (int argc, char * argv[], s_dati *dati);
- +bool is_afilter (int argc, char * argv[], s_dati *dati);
- +bool is_acomp (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- 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
- --- src/routines/r-build-fin.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.cpp 2013-09-16 15:48:02.620479917 +0200
- @@ -0,0 +1,174 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-build-fin.h"
- +
- +
- +bool build_fin_eseg (s_dati *dati)
- +{
- + // variabili cronometri
- + time_t now;
- + double seconds, seconds2start, seconds3start;
- + double durata, durata1, durata2, durata3;
- +
- +
- + for (int i=1; i<=dati->pass; i++)
- + {
- +
- + dati->daeseguire = (dati->eseguibile + " ");
- + if (dati->logfile != "")
- + dati->daeseguire = dati->daeseguire + dati->logfile + " ";
- + if
- + (
- + (dati->pass==2 && i==1)
- + || (dati->pass==3 && (i==1 || i==2))
- + )
- + dati->daeseguire = dati->daeseguire + "-y ";
- +
- + dati->daeseguire = dati->daeseguire + "-i "
- + + "\"" + dati->nomefilein + "\"" + " ";
- + if (dati->rate != "")
- + dati->daeseguire = dati->daeseguire + dati->rate + " ";
- + if (dati->maps!= "")
- + dati->daeseguire = dati->daeseguire + dati->maps + " ";
- + if (dati->tempoin != "")
- + dati->daeseguire = dati->daeseguire + dati->tempoin + " ";
- + if (dati->tempodur != "")
- + dati->daeseguire = dati->daeseguire + dati->tempodur + " ";
- + if (dati->filter != "")
- + dati->daeseguire = dati->daeseguire + dati->filter + " ";
- + if (dati->vcodec != "")
- + dati->daeseguire = dati->daeseguire + dati->vcodec + " ";
- + if (dati->video_codec_is == VIDEO_IS_X_264)
- + {
- + if (dati->preset != "")
- + dati->daeseguire = dati->daeseguire + dati->preset + " ";
- + if (dati->profile != "")
- + dati->daeseguire = dati->daeseguire + dati->profile + " ";
- + if (dati->set_264 != "")
- + dati->daeseguire = dati->daeseguire + dati->set_264 + " ";
- + }
- + if (dati->bitrate_video != "")
- + dati->daeseguire = dati->daeseguire + dati->bitrate_video + " ";
- + if (dati->pass>=2 && i==1)
- + {
- + dati->daeseguire = dati->daeseguire + "-pass 1" + " ";
- + if ( (dati->nofastfirst == 0) && (dati->video_codec_is == VIDEO_IS_X_264) )
- + dati->daeseguire = dati->daeseguire + FAST_1_PASS + " ";
- + }
- + if
- + (
- + (dati->pass==2 && i==2)
- + || (dati->pass==3 && i==3)
- + )
- + dati->daeseguire = dati->daeseguire + "-pass 2" + " ";
- +
- + if (dati->pass==3 && i==2)
- + dati->daeseguire = dati->daeseguire + "-pass 3" + " ";
- + if
- + (
- + (dati->pass==2 && i==1)
- + || (dati->pass==3 && (i==1 || i==2))
- + )
- + dati->daeseguire = dati->daeseguire + AUDIO_PARM_NONE + " " + FORMAT_NULL + " " + OUT_NULL;
- +
- + if
- + (
- + dati->pass==1
- + || (dati->pass==2 && i==2)
- + || (dati->pass==3 && i==3)
- + )
- + {
- + if (dati->a_filter_valore != "")
- + dati->daeseguire = dati->daeseguire + "-af" + " "
- + + "\"" + dati->a_filter_valore + "\"" + " ";
- + if (dati->audio_parm != "")
- + dati->daeseguire = dati->daeseguire + dati->audio_parm + " ";
- + dati->daeseguire = (dati->daeseguire + dati->format_out + " ");
- + if (dati->altro != "")
- + dati->daeseguire = dati->daeseguire + dati->altro + " ";
- + if ( (dati->video_codec_is != VIDEO_IS_X_264) && (dati->aspetto != "") )
- + dati->daeseguire = dati->daeseguire + dati->aspetto + " ";
- + dati->daeseguire = dati->daeseguire + "\"" + dati->nuovo_nome_file_out + "\"";
- + }
- +
- + if (!dati->debug)
- + printf ("\n\n");
- +
- + printf ("%s\n\n", dati->daeseguire.c_str());
- +
- + if (!dati->debug)
- + {
- + if (i==1)
- + {
- + seconds = time(&now);
- + if ( esegui(dati->daeseguire.c_str()) !=0) return true;
- + durata1 = difftime(time(&now),seconds);
- + }
- +
- + if (i==2)
- + {
- + seconds2start = time(&now);
- + if (esegui (dati->daeseguire.c_str()) !=0) return true;
- + durata2 = difftime(time(&now),seconds2start);
- + }
- +
- + if (i==3)
- + {
- + seconds3start = time(&now);
- + if ( esegui(dati->daeseguire.c_str()) !=0) return true;
- + durata3 = difftime(time(&now),seconds3start);
- + }
- + }
- +
- + }
- + // durata totale
- + durata = difftime(time(&now),seconds);
- +
- + // elimina i file stat delle passate
- + // ffmpeg2pass-0.log ffmpeg2pass-0.log.mbtree
- + if ( (dati->pass>1) && (!dati->debug) )
- + {
- + if( remove( "ffmpeg2pass-0.log" ) != 0 )
- + perror( "Error deleting file" );
- + if (dati->vcodec == VCODEC_X264)
- + {
- + if( remove( "ffmpeg2pass-0.log.mbtree" ) != 0 )
- + perror( "Error deleting file" );
- + }
- + }
- +
- +
- + // stampa i cronometri su stringa
- + if (!dati->debug)
- + {
- + dati->riepilogo = "\n\nTempo conversione: "
- + + str_stampatempo(durata);
- +
- + if ((dati->pass==2) || (dati->pass==3))
- + {
- + dati->riepilogo = dati->riepilogo
- + + "\nPass 1: " +str_stampatempo(durata1)
- + + "Pass 2: " +str_stampatempo(durata2);
- + }
- + if (dati->pass==3)
- + {
- + dati->riepilogo = dati->riepilogo
- + + "Pass 3: " +str_stampatempo(durata3);
- + }
- + dati->riepilogo = dati->riepilogo + "\n";
- + }
- +
- + // stampa le dimensioni in MB e data dei file in e out su stringa
- + if (!dati->debug)
- + {
- + dati->riepilogo = dati->riepilogo
- + + str_stampa_info_file (dati->nomefilein)
- + + str_stampa_info_file (dati->nuovo_nome_file_out)
- + + "\n";
- +
- + // stampa su terminale
- + printf ("%s", dati->riepilogo.c_str() );
- + }
- +
- + return false;
- +}
- 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
- --- src/routines/r-build-fin.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-build-fin.h 2013-08-26 15:36:41.883981953 +0200
- @@ -0,0 +1,6 @@
- +#ifndef R_BUILD_FIN_H
- +#define BUILD_FIN_H
- +
- +bool build_fin_eseg (s_dati *dati);
- +
- +#endif
- 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
- --- src/routines/r-file-sett.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.cpp 2013-08-26 00:09:47.552378045 +0200
- @@ -0,0 +1,99 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-file-sett.h"
- +
- +bool is_load_save (int argc, char * argv[], s_dati *dati)
- +{
- + // utility scrivi leggi settaggi su file
- + // save | load nomefile (con o senza .estensione e senza spazi)
- +
- + for (int i=2; i<argc; i++)
- + {
- + if ( (std::string(argv[i]) == "save") || (std::string(argv[i]) == "load") )
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + std::string nomefilesettaggi = removeExtension ( std::string(argv[i+1]).c_str() ) + FILESETTAGGI_EXT;
- + //
- + FILE * pFile;
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + // scrivi
- + if ( (std::string(argv[i]) == "save") )
- + {
- +
- + pFile = fopen (nomefilesettaggi.c_str(),"w");
- + if (pFile == NULL)
- + {
- + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
- + perror ("Errore");
- + return false;
- + }
- + else
- + {
- +
- + scrivi_str_su_file (pFile , dati->filsett_vers);
- + scrivi_str_su_file (pFile , dati->maps);
- + scrivi_str_su_file (pFile , dati->bitrate_video);
- + scrivi_str_su_file (pFile , dati->filter);
- + scrivi_str_su_file (pFile , dati->set_264);
- + scrivi_str_su_file (pFile , dati->preset);
- + scrivi_int_su_file (pFile , dati->pass);
- + scrivi_str_su_file (pFile , dati->audio_parm);
- + scrivi_str_su_file (pFile , dati->format_out);
- + scrivi_str_su_file (pFile , dati->vcodec);
- + scrivi_str_su_file (pFile , dati->nuova_estensione);
- +
- + fclose (pFile);
- + printf ("\nIl file: %s è stato salvato.\n\n", nomefilesettaggi.c_str() );
- + break;
- + }
- +
- +
- + }
- + // leggi
- + if ( (std::string(argv[i]) == "load") )
- + {
- + pFile = fopen (nomefilesettaggi.c_str(),"r");
- + if (pFile == NULL)
- + {
- + printf ("\nIl file: %s non può essere aperto.\n",nomefilesettaggi.c_str() );
- + perror ("Errore");
- + return false;
- + }
- + else
- + {
- + std::string check_file_version ("");
- + check_file_version = leggi_str_da_file (pFile);
- + if (check_file_version != dati->filsett_vers)
- + {
- + fclose (pFile);
- + printf ("\nIl file: %s non è compatibile con questa versione.\n\n",nomefilesettaggi.c_str() );
- + return false;
- + }
- +
- + dati->maps = leggi_str_da_file (pFile);
- + dati->bitrate_video = leggi_str_da_file (pFile);
- + dati->filter = leggi_str_da_file (pFile);
- + dati->set_264 = leggi_str_da_file (pFile);
- + dati->preset = leggi_str_da_file (pFile);
- + dati->pass = leggi_int_da_file (pFile); // pass è int
- + dati->audio_parm = leggi_str_da_file (pFile);
- + dati->format_out = leggi_str_da_file (pFile);
- + dati->vcodec = leggi_str_da_file (pFile);
- + dati->nuova_estensione = leggi_str_da_file (pFile);
- +
- + fclose (pFile);
- + printf ("\nIl file: %s è stato caricato.\n\n", nomefilesettaggi.c_str() );
- + break;
- + }
- +
- + }
- +
- + }
- +
- + }
- + return true;
- +}
- +
- +
- +
- 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
- --- src/routines/r-file-sett.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-file-sett.h 2013-08-23 21:57:49.000000000 +0200
- @@ -0,0 +1,6 @@
- +#ifndef R_FILE_SETT_H
- +#define R_FILE_SETT_H
- +
- +bool is_load_save (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- diff -Naur -x '*~' src/routines/routines.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.cpp
- --- src/routines/routines.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.cpp 2013-08-26 00:12:49.120973731 +0200
- @@ -0,0 +1,139 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "routines.h"
- +
- +void isdebug (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "debug")
- + {
- + dati->debug = true;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_map (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-map")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + if (dati->maps == "")
- + {
- + dati->maps = "-map " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + }
- + else
- + {
- + dati->maps = dati->maps + " -map " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + }
- + i++;
- + }
- + }
- + return true;
- +}
- +
- +void is_10bit (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-10bit")
- + {
- + dati->eseguibile = ESEGUIBILE_10BIT;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_filter (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-vf")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + dati->filtervalore = std::string (argv[i+1]);
- + dati->filter = "-vf " + dati->filtervalore;
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool is_ss_is_t (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-ss")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + dati->tempoin = "-ss " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-t")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + dati->tempodur = "-t " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_altro (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-nometa")
- + {
- + dati->altro = "-map_metadata -1";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-scopy")
- + {
- + if (dati->altro != "")
- + dati->altro = dati->altro + " -c:s copy";
- + else
- + dati->altro = "-c:s copy";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_log (int argc, char * argv[], s_dati *dati)
- +{
- +// -log logfile ffmpeg
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-log")
- + {
- + dati->logfile = "-psnr -report";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- diff -Naur -x '*~' src/routines/routines.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.h
- --- src/routines/routines.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/routines.h 2013-08-23 21:33:51.000000000 +0200
- @@ -0,0 +1,15 @@
- +#ifndef ROUTINES_H
- +#define ROUTINES_H
- +
- +void isdebug (int argc, char * argv[], s_dati *dati);
- +bool is_map (int argc, char * argv[], s_dati *dati);
- +void is_10bit (int argc, char * argv[], s_dati *dati);
- +bool is_filter (int argc, char * argv[], s_dati *dati);
- +bool is_ss_is_t (int argc, char * argv[], s_dati *dati);
- +void is_altro (int argc, char * argv[], s_dati *dati);
- +void is_log (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- +
- +
- +
- diff -Naur -x '*~' src/routines/r-util.cpp /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.cpp
- --- src/routines/r-util.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.cpp 2013-09-28 15:35:40.325120764 +0200
- @@ -0,0 +1,496 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-util.h"
- +
- +int ConvStdTimeToSec(std::string time)
- +{
- + int val;
- +
- + val = ( atoi(time.substr(0,2).c_str()) * 3600 )
- + + ( atoi(time.substr(3,2).c_str()) * 60 )
- + + ( atoi(time.substr(6,2).c_str()) );
- +
- + return val;
- +}
- +
- +
- +bool is_util_mkvinfo (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "mkvinfo")
- + {
- + if (dati->estensione_file_in == ".mkv")
- + {
- + std::string utility ((std::string)ESEGUIBILE_MKVINFO + " "
- + + "\"" + dati->nomefilein + "\""
- + );
- + printf ("\n");
- + if ( esegui(utility.c_str()) !=0) return false;
- + printf ("\n\nEsempi estrazione flussi:\n\n");
- + printf ("mkvextract tracks %s 1:video.mkv\n",dati->nomefilein.c_str());
- + printf ("mkvextract tracks %s 2:audio.mp3\n",dati->nomefilein.c_str());
- + printf ("mkvextract tracks %s 6:subs.srt\n\n",dati->nomefilein.c_str());
- + printf ("\nDove n:tipofile.ext sono il numero ed il tipo di stream.\n\n");
- + return false;
- + }
- + else
- + {
- + printf ("\n il file \"%s\" non è un file matroska .mkv\n\n", dati->nomedelfile.c_str() );
- + return false;
- + }
- + }
- + }
- + return true;
- +}
- +
- +bool is_util_mkvmerge (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "mmg")
- + {
- + std::string mmgexe ("mmg");
- + std::string utility = mmgexe + " " + "\"" + dati->nomefilein + "\"";
- + printf ("\n");
- + printf ("\n%s\n\n",utility.c_str() );
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +
- +}
- +
- +bool is_util_play (int argc, char * argv[], s_dati *dati)
- +{
- + // utility play (preview con -map -ss e -vf)
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "play")
- + {
- + std::string utility;
- + if ( dati->maps == "" )
- + {
- + utility = (std::string)ESEGUIBILE_PLAY + " "
- + + "\"" + dati->nomefilein + "\" ";
- + if (dati->filter != "")
- + utility = utility + dati->filter + " ";
- + if (dati->tempoin != "")
- + utility = utility + dati->tempoin + " ";
- + }
- + else
- + {
- + utility = (std::string)ESEGUIBILE_FFMPEG + " -i "
- + + "\"" + dati->nomefilein + "\" "
- + + dati->maps + " ";
- + if ( dati->tempoin != "")
- + utility = utility + dati->tempoin + " ";
- + utility = utility + VCODEC_COPY_ALL + " "
- + + FORMAT_OUT_MATROSKA + " - | "
- + + ESEGUIBILE_PLAY + " "
- + + "- ";
- + if ( dati->filter != "")
- + utility = utility + dati->filter + " ";
- + utility = utility + "&";
- + }
- + printf ("\n%s\n\n",utility.c_str());
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +
- +bool is_util_probe (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "probe")
- + {
- + std::string utility ((std::string)ESEGUIBILE_PROBE + " "
- + + "\"" + dati->nomefilein + "\""
- + + " " + FILTRO_FFMPEG_OUTPUT
- + );
- + printf ("\n");
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +bool is_util_help_filter (int argc, char * argv[])
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-hf")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + std::string utility ((std::string)ESEGUIBILE_FFMPEG + " "
- + + "-h filter=" + std::string(argv[i+1])
- + + " " + FILTRO_FFMPEG_OUTPUT
- + );
- + printf ("\n");
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_vftest (int argc, char * argv[], s_dati *dati)
- +{
- + // utility vftest 2 video verticali
- + // filtervalore per utility vftest
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "vftest")
- + {
- + if (dati->filtervalore == "")
- + {
- + printf ("\nè necessario usare -vf filter,filter per usare vftest.\n\n" );
- + return false;
- + }
- + // 2v
- + std::string utility ((std::string)ESEGUIBILE_PLAY + " "
- + + "\"" + dati->nomefilein + "\" "
- + + "-vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]"
- + + dati->filtervalore
- + + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\" "
- + );
- + if (dati->tempoin != "")
- + utility = utility + dati->tempoin + " ";
- + printf ("\n%s\n\n", utility.c_str() );
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_vftestsp (int argc, char * argv[], s_dati *dati)
- +{
- + // utility vftestsp video split
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "vftestsp")
- + {
- + if (dati->filtervalore == "")
- + {
- + printf ("\nè necessario usare -vf filter,filter per usare vftestsp.\n\n" );
- + return false;
- + }
- + // 2v
- + std::string utility ((std::string)ESEGUIBILE_PLAY + " "
- + + "\"" + dati->nomefilein + "\" "
- + + "-vf \"split [main][tmp]; [tmp] crop=iw/2:ih:iw/2:0,"
- + + dati->filtervalore
- + + " [filter]; [main][filter] overlay=W/2:0\" "
- + );
- + if (dati->tempoin != "")
- + utility = utility + dati->tempoin + " ";
- + printf ("\n%s\n\n", utility.c_str() );
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_calc_scale (int argc, char * argv[])
- +{
- + // utility calcola scala proporzionale
- + // calc 720 0 16 9 o calc 0 480 4 3
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "calc")
- + {
- + if ( !check_num_param (argc,i,4) )
- + {
- + printf ("\nUsare: calc 640 0 16 9 oppure 0 480 4 3.\n\n");
- + return false;
- + }
- + int w, h, aw, ah;
- + w = atoi(argv[i+1]);
- + h = atoi(argv[i+2]);
- + aw = atoi(argv[i+3]);
- + ah = atoi(argv[i+4]);
- + //check
- + if ( (w == 0 && h == 0) || (aw == 0) || (ah == 0) )
- + {
- + printf ("\nUsare: calc 640 0 16 9 oppure 0 480 4 3.\n\n");
- + return false;
- + }
- + calcola_proporzioni (w, h, aw, ah);
- + calcola_proporzioni_8 (w, h, aw, ah);
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_muxer (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if ( std::string(argv[i]) == "muxer" )
- + {
- + if ( !check_num_param (argc,i,1) )
- + {
- + printf ("usare: %s -muxer nomefileaudio [container mkv(default)|avi|mp4]\n", dati->nomefilein.c_str() );
- + printf ("Se -map non sono specificati viene usato:\n");
- + printf ("-map 0:0 -map 1:0\n\n");
- + return false;
- + }
- + std::string nome_file_audio = (argv[i+1]);
- + std::string verifica = nome_file_audio.substr ( (nome_file_audio.length() -1) ,1);
- + if (verifica == "/")
- + {
- + printf ("\nAttenzione: %s è una cartella.\n\n", nome_file_audio.c_str() );
- + return false;
- + }
- + if ( !fileExists ( nome_file_audio.c_str() ) )
- + {
- + printf ("\nIl file: %s non esiste.\n\n", nome_file_audio.c_str() );
- + return false;
- + }
- + std::string formato = FORMAT_OUT_MATROSKA;
- + std::string tipo = NUOVA_EXT_MKV;
- + if ( (argc-1) >= (i+2) )
- + {
- + std::string container = (argv[i+2]);
- + if ( container == "avi")
- + {
- + formato = FORMAT_OUT_AVI;
- + tipo = NUOVA_EXT_AVI;
- + }
- + else if ( container == "mp4")
- + {
- + formato = FORMAT_OUT_MP4;
- + tipo = NUOVA_EXT_MP4;
- + }
- + }
- + tipo = "_MUXED_" + tipo;
- + std::string daeseguire;
- + std::string nuovo_nome_file_out_muxed = check_fileout_name_e_rename (dati->nome_file_senza_ext, tipo);
- + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " "
- + + "-i "+ "\"" + dati->nomefilein + "\"" + " "
- + + "-i " + "\"" + nome_file_audio + "\"" + " ";
- + if (dati->maps == "")
- + daeseguire = daeseguire + "-map 0:0 -map 1:0 " + " ";
- + else
- + daeseguire = daeseguire + dati->maps + " ";
- + // un po inutile solo per test
- + if (dati->tempodur != "")
- + daeseguire = daeseguire + dati->tempodur + " ";
- + // -----------------------------
- + daeseguire = daeseguire + VCODEC_COPY_ALL + " "
- + + formato + " "
- + + + "\"" + nuovo_nome_file_out_muxed + "\"";
- + printf ("\n%s\n\n", daeseguire.c_str() );
- + if (! dati->debug)
- + {
- + if ( esegui(daeseguire.c_str()) !=0) return false;
- + printf ("\n");
- + stampa_info_file (nuovo_nome_file_out_muxed);
- + printf ("\n");
- + }
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +bool is_util_volumedetect (int argc, char * argv[], s_dati *dati)
- +{
- + // ffmpeg -i filein -vn -af volumedetect -f null /dev/null
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "volumedet")
- + {
- + std::string utility = (std::string)ESEGUIBILE_FFMPEG + " -i "
- + + "\"" + dati->nomefilein + "\"" + " ";
- + if ( dati->tempoin != "")
- + utility = utility + dati->tempoin + " ";
- + if ( dati->tempodur != "")
- + utility = utility + dati->tempodur + " ";
- + if ( dati->maps != "")
- + utility = utility + dati->maps + " ";
- + utility = utility + "-vn " + "-af volumedetect "
- + + FORMAT_NULL + " " + OUT_NULL;
- + printf ("\n%s\n\n", utility.c_str() );
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_showwaves (int argc, char * argv[], s_dati *dati)
- +{
- + // utility play (preview con -map -ss e -vf)
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "showwaves")
- + {
- + std::string utility;
- +
- + utility = (std::string)ESEGUIBILE_PLAY + " "
- + + "-f lavfi 'amovie="
- + + dati->nomefilein + " ";
- + if (dati->tempoin != "")
- + utility = utility + ":sp="
- + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
- + if (dati->a_filter_valore != "")
- + utility = utility + ", " + dati->a_filter_valore;
- + utility = utility + ",asplit[out0],showwaves=s=1200x800:mode=line[out1]'";
- +
- + printf ("\n%s\n\n",utility.c_str());
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +bool is_util_showspectrum (int argc, char * argv[], s_dati *dati)
- +{
- + // utility play (preview con -map -ss e -vf)
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "showspectrum")
- + {
- + std::string utility;
- +
- + utility = (std::string)ESEGUIBILE_PLAY + " "
- + + "-f lavfi 'amovie="
- + + dati->nomefilein + " ";
- + if (dati->tempoin != "")
- + utility = utility + ":sp="
- + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
- + if (dati->a_filter_valore != "")
- + utility = utility + ", " + dati->a_filter_valore;
- + utility = utility + " ,asplit [a][out1];[a] showspectrum=s=1200x800:mode=combined:color=intensity:slide=1:scale=sqrt:saturation=3 [out0]'";
- +
- + printf ("\n%s\n\n",utility.c_str());
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +
- +bool is_util_ebur128 (int argc, char * argv[], s_dati *dati)
- +{
- + // utility play (preview con -map -ss e -vf)
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "ebur128")
- + {
- + std::string utility;
- +
- + utility = (std::string)ESEGUIBILE_PLAY + " "
- + + "-f lavfi 'amovie="
- + + dati->nomefilein + " ";
- + if (dati->tempoin != "")
- + utility = utility + ":sp="
- + + dati->tempoin.substr( 4, dati->tempoin.length() ) + " "; //solo in sec es 4500
- + if (dati->a_filter_valore != "")
- + utility = utility + ", " + dati->a_filter_valore;
- + utility = utility + " ,ebur128=video=1:meter=18 [out0][out1]'";
- +
- + printf ("\n%s\n\n",utility.c_str());
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_dbcalc (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "dbcalc")
- + {
- + if ( !check_num_param (argc,i,1) )
- + {
- + printf ("\nusare: dbcalc db (20 -20)\n\n");
- + return false;
- + }
- +
- + if ( !is_number(argv[i+1]) )
- + {
- + printf ("\nusare: dbcalc db (20 -20)\n\n");
- + return false;
- + }
- +
- + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
- + double amp = atof(argv[i+1]);
- + if ( amp < -20.0 || amp > 20.0 || amp == 0.0 )
- + {
- + printf ("\nusare: dbcalc db (20 -20)\n\n");
- + return false;
- + }
- + // db to ratio
- + float f_ratio = pow (10.0, (amp/20.0) );
- + char ratio [10];
- + sprintf (ratio,"%.3f",f_ratio);
- + setlocale (LC_ALL,""); // ripristino locale
- + printf ("\n\n%.1f db = %s \n\n", amp ,ratio);
- + printf ("emempio d'uso con -af volume e timeline:\n");
- + printf ("-af \"volume=enable='between(t,0,44.95)':volume=0.5, volume=enable='gte(t,45)':volume=2\"\n\n");
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_time (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "time")
- + {
- + int start, fine, durata;
- + if ( !check_num_param (argc,i,2) )
- + {
- + printf ("\nusare: time in out (hh:mm:ss o sec)\n\n");
- + return false;
- + }
- +
- + if ( is_number(argv[i+1]) )
- + start = atoi(argv[i+1]);
- + else
- + start = ConvStdTimeToSec ( std::string(argv[i+1]) );
- +
- + if ( is_number(argv[i+2]) )
- + fine = atoi(argv[i+2]);
- + else
- + fine = ConvStdTimeToSec ( std::string(argv[i+2]) );
- +
- + durata = fine - start;
- + if (durata <=0)
- + {
- + printf ("\nla durata risulta 0 o minore.\nUsare: time in out (hh:mm:ss o sec)\n\n");
- + return false;
- + }
- + printf("\n-ss %i -t %i\n\n",start,durata);
- + return false;
- + }
- + }
- + return true;
- +}
- diff -Naur -x '*~' src/routines/r-util.h /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.h
- --- src/routines/r-util.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util.h 2013-09-28 15:30:12.826249914 +0200
- @@ -0,0 +1,20 @@
- +#ifndef R_UTIL_H
- +#define R_UTIL_H
- +
- +bool is_util_mkvinfo (int argc, char * argv[], s_dati *dati);
- +bool is_util_mkvmerge (int argc, char * argv[], s_dati *dati);
- +bool is_util_play (int argc, char * argv[], s_dati *dati);
- +bool is_util_probe (int argc, char * argv[], s_dati *dati);
- +bool is_util_help_filter (int argc, char * argv[]);
- +bool is_util_vftest (int argc, char * argv[], s_dati *dati);
- +bool is_util_vftestsp (int argc, char * argv[], s_dati *dati);
- +bool is_util_calc_scale (int argc, char * argv[]);
- +bool is_muxer (int argc, char * argv[], s_dati *dati);
- +bool is_util_volumedetect (int argc, char * argv[], s_dati *dati);
- +bool is_util_showwaves (int argc, char * argv[], s_dati *dati);
- +bool is_util_showspectrum (int argc, char * argv[], s_dati *dati);
- +bool is_util_ebur128 (int argc, char * argv[], s_dati *dati);
- +bool is_util_dbcalc (int argc, char * argv[], s_dati *dati);
- +bool is_util_time (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- 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
- --- src/routines/r-util-sox.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.cpp 2013-09-02 13:52:54.136003052 +0200
- @@ -0,0 +1,188 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-util-sox.h"
- +
- +void sox_help (std::string nome_del_file)
- +{
- + printf ("\nUsare: sox norm | comp | compf | fastdet | compfast [noshow mux]\n");
- + printf ("noshow: non mostra sox progress\n");
- + printf ("mux: muxa il file %s\n\n", nome_del_file.c_str() );
- +}
- +
- +bool is_util_sox (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "sox")
- + {
- + time_t now;
- + double seconds, durata;
- + std::string sox_effect;
- + std::string sox_show ("-S");
- + std::string nuovo_nome_file_out_mka = check_fileout_name_e_rename ( dati->nome_file_senza_ext, ((std::string)"_SOX_" + NUOVA_EXT_MKA) );
- + std::string nuovo_nome_file_out_mux = check_fileout_name_e_rename ( dati->nome_file_senza_ext, ((std::string)"_MUX_" + NUOVA_EXT_MKV) );
- + std::string daeseguire ("");
- + std::string daeseguire_test ("");
- + bool is_test (false);
- + int prossimo = 2;
- +
- + if ( !check_num_param (argc,i,1) )
- + {
- + sox_help (nuovo_nome_file_out_mux);
- + return false;
- + }
- +
- + if (
- + dati->audio_parm == AUDIO_PARM_NONE
- + || dati->audio_parm == AUDIO_PARM_COPY
- + || dati->vcodec == VCODEC_COPY_ALL
- + )
- + {
- + printf ("\n\nsox è incompatibile con -an -acopy e -copy\n\n");
- + return false;
- + }
- +
- + if ( std::string(argv[i+1]) == "norm" )
- + sox_effect = SOX_NORM;
- + else if ( std::string(argv[i+1]) == "comp" )
- + sox_effect = SOX_COMPAND_STD_2;
- + else if ( std::string(argv[i+1]) == "compf" )
- + sox_effect = SOX_COMPAND_FILM_STD;
- + else if ( std::string(argv[i+1]) == "compfast" )
- + sox_effect = SOX_COMPAND_FILM_STD_NO_NORM;
- + else if ( std::string(argv[i+1]) == "fastdet" )
- + {
- + sox_effect = SOX_COMPAND_FILM_STD_NO_NORM;
- + dati->a_filter_valore = "atempo=2";
- + is_test = true;
- + }
- + else
- + {
- + sox_help (nuovo_nome_file_out_mux);
- + return false;
- + }
- +
- + if ( argc-1 >= i+prossimo )
- + {
- + for (int x=i; x<argc; x++)
- + {
- + if (std::string(argv[x]) == "noshow")
- + {
- + sox_show = "";
- + prossimo = prossimo +1;
- + break;
- + }
- + }
- + }
- +
- + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " " + "-i "
- + + "\"" + dati->nomefilein + "\"" + " ";
- + if (dati->rate != "")
- + daeseguire = daeseguire + dati->rate + " ";
- + if (dati->maps != "")
- + daeseguire = daeseguire + dati->maps + " ";
- + if (is_test)
- + daeseguire = daeseguire + "-af" + " "
- + + "\"" + dati->a_filter_valore + "\"" + " ";
- + if (dati->tempoin != "")
- + daeseguire = daeseguire + dati->tempoin + " ";
- + if (dati->tempodur != "")
- + daeseguire = daeseguire + dati->tempodur + " ";
- + daeseguire = daeseguire + "-vn -f sox - | sox "
- + + SOX_TEMP_MY_SETT + " "
- + + sox_show + " "
- + + "-t sox - -t sox -" + " "
- + + sox_effect + " | "
- + + ESEGUIBILE_FFMPEG + " -y "
- + + "-i - " + FORMAT_OUT_MATROSKA + " "
- + + dati->audio_parm + " ";
- + if ( sox_effect == SOX_COMPAND_FILM_STD_NO_NORM && !is_test )
- + {
- + if (dati->a_filter_valore != "" )
- + daeseguire = daeseguire + "-af" + " "
- + + "\"" + dati->a_filter_valore + "\"" + " ";
- + }
- + daeseguire = daeseguire+ "\"" + nuovo_nome_file_out_mka + "\"";
- + printf ("\n\n%s\n\n", daeseguire.c_str() );
- + if (is_test)
- + {
- + daeseguire_test = (std::string)ESEGUIBILE_FFMPEG + " -i "
- + + "\"" + nuovo_nome_file_out_mka + "\"" + " "
- + + "-vn " + "-af volumedetect "
- + + FORMAT_NULL + " " + OUT_NULL;
- + printf ("%s\n\n", daeseguire_test.c_str() );
- + }
- + if (! dati->debug)
- + {
- + seconds = time(&now);
- + if ( esegui(daeseguire.c_str()) !=0) return false;
- + if (is_test)
- + {
- + if ( esegui(daeseguire_test.c_str()) !=0) return false;
- + }
- + durata = difftime(time(&now),seconds);
- + dati->riepilogo = dati->riepilogo
- + + "\n\nTempo conversione audio: "
- + + str_stampatempo(durata) + "\n"
- + + str_stampa_info_file(dati->nomefilein)
- + + str_stampa_info_file(nuovo_nome_file_out_mka);
- + if (is_test)
- + {
- + if( remove( nuovo_nome_file_out_mka.c_str() ) != 0 )
- + perror( "Error deleting file" );
- + }
- + }
- +
- + if ( argc-1 >= i+prossimo )
- + {
- + for (int x=i; x<argc; x++)
- + {
- + if ( std::string(argv[x]) == "mux" )
- + {
- + // even aggiungere i param video e tempo
- + prossimo = prossimo +1;
- + daeseguire = (std::string)ESEGUIBILE_FFMPEG + " ";
- + // dovrebbe funzionare ma non è affidabile
- + if (dati->tempoin != "")
- + daeseguire = daeseguire + dati->tempoin + " ";
- + if (dati->tempodur != "")
- + daeseguire = daeseguire + dati->tempodur + " ";
- + // ----------------------------------------------
- + daeseguire = daeseguire + "-i "
- + + "\"" + dati->nomefilein + "\"" + " "
- + + "-i "
- + + "\"" + nuovo_nome_file_out_mka + "\"" + " ";
- + if (dati->maps == "")
- + daeseguire = daeseguire + "-map 0:v -map 1:a " + " ";
- + else
- + daeseguire = daeseguire + dati->maps.substr (0,8) + " "
- + + "-map 1:a " + " ";
- + //daeseguire = daeseguire + "-map 0:v -map 1:a" + " ";
- + daeseguire = daeseguire + VCODEC_COPY_ALL + " "
- + + FORMAT_OUT_MATROSKA + " "
- + + "\"" + nuovo_nome_file_out_mux + "\"";
- + printf ("%s\n\n", daeseguire.c_str() );
- + if (! dati->debug)
- + {
- + if ( esegui(daeseguire.c_str()) !=0) return false;
- + dati->riepilogo = dati->riepilogo
- + + str_stampa_info_file(nuovo_nome_file_out_mux) + "\n";
- + printf("%s",dati->riepilogo.c_str());
- + return false;
- + }
- + }
- + }
- + }
- +
- + if (! dati->debug)
- + {
- + dati->riepilogo = dati->riepilogo
- + + "\nProcessare ora il video con -an e/o muxare.\n\n";
- + printf("%s",dati->riepilogo.c_str());
- + }
- + return false;
- + }
- + }
- + return true;
- +}
- +
- 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
- --- src/routines/r-util-sox.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-util-sox.h 2013-08-26 16:17:50.632137211 +0200
- @@ -0,0 +1,25 @@
- +#ifndef R_UTIL_SOX_H
- +#define R_UTIL_SOX_H
- +
- +// attenzione che -norm e gain -n- 3 (che è la stessa cosa)
- +// consumano MOLTO spazio x film lunghi > 10GB
- +// meglio fare una passata con compfast poi fare avolumedetect sul file .mka ottenuto
- +// e rifare compfast con -avolume n dove n è determinato dal maxvol di avolumedetect -5
- +#define SOX_NORM "norm -3"
- +#define SOX_COMPAND_STD_2 "compand 0.3,1 6:-70,-40,-20 -20 -90 0.2 gain -n -3" //2:1
- +#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"
- +#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"
- +// cartella temp di sox per norm che richiede molto spazio
- +#define SOX_TEMP_DEFAULT "--temp ."
- +#define SOX_TEMP_MY_SETT "--temp /home/mc/rec/temp"
- +/*
- +old SOX_COMPAND_STD_2 ("compand 0.3,1 6:-70,-40,-20 -5 -90 0.2"); //2:1
- +std::string sox_compand_std ("compand 0.3,1 6:-70,-60,-20 -5 -90 0.2"); //3 :1
- +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");
- +std::string sox_compand_film ("compand 0.1,0.4 6:-70,-43,-20,-12,-10 -6 -80 0.1");
- +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");
- +*/
- +
- +bool is_util_sox (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- 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
- --- src/routines/r-video-asp-avi.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /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
- @@ -0,0 +1,78 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-asp-avi.h"
- +
- +bool is_mpeg4_avi_xvid (int argc, char * argv[], s_dati *dati)
- +{
- + bool is_mpeg4 = false;
- + bool is_avi = false;
- + bool is_xvid = false;
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-mpeg4")
- + {
- + is_mpeg4 = true;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + }
- + if (std::string(argv[i]) == "-avi")
- + {
- + is_avi = true;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + }
- + if (std::string(argv[i]) == "-xvid")
- + {
- + is_xvid = true;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + }
- + }
- + if (
- + is_mpeg4
- + || is_avi
- + || is_xvid
- + )
- + {
- + dati->vcodec = VCODEC_MPEG4;
- + dati->video_codec_is = VIDEO_IS_MPEG4;
- + dati->preset="";
- + dati->profile="";
- + dati->set_264="";
- + if (dati->b_v_rate == 0)
- + dati->bitrate_video = BITRATE_VIDEO_MPEG4_DEFAULT;
- + if (dati->pass == 3)
- + dati->pass = 2;
- + }
- + if ( is_xvid )
- + {
- + if ( dati->nuova_estensione == NUOVA_EXT_MP4 )
- + {
- + printf ("\nAttenzione,\n-xvid non è compatibile con il formato -mp4\n");
- + printf ("Usare -mpeg4 con il formato -mp4\n\n");
- + return false;
- + }
- + dati->vcodec = (std::string)VCODEC_MPEG4 + " " + XVID_TAG;
- + dati->video_codec_is = VIDEO_IS_MPEG4_XVID;
- + }
- + if (is_avi)
- + {
- + // check -mp4
- + if ( dati->nuova_estensione == NUOVA_EXT_MP4 )
- + {
- + printf ("\nAttenzione,\nè stato selezionato anche il formato -mp4 insieme ad -avi -xvid\n");
- + printf ("Verificare i parametri inseriti.\n\n");
- + return false;
- + }
- + // audio avi - no aac no aac+ solo mp3
- + if ( (dati->audio_codec_is != AUDIO_IS_LAME)
- + && (dati->audio_codec_is != "")
- + )
- + {
- + dati->audio_parm = AUDIO_PARM_LAME_C128;
- + dati->audio_codec_is = AUDIO_IS_LAME;
- + }
- + dati->format_out = FORMAT_OUT_AVI;
- + dati->nuova_estensione = NUOVA_EXT_AVI;
- + }
- +
- + return true;
- +}
- +
- 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
- --- src/routines/r-video-asp-avi.h 1970-01-01 01:00:00.000000000 +0100
- +++ /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
- @@ -0,0 +1,8 @@
- +#ifndef R_VIDEO_ASP_AVI_H
- +#define R_VIDEO_ASP_AVI_H
- +
- +bool is_mpeg4_avi_xvid
- + (int argc, char * argv[], s_dati *dati);
- +
- +
- +#endif
- 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
- --- src/routines/r-video-generali.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.cpp 2013-11-10 16:15:26.510972234 +0100
- @@ -0,0 +1,214 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-generali.h"
- +
- +bool passate (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-pass")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + dati->pass = atoi(argv[i+1]);
- + // check
- + if (dati->pass < 1 || dati->pass >3)
- + {
- + printf ("\nInserire -pass 2 o 3.\n");
- + return false;
- + }
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool frame_rate (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-r")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + if ( is_number(argv[i+1]) )
- + {
- + dati->rate = "-r " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + else
- + {
- + printf("\nInserire un frame rate corretto.\n\n");
- + return false;
- + }
- + }
- + }
- + return true;
- +}
- +
- +bool video_bit_rate (int argc, char * argv[], s_dati *dati)
- +{
- + // bitrate in k, es: -b 500 altimenti 730k
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-b")
- + {
- + if ( !check_num_param (argc,i,1) )
- + {
- + printf ("\nInserire un bitrate video corretto.\n\n");
- + return false;
- + }
- + // check argomento 300 to 4000
- + dati->b_v_rate = atoi(argv[i+1]);
- + if ( dati->b_v_rate < 300 || dati->b_v_rate > 4000)
- + {
- + printf ("\nInserire un bitrate video corretto.\n\n");
- + return false;
- + }
- + // fine check
- + char temp [6];
- + sprintf(temp,"%i",dati->b_v_rate);
- + dati->bitrate_video = "-b:v " + (std::string)temp + "k";
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_crf (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- +
- + if (std::string(argv[i]) == "-crf")
- + {
- + setlocale (LC_ALL,"C"); // altrimenti , invece di . nei decimali
- + float qcrf (19.0); //default -crf 19
- + if ( argc-1 >= i+1 )
- + {
- + if ( is_number( argv[i+1]) )
- + {
- + qcrf = atof(argv[i+1]);
- + if ( qcrf < 0 || qcrf > 50)
- + {
- + printf ("\nInserire un valore crf corretto (0.0-50.0).\n\n");
- + return false;
- + }
- + }
- + }
- + char qfact [10];
- + sprintf (qfact,"%.1f",qcrf);
- + setlocale (LC_ALL,""); // ripristino locale
- + std::string crfval = "-crf " + (std::string)qfact;
- + if (dati->video_codec_is == VIDEO_IS_X_264)
- + {
- + dati->pass = 1;
- + dati->bitrate_video = (std::string)crfval;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + }
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_mp4_out (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-mp4")
- + {
- + dati->format_out = FORMAT_OUT_MP4;
- + dati->nuova_estensione = NUOVA_EXT_MP4;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_aspect (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-aspect")
- + {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + dati->aspetto = "-aspect " + std::string(argv[i+1]);
- + dati->param_tot_previsti = dati->param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +
- +void is_vcopy_copy (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-vcopy")
- + {
- + dati->vcodec = VCODEC_VCOPY;
- + dati->video_codec_is = "";
- + // azzeramento altri paramentri video
- + dati->rate="";
- + dati->preset="";
- + dati->profile="";
- + dati->set_264="";
- + dati->bitrate_video="";
- + dati->filter="";
- + dati->pass=1;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-copy")
- + {
- + dati->vcodec = VCODEC_COPY_ALL;
- + dati->video_codec_is = "";
- + // azzeramento altri paramentri video e audio
- + dati->rate="";
- + dati->preset="";
- + dati->profile="";
- + dati->set_264="";
- + dati->bitrate_video="";
- + dati->filter="";
- + dati->a_filter_valore="";
- + dati->pass=1;
- + if (dati->audio_parm != AUDIO_PARM_NONE )
- + dati->audio_parm="";
- + dati->audio_codec_is = "";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-vn")
- + {
- + dati->vcodec = VCODEC_NONE;
- + dati->video_codec_is = "";
- + // azzeramento altri paramentri video e audio
- + dati->rate="";
- + dati->preset="";
- + dati->profile="";
- + dati->set_264="";
- + dati->bitrate_video="";
- + dati->filter="";
- + dati->pass=1;
- + dati->format_out = FORMAT_OUT_MATROSKA;
- + dati->nuova_estensione = NUOVA_EXT_MKA;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- 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
- --- src/routines/r-video-generali.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-generali.h 2013-11-10 16:04:15.554770404 +0100
- @@ -0,0 +1,12 @@
- +#ifndef R_VIDEO_GENERALI_H
- +#define R_VIDEO_GENERALI_H
- +
- +bool passate (int argc, char * argv[], s_dati *dati);
- +bool frame_rate (int argc, char * argv[], s_dati *dati);
- +bool video_bit_rate (int argc, char * argv[], s_dati *dati);
- +void is_mp4_out (int argc, char * argv[], s_dati *dati);
- +bool is_aspect (int argc, char * argv[], s_dati *dati);
- +void is_vcopy_copy (int argc, char * argv[], s_dati *dati);
- +bool is_crf (int argc, char * argv[], s_dati *dati);
- +
- +#endif
- 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
- --- src/routines/r-video-x264.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.cpp 2013-08-26 00:12:39.070682443 +0200
- @@ -0,0 +1,145 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-x264.h"
- +
- +void no_fast (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-nofast")
- + {
- + dati->nofastfirst = true;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_preset (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- +
- + if (std::string(argv[i]) == "-fast")
- + {
- + dati->preset = PRESET_FAST;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-medium")
- + {
- + dati->preset = PRESET_MEDIUM;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-slow")
- + {
- + dati->preset = PRESET_SLOW;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- +
- + }
- +}
- +
- +void is_profile (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-main")
- + {
- + dati->profile = PROFILE_MAIN;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-high")
- + {
- + dati->profile = PROFILE_HIGH;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- +
- + }
- +}
- +
- +void is_nopts (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-nopts")
- + {
- + dati->set_264 = OPT_264_NOPTS;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_opencl (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-opencl")
- + {
- + dati->set_264 = dati->set_264 + ":opencl";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_nr_denoise (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-nr200")
- + {
- + dati->set_264 = dati->set_264 + ":nr=200";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-nr500")
- + {
- + dati->set_264 = dati->set_264 + ":nr=500";
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_level (int argc, char * argv[], s_dati *dati)
- +{
- + for (int i=2; i<argc; i++)
- + {
- + if (std::string(argv[i]) == "-level1")
- + {
- + dati->set_264 = dati->set_264 + ":" + LEVEL_1_0;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level2")
- + {
- + dati->set_264 = dati->set_264 + ":" + LEVEL_2_0;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level3")
- + {
- + dati->set_264 = dati->set_264 + ":" + LEVEL_3_0;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level4")
- + {
- + dati->set_264 = dati->set_264 + ":" + LEVEL_4_0;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level5")
- + {
- + dati->set_264 = dati->set_264 + ":" + LEVEL_5_0;
- + dati->param_tot_previsti = dati->param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- 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
- --- src/routines/r-video-x264.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/cb-project/730-ffmpeg-tool-2/src/routines/r-video-x264.h 2013-08-23 21:28:23.000000000 +0200
- @@ -0,0 +1,12 @@
- +#ifndef R_VIDEO_X264_H
- +#define R_VIDEO_X264_H
- +
- +void no_fast (int argc, char * argv[], s_dati *dati);
- +void is_preset (int argc, char * argv[], s_dati *dati);
- +void is_profile (int argc, char * argv[], s_dati *dati);
- +void is_nopts (int argc, char * argv[], s_dati *dati);
- +void is_opencl (int argc, char * argv[], s_dati *dati);
- +void is_nr_denoise (int argc, char * argv[], s_dati *dati);
- +void is_level (int argc, char * argv[], s_dati *dati);
- +
- +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement