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/3/730-ffmpeg-tool/src/730-ffmpeg-tool-main.cpp
- --- src/730-ffmpeg-tool-main.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/730-ffmpeg-tool-main.cpp 2013-08-23 14:30:52.156955283 +0200
- @@ -0,0 +1,520 @@
- +#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"
- +
- +
- +
- +
- +const std::string versione ("p-2.38");
- +const std::string filesettaggi_version ("v1.1");
- +
- +int main(int argc, char * argv[])
- +{
- + setlocale (LC_ALL,"");
- + // eseguibile
- + std::string eseguibile (eseguibile_ffmpeg);
- + std::string estensione_file_in ("");
- + std::string nuova_estensione (nuova_estensione_mkv);
- + bool debug = false;
- + std::string rate ("");
- + std::string maps("");
- + std::string vcodec (vcodec_x264);
- + std::string video_codec_is (VIDEO_IS_X_264);
- + std::string bitrate_video (bitrate_video_x264_default);
- + int b_v_rate = 0;
- + std::string preset (preset_faster);
- + std::string profile ("");
- + std::string set_264 (opt_264_1);
- + std::string audio_parm (audio_parm_a112);
- + std::string audio_codec_is (AUDIO_IS_FDKAAC);
- + int pass = 1;
- + bool nofastfirst (0);
- + std::string filter ("");
- + std::string filtervalore (""); // per utility vftest
- + std::string a_filter ("");
- + std::string tempoin ("");
- + std::string tempodur ("");
- + std::string logfile ("");
- + std::string altro ("");
- + std::string aspetto ("");
- + std::string format_out (format_out_mkv);
- + std::string nuovo_nome_file_out ("");
- + // stringa finale daeseguire
- + std::string daeseguire ("");
- + // variabili cronometri
- + time_t now;
- + double seconds, seconds2start, seconds3start;
- + double durata, durata1, durata2, durata3;
- + //
- +
- + // 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
- + const std::string nomefilein (argv[1]);
- + std::string verifica = nomefilein.substr ( (nomefilein.length() -1) ,1);
- + if (verifica == "/"){
- + printf ("\nAttenzione: %s è una cartella.\n\n", nomefilein.c_str() );
- + return 1;
- + }
- + // nome del file senza path
- + const std::string nomedelfile ( rimuovi_path(nomefilein) );
- + // estensione del file
- + estensione_file_in = tipo_ext (nomedelfile);
- + // nome del file senza ext
- + std::string nome_file_senza_ext ( removeExtension (nomedelfile.c_str()) );
- +
- + // check se il file input esiste
- + if ( !fileExists (nomefilein.c_str()) ){
- + printf ("\nIl file: %s non esiste.\n\n", nomefilein.c_str() );
- + return 1;
- + }
- +
- + // check minimale sul numero parametri immessi
- + int param_tot_previsti = 2;
- +
- +
- + // debug stampa solo i comandi senza eseguirli
- + isdebug (argc, argv, ¶m_tot_previsti, &debug);
- +
- +
- + // frame rate, -r 25
- + if ( !frame_rate (argc, argv, ¶m_tot_previsti, &rate) )
- + return 1;
- +
- +
- + // -map (multipli) es -map 0:0 -map 0:1
- + if ( !is_map (argc, argv, ¶m_tot_previsti, &maps) )
- + return 1;
- +
- +
- + // bitrate in k, es: -b 500 altimenti 730k
- + if ( !video_bit_rate (argc, argv, ¶m_tot_previsti, &b_v_rate, &bitrate_video) )
- + return 1;
- +
- +
- + // parametri video: default preset="-preset faster -tune film"
- + // -fast -medium -slow
- + is_preset (argc, argv, ¶m_tot_previsti, &preset);
- +
- +
- + // profile: -main -high, default auto
- + is_profile (argc, argv, ¶m_tot_previsti, &profile);
- +
- +
- + // opts264
- + // -nopts = parametri del preset senza tuning personale
- + is_nopts (argc, argv, ¶m_tot_previsti, &set_264);
- +
- +
- + // opencl lookahead
- + // -opencl
- + is_opencl (argc, argv, ¶m_tot_previsti, &set_264);
- +
- +
- + // -nr x264 fastdenoise da 100 a 1000 -nr200 -nr500
- + // non usare se usate -vf |denoiser|
- + is_nr_denoise (argc, argv, ¶m_tot_previsti, &set_264);
- +
- +
- + // -level1 to 5, default auto
- + is_level (argc, argv, ¶m_tot_previsti, &set_264);
- +
- +
- + // -10bit = x264 10 bit depth
- + is_10bit (argc, argv, ¶m_tot_previsti, &eseguibile);
- +
- + // eventualmente implementare -af audio filter
- +
- + // -avolume -20 20
- + if ( !is_avolume (argc, argv, ¶m_tot_previsti, &a_filter) )
- + return 1;
- +
- + // audio
- + // -a32 -a64 -a96 -a128 -acopy -an
- + // -alameq 0-9
- + // -alameb 32-320 (K)
- + if ( !is_audio (argc, argv, ¶m_tot_previsti, &audio_parm, &audio_codec_is, &a_filter) )
- + return 1;
- +
- + // -aboost // solo per fdk_aac - dopo avi altrimenti i confronti audio_parm non funzionano
- + is_aboost (argc, argv, ¶m_tot_previsti, &audio_parm, &audio_codec_is);
- +
- + // -pass passate 1,2 o 3 (3 solo x264)
- + if ( !passate (argc, argv , ¶m_tot_previsti, &pass) )
- + return 1;
- +
- +
- + // -nofast -fastfirstpass 0
- + no_fast (argc, argv, ¶m_tot_previsti, &nofastfirst);
- +
- +
- + // filtri -vf deshake,pp=ac/al
- + if ( !is_filter (argc, argv, ¶m_tot_previsti, &filter, &filtervalore) )
- + return 1;
- +
- +
- + // tempo start e durata, esempio -ss 00:03:00 -t 00:05:00 oppure -ss 120 -t 60
- + // -ss
- + if ( !is_ss_is_t (argc, argv, ¶m_tot_previsti, &tempoin, &tempodur) )
- + return 1;
- +
- +
- + // -log logfile ffmpeg
- + is_log (argc, argv, ¶m_tot_previsti, &logfile);
- +
- +
- + // -mp4 .mp4
- + is_mp4_out (argc, argv, ¶m_tot_previsti, &format_out, &nuova_estensione);
- +
- +
- + // -mpeg4
- + // -avi
- + // -xvid
- + if ( !is_mpeg4_avi_xvid
- + (argc, argv,
- + ¶m_tot_previsti,
- + &vcodec,
- + &preset,
- + &profile,
- + &set_264,
- + &b_v_rate,
- + &bitrate_video,
- + &pass,
- + &nuova_estensione,
- + &audio_parm,
- + &format_out,
- + &audio_codec_is,
- + &video_codec_is)
- + )
- + return 1;
- +
- +
- + //// altri parametri
- + // -nometa -map_metadata -1
- + // -scopy -c:s copy subtitles
- + is_altro (argc, argv, ¶m_tot_previsti, &altro);
- +
- +
- + // -vcopy = -c:v copy
- + // -copy = -c copy
- + is_vcopy_copy (argc, argv,
- + ¶m_tot_previsti,
- + &vcodec,
- + &rate,
- + &preset,
- + &profile,
- + &set_264,
- + &bitrate_video,
- + &filter,
- + &pass,
- + &audio_parm,
- + &a_filter,
- + &video_codec_is,
- + &audio_codec_is);
- +
- +
- + // -aspect 4:3 16/9 (da usare solo con video copy,
- + // se codificate -vf setdar=16/9)
- + if ( !is_aspect (argc, argv, ¶m_tot_previsti, &aspetto) )
- + 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, nomefilein, nomedelfile, &estensione_file_in) )
- + return 0;
- +
- + // utility mgm (mkvmerge gui)
- + if ( !is_util_mkvmerge (argc, argv, nomefilein, nomedelfile, &estensione_file_in) )
- + return 0;
- +
- + // utility probe
- + if ( !is_util_probe (argc, argv, nomefilein) )
- + return 0;
- +
- +
- + // utility play (preview con -map -ss e -vf)
- + if ( !is_util_play (argc, argv,
- + nomefilein,
- + &filter,
- + &tempoin,
- + &maps)
- + )
- + 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,
- + nomefilein,
- + &filtervalore,
- + &tempoin)
- + )
- + return 0;
- +
- + // utility vftestsp video split
- + if ( !is_util_vftestsp (argc, argv,
- + nomefilein,
- + &filtervalore,
- + &tempoin)
- + )
- + return 0;
- +
- + // utility calcola scala proporzionale
- + // calc 720 0 16 9 o calc 0 480 4 3
- + if ( !is_util_calc_scale (argc, argv) )
- + return 0;
- +
- +
- + // utility scrivi leggi settaggi su file
- + // save | load nomefile (con o senza .estensione e senza spazi)
- + if ( !is_load_save (argc, argv,
- + ¶m_tot_previsti,
- + filesettaggi_version,
- + &maps,
- + &bitrate_video,
- + &filter,
- + &set_264,
- + &preset,
- + &pass,
- + &audio_parm,
- + &format_out,
- + &vcodec,
- + &nuova_estensione)
- + )
- + return 0;
- +
- + // utility
- + // muxer nomefile2audio
- + if ( !is_muxer (argc, argv,
- + nomefilein,
- + &nome_file_senza_ext,
- + &maps,
- + &tempodur,
- + &debug)
- + )
- + return 0;
- +
- + // utility
- + // volumedet = -af volumedetect
- + if ( !is_util_volumedetect (argc, argv,
- + nomefilein,
- + &tempoin,
- + &tempodur,
- + &maps)
- + )
- + return 0;
- +
- + // sox
- + if (! is_util_sox (argc, argv,
- + nomefilein,
- + &nome_file_senza_ext,
- + &audio_parm,
- + &vcodec,
- + &rate,
- + &maps,
- + &tempoin,
- + &tempodur,
- + &debug)
- + )
- + return 0;
- +
- +
- + // nome fileout
- + // check se fileout esiste e nel caso rinomina _N_.ext
- + nuovo_nome_file_out = check_fileout_name_e_rename (nome_file_senza_ext, nuova_estensione);
- +
- + //
- +
- + printf ("\n");
- +
- + // check parametri totali in input
- + if (param_tot_previsti > argc){
- + debug = true;
- + printf ("\n\nVerificare i parametri inseriti:\n");
- + printf ("Immessi %i, previsti %i\n\n",argc, param_tot_previsti);
- + }
- +
- +
- + // esecuzione
- +
- + for (int i=1; i<=pass; i++) {
- +
- + daeseguire = (eseguibile + " ");
- + if (logfile != "")
- + daeseguire = daeseguire +logfile + " ";
- + if (
- + (pass==2 && i==1)
- + || (pass==3 && (i==1 || i==2))
- + )
- + daeseguire = daeseguire + "-y ";
- + daeseguire = daeseguire + "-i "
- + + "\"" + nomefilein + "\"" + " ";
- + if (rate != "")
- + daeseguire = daeseguire + rate + " ";
- + if (maps!= "")
- + daeseguire = daeseguire + maps + " ";
- + if (tempoin != "")
- + daeseguire = daeseguire + tempoin + " ";
- + if (tempodur != "")
- + daeseguire = daeseguire + tempodur + " ";
- + if (filter != "")
- + daeseguire = daeseguire + filter + " ";
- + if (vcodec != "")
- + daeseguire = daeseguire + vcodec + " ";
- + if (video_codec_is == VIDEO_IS_X_264) {
- + if (preset != "")
- + daeseguire = daeseguire + preset + " ";
- + if (profile != "")
- + daeseguire = daeseguire + profile + " ";
- + if (set_264 != "")
- + daeseguire = daeseguire + set_264 + " ";
- + }
- + if (bitrate_video != "")
- + daeseguire = daeseguire + bitrate_video + " ";
- + if (pass>=2 && i==1) {
- + daeseguire = daeseguire + "-pass 1" + " ";
- + if ( (nofastfirst == 0) && (video_codec_is == VIDEO_IS_X_264) )
- + daeseguire = daeseguire + fast_1pass + " ";
- + }
- + if (
- + (pass==2 && i==2)
- + || (pass==3 && i==3)
- + )
- + daeseguire = daeseguire + "-pass 2" + " ";
- + if (pass==3 && i==2)
- + daeseguire = daeseguire + "-pass 3" + " ";
- + if (
- + (pass==2 && i==1)
- + || (pass==3 && (i==1 || i==2))
- + )
- + daeseguire = daeseguire + audio_parm_none + " " + format_null + " " + out_null;
- + if (
- + pass==1
- + || (pass==2 && i==2)
- + || (pass==3 && i==3)
- + ){
- + if (a_filter != "")
- + daeseguire = daeseguire + a_filter + " ";
- + if (audio_parm != "")
- + daeseguire = daeseguire + audio_parm + " ";
- + daeseguire = (daeseguire + format_out + " ");
- + if (altro != "")
- + daeseguire = daeseguire + altro + " ";
- + if ( (video_codec_is != VIDEO_IS_X_264) && (aspetto != "") )
- + daeseguire = daeseguire + aspetto + " ";
- + daeseguire = daeseguire + "\"" + nuovo_nome_file_out + "\"";
- + }
- +
- +
- + if (!debug)
- + printf ("\n\n");
- +
- + printf ("%s\n\n", daeseguire.c_str());
- +
- +
- + if (!debug){
- + if (i==1) {
- +
- + seconds = time(&now);
- + if ( esegui(daeseguire.c_str()) !=0) return 1;
- + durata1 = difftime(time(&now),seconds);
- +
- + }
- +
- + if (i==2) {
- +
- + seconds2start = time(&now);
- + if (esegui (daeseguire.c_str()) !=0) return 1;
- + durata2 = difftime(time(&now),seconds2start);
- +
- + }
- +
- + if (i==3) {
- +
- + seconds3start = time(&now);
- + if ( esegui(daeseguire.c_str()) !=0) return 1;
- + 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 ( (pass>1) && (!debug) ){
- + if( remove( "ffmpeg2pass-0.log" ) != 0 )
- + perror( "Error deleting file" );
- + if (vcodec == vcodec_x264){
- + if( remove( "ffmpeg2pass-0.log.mbtree" ) != 0 )
- + perror( "Error deleting file" );
- + }
- + }
- +
- +
- + // stampa i cronometri
- + if (!debug) {
- + printf ("\n\nTempo conversione: ");
- + stampatempo (durata);
- + if ((pass==2) || (pass==3)){
- + printf ("\nPass 1: ");
- + stampatempo (durata1);
- + printf ("Pass 2: ");
- + stampatempo (durata2);
- + }
- + if (pass==3){
- + printf ("Pass 3: ");
- + stampatempo (durata3);
- + }
- + printf ("\n");
- + }
- +
- + // stampa le dimensioni in MB e data dei file in e out
- + if (!debug) {
- + stampa_info_file (nomefilein);
- + stampa_info_file (nuovo_nome_file_out);
- + }
- +
- + return 0;
- +}
- +
- +
- +
- +
- diff -Naur -x '*~' src/f-help.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/f-help.cpp
- --- src/f-help.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/f-help.cpp 2013-08-23 14:44:45.517071929 +0200
- @@ -0,0 +1,69 @@
- +#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 (" -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 (" -alameq 0-9 (lame vbr da 0 a 9, 5 ~ 130k, 6 ~ 115k)\n");
- + printf (" -alameb 32-320 (lame cbr da 32 a 320k)\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 (" -vcopy (-c:v copy, default no)\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 (" -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 (" 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 (statiche sul livello dell'audio, supporta -map -t -ss)\n");
- + printf (" sox norm | comp | compf [noshow mux]\n");
- + printf (" (usa sox per normalizzare | compand l'audio in un file .mka.\n");
- + printf (" validi i set audio -t -ss e -map, noshow sox progress.\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 ("\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/3/730-ffmpeg-tool/src/funzioni.cpp
- --- src/funzioni.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.cpp 2013-08-23 14:31:26.271344809 +0200
- @@ -0,0 +1,229 @@
- +#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 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;
- + }
- + 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;
- + }
- + 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 );
- + }
- + 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 );
- + }
- + 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() );
- +}
- +
- +////
- +
- +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);
- +}
- +
- +////
- diff -Naur -x '*~' src/funzioni.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.h
- --- src/funzioni.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/funzioni.h 2013-08-21 03:34:09.285011885 +0200
- @@ -0,0 +1,34 @@
- +#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>
- +#endif
- +
- +////
- +void 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);
- +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);
- +////
- +void stampa_help(char * testo);
- +////
- +#endif
- diff -Naur -x '*~' src/main.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/main.h
- --- src/main.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/main.h 2013-08-21 17:28:23.595559625 +0200
- @@ -0,0 +1,73 @@
- +#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>
- +#endif
- +
- +// eseguibile ffmpeg
- +const std::string eseguibile_ffmpeg ("ffmpeg2");
- +// eseguibile 10bit
- +const std::string eseguibile10bit ("ffmpeg-x10bit");
- +// eseguibile play
- +const std::string eseguibileplay ("ffplay2");
- +// eseguibile probe
- +const std::string eseguibileprobe ("ffprobe2");
- +// eseguibile mkvinfo
- +const std::string eseguibilemkvinfo ("mkvinfo-gui -g");
- +// default e opzioni
- +const std::string nuova_estensione_avi (".avi");
- +const std::string nuova_estensione_mp4 (".mp4");
- +const std::string nuova_estensione_mkv (".mkv");
- +const std::string vcodec_x264 ("-c:v libx264");
- +const std::string vcodec_mpeg4 ("-c:v mpeg4 -mpv_flags strict_gop");
- +const std::string vcodec_vcopy ("-c:v copy");
- +const std::string vcodec_copy ("-c copy");
- +const std::string xvid_tag ("-vtag XVID");
- +const std::string VIDEO_IS_X_264 ("video_is_x_264");
- +const std::string VIDEO_IS_MPEG4 ("video_is_mpeg4");
- +const std::string VIDEO_IS_MPEG4_XVID ("video_is_mpeg4_xvid");
- +const std::string bitrate_video_x264_default ("-b:v 730k");
- +const std::string bitrate_video_mpeg4_default ("-b:v 1500k");
- +const std::string preset_faster ("-preset faster -tune film");
- +const std::string preset_fast ("-preset fast -tune film");
- +const std::string preset_medium ("-preset medium -tune film");
- +const std::string preset_slow ("-preset slow -tune film");
- +const std::string profile_main ("-profile:v main");
- +const std::string profile_high ("-profile:v high");
- +const std::string opt_264_1 ("-x264opts ref=4:bframes=4:direct=auto:aq-strength=1.3:ssim");
- +const std::string set_264_nopts ("-x264opts ssim");
- +const std::string livello1 ("level=1.0:ref=1:bframes=0:vbv-bufsize=218:vbv-maxrate=80");
- +const std::string livello2 ("level=2.0:ref=2:b-pyramid=none:vbv-bufsize=2500:vbv-maxrate=2500");
- +const std::string livello3 ("level=3.0:vbv-bufsize=12500:vbv-maxrate=12500");
- +const std::string livello4 ("level=4.0:vbv-bufsize=25000:vbv-maxrate=20000");
- +const std::string livello5 ("level=5.0:vbv-bufsize=168750:vbv-maxrate=168750");
- +const std::string audio_parm_a32 ("-c:a libaacplus -b:a 32k -ar 48k -ac 2");
- +const std::string audio_parm_a64 ("-c:a libaacplus -b:a 64k -ar 48k -ac 2");
- +const std::string audio_parm_a96 ("-c:a libfdk_aac -b:a 96k -ar 48k -ac 2");
- +const std::string audio_parm_a112 ("-c:a libfdk_aac -b:a 112k -ar 48k -ac 2");
- +const std::string audio_parm_a128 ("-c:a libfdk_aac -b:a 128k -ar 48k -ac 2");
- +const std::string audio_parm_copy ("-c:a copy");
- +const std::string audio_parm_none ("-an");
- +const std::string audio_parm_lame ("-c:a libmp3lame -b:a 128k -ar 48k -ac 2");
- +const std::string audio_boost ("-afterburner 1"); // solo per fdk_aac
- +const std::string AUDIO_IS_LAME ("audio_is_lame");
- +const std::string AUDIO_IS_FDKAAC ("audio_is_fdkaac");
- +const std::string AUDIO_IS_AACPLUS ("audio_is_aacplus");
- +const std::string filesettaggi_ext (".fftlset");
- +const std::string format_null ("-f null");
- +const std::string fast_1pass ( "-fastfirstpass 1");
- +const std::string format_out_avi ("-f avi");
- +const std::string format_out_mp4 ("-f mp4");
- +const std::string format_out_mkv ("-f matroska");
- +const std::string out_null ("/dev/null"); // linux
- +
- +#endif
- +
- diff -Naur -x '*~' src/makefile /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/makefile
- --- src/makefile 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/makefile 2013-08-21 13:41:16.000000000 +0200
- @@ -0,0 +1,19 @@
- +all:
- + g++ -O3 -o 730-ffmpeg-tool \
- + 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 \
- + 730-ffmpeg-tool-main.cpp -s
- +
- +
- +clean:
- + rm -f *.o *.a *~ routines/*.o routines/*~ 730-ffmpeg-tool
- +
- +
- diff -Naur -x '*~' src/routines/r-audio.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.cpp
- --- src/routines/r-audio.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.cpp 2013-08-22 16:21:39.137170592 +0200
- @@ -0,0 +1,125 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-audio.h"
- +
- +bool is_audio (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is, std::string *a_filter)
- +{
- + // audio
- + // -a32 -a64 -a96 -a128 -acopy -an
- + // -alameq 0-9
- + for (int i=2; i<argc; i++) {
- +
- + if (std::string(argv[i]) == "-a32") {
- + *audio_parm = audio_parm_a32;
- + *audio_codec_is = AUDIO_IS_AACPLUS;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a64") {
- + *audio_parm = audio_parm_a64;
- + *audio_codec_is = AUDIO_IS_AACPLUS;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a96") {
- + *audio_parm = audio_parm_a96;
- + *audio_codec_is = AUDIO_IS_FDKAAC;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-a128") {
- + *audio_parm = audio_parm_a128;
- + *audio_codec_is = AUDIO_IS_FDKAAC;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-acopy") {
- + *audio_parm = audio_parm_copy;
- + *audio_codec_is = "";
- + *a_filter = "";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-an") {
- + *audio_parm = audio_parm_none;
- + *audio_codec_is = "";
- + *a_filter = "";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-alameq") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + // check argomento 0 to 9
- + int q = atoi(argv[i+1]);
- + if ( q < 0 || q > 9) {
- + printf ("\nInserire un q corretto (0-9).\n");
- + return false;
- + }
- + std::string audio_parm_lameq = "-c:a libmp3lame -q:a " + std::string(argv[i+1]) + " -ar 48k -ac 2";
- + *audio_parm = audio_parm_lameq;
- + *audio_codec_is = AUDIO_IS_LAME;
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + if (std::string(argv[i]) == "-alameb") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + // check argomento 32 to 320
- + int ba = atoi(argv[i+1]);
- + if ( ba < 32 || ba > 320) {
- + printf ("\nInserire un bitrate audio corretto (32-320).\n");
- + return false;
- + }
- + std::string audio_parm_lameb = "-c:a libmp3lame -b:a " + std::string(argv[i+1]) + "k -ar 48k -ac 2";
- + *audio_parm = audio_parm_lameb;
- + *audio_codec_is = AUDIO_IS_LAME;
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_aboost (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is)
- +{
- + // -aboost // solo per fdk_aac
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-aboost"){
- + // solo audio fdk_aac
- + if ( *audio_codec_is == AUDIO_IS_FDKAAC ){
- + *audio_parm = *audio_parm + " " + audio_boost;
- + *param_tot_previsti = *param_tot_previsti +1;
- + }
- + break;
- + }
- + }
- +}
- +
- +bool is_avolume (int argc, char * argv[], int *param_tot_previsti, std::string *a_filter)
- +{
- + 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 corretto (da -20 a 20).\n");
- + printf ("Usare: volumedet per stabilirlo.\n");
- + return false;
- + }
- + int amp = atoi(argv[i+1]);
- + if ( amp < -20 || amp > 20) {
- + printf ("\nInserire un fattore di amplificazione corretto (da -20 a 20).\n");
- + printf ("Usare: volumedet per stabilirlo.\n");
- + return false;
- + }
- + if ( *a_filter == "" )
- + *a_filter = "-af volume=volume=" + std::string(argv[i+1]) + "dB:precision=fixed";
- + else
- + *a_filter = *a_filter + "," + "-af volume=volume=" + std::string(argv[i+1]) + "15dB:precision=fixed";
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +
- diff -Naur -x '*~' src/routines/r-audio.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.h
- --- src/routines/r-audio.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-audio.h 2013-08-22 16:04:27.507157986 +0200
- @@ -0,0 +1,8 @@
- +#ifndef R_AUDIO_H
- +#define R_AUDIO_H
- +
- +bool is_audio (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is, std::string *a_filter );
- +void is_aboost (int argc, char * argv[], int *param_tot_previsti, std::string *audio_parm, std::string *audio_codec_is);
- +bool is_avolume (int argc, char * argv[], int *param_tot_previsti, std::string *a_filter);
- +
- +#endif
- diff -Naur -x '*~' src/routines/r-file-sett.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.cpp
- --- src/routines/r-file-sett.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.cpp 2013-08-21 04:25:15.137351238 +0200
- @@ -0,0 +1,102 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-file-sett.h"
- +
- +bool is_load_save (int argc, char * argv[],
- + int *param_tot_previsti,
- + const std::string filesettaggi_version,
- + std::string *maps,
- + std::string *bitrate_video,
- + std::string *filter,
- + std::string *set_264,
- + std::string *preset,
- + int *pass,
- + std::string *audio_parm,
- + std::string *format_out,
- + std::string *vcodec,
- + std::string *nuova_estensione)
- +{
- + // 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;
- + *param_tot_previsti = *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 , filesettaggi_version);
- + scrivi_str_su_file (pFile , *maps);
- + scrivi_str_su_file (pFile , *bitrate_video);
- + scrivi_str_su_file (pFile , *filter);
- + scrivi_str_su_file (pFile , *set_264);
- + scrivi_str_su_file (pFile , *preset);
- + scrivi_int_su_file (pFile , *pass);
- + scrivi_str_su_file (pFile , *audio_parm);
- + scrivi_str_su_file (pFile , *format_out);
- + scrivi_str_su_file (pFile , *vcodec);
- + scrivi_str_su_file (pFile , *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 != filesettaggi_version){
- + fclose (pFile);
- + printf ("\nIl file: %s non è compatibile con questa versione.\n\n",nomefilesettaggi.c_str() );
- + return false;
- + }
- +
- + *maps = leggi_str_da_file (pFile);
- + *bitrate_video = leggi_str_da_file (pFile);
- + *filter = leggi_str_da_file (pFile);
- + *set_264 = leggi_str_da_file (pFile);
- + *preset = leggi_str_da_file (pFile);
- + *pass = leggi_int_da_file (pFile); // pass è int
- + *audio_parm = leggi_str_da_file (pFile);
- + *format_out = leggi_str_da_file (pFile);
- + *vcodec = leggi_str_da_file (pFile);
- + *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/3/730-ffmpeg-tool/src/routines/r-file-sett.h
- --- src/routines/r-file-sett.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-file-sett.h 2013-08-21 04:25:15.050682055 +0200
- @@ -0,0 +1,19 @@
- +#ifndef R_FILE_SETT_H
- +#define R_FILE_SETT_H
- +
- +bool is_load_save (int argc, char * argv[],
- + int *param_tot_previsti,
- + std::string filesettaggi_version,
- + std::string *maps,
- + std::string *bitrate_video,
- + std::string *filter,
- + std::string *set_264,
- + std::string *preset,
- + int *pass,
- + std::string *audio_parm,
- + std::string *format_out,
- + std::string *vcodec,
- + std::string *nuova_estensione);
- +
- +
- +#endif
- diff -Naur -x '*~' src/routines/routines.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.cpp
- --- src/routines/routines.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.cpp 2013-08-21 04:25:14.927345141 +0200
- @@ -0,0 +1,119 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "routines.h"
- +
- +void isdebug (int argc, char * argv[], int *param_tot_previsti, bool *debug)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "debug") {
- + *debug = true;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_map (int argc, char * argv[], int *param_tot_previsti, std::string *maps)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-map") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + if (*maps == ""){
- + *maps = "-map " + std::string(argv[i+1]);
- + *param_tot_previsti = *param_tot_previsti +2;
- + }
- + else{
- + *maps = *maps + " -map " + std::string(argv[i+1]);
- + *param_tot_previsti = *param_tot_previsti +2;
- + }
- + i++;
- + }
- + }
- + return true;
- +}
- +
- +void is_10bit (int argc, char * argv[], int *param_tot_previsti, std::string *eseguibile)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-10bit") {
- + *eseguibile = eseguibile10bit;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_filter (int argc, char * argv[], int *param_tot_previsti, std::string *filter, std::string *filtervalore)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-vf") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + *filtervalore = std::string (argv[i+1]);
- + *filter = "-vf " + *filtervalore;
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool is_ss_is_t (int argc, char * argv[], int *param_tot_previsti, std::string *tempoin, std::string *tempodur)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-ss") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + *tempoin = "-ss " + std::string(argv[i+1]);
- + *param_tot_previsti = *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;
- + *tempodur = "-t " + std::string(argv[i+1]);
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_altro (int argc, char * argv[], int *param_tot_previsti, std::string *altro)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-nometa") {
- + *altro = "-map_metadata -1";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-scopy") {
- + if (*altro != "")
- + *altro = *altro + " -c:s copy";
- + else
- + *altro = "-c:s copy";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_log (int argc, char * argv[], int *param_tot_previsti, std::string *logfile)
- +{
- +// -log logfile ffmpeg
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-log") {
- + *logfile = "-psnr -report";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- diff -Naur -x '*~' src/routines/routines.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.h
- --- src/routines/routines.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/routines.h 2013-08-21 04:25:15.007347463 +0200
- @@ -0,0 +1,15 @@
- +#ifndef ROUTINES_H
- +#define ROUTINES_H
- +
- +void isdebug (int argc, char * argv[], int *param_tot_previsti, bool *debug);
- +bool is_map (int argc, char * argv[], int *param_tot_previsti, std::string *maps);
- +void is_10bit (int argc, char * argv[], int *param_tot_previsti, std::string *eseguibile);
- +bool is_filter (int argc, char * argv[], int *param_tot_previsti, std::string *filter, std::string *filtervalore);
- +bool is_ss_is_t (int argc, char * argv[], int *param_tot_previsti, std::string *tempoin, std::string *tempodur);
- +void is_altro (int argc, char * argv[], int *param_tot_previsti, std::string *altro);
- +void is_log (int argc, char * argv[], int *param_tot_previsti, std::string *logfile);
- +
- +#endif
- +
- +
- +
- diff -Naur -x '*~' src/routines/r-util.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.cpp
- --- src/routines/r-util.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.cpp 2013-08-23 14:41:48.455456816 +0200
- @@ -0,0 +1,304 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-util.h"
- +
- +bool is_util_mkvinfo (int argc, char * argv[], const std::string nomefilein, const std::string nomedelfile, std::string *estensione_file_in)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "mkvinfo") {
- + if (*estensione_file_in == ".mkv"){
- + std::string utility (eseguibilemkvinfo + " "
- + + "\"" + 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",nomefilein.c_str());
- + printf ("mkvextract tracks %s 2:audio.mp3\n",nomefilein.c_str());
- + printf ("mkvextract tracks %s 6:subs.srt\n\n",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", nomedelfile.c_str() );
- + return false;
- + }
- + }
- + }
- + return true;
- +}
- +
- +bool is_util_mkvmerge (int argc, char * argv[], const std::string nomefilein, const std::string nomedelfile, std::string *estensione_file_in)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "mmg") {
- + std::string mmgexe ("mmg");
- + std::string utility = mmgexe + " " + "\"" + 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[],
- + const std::string nomefilein,
- + std::string *filter,
- + std::string *tempoin,
- + std::string *maps
- + )
- +{
- + // 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 ( *maps == "" ) {
- + utility = eseguibileplay + " "
- + + "\"" + nomefilein + "\" ";
- + if (*filter != "")
- + utility = utility + *filter + " ";
- + if (*tempoin != "")
- + utility = utility + *tempoin + " ";
- + }
- + else {
- + utility = eseguibile_ffmpeg + " -i "
- + + "\"" + nomefilein + "\" "
- + + *maps + " ";
- + if ( *tempoin != "")
- + utility = utility + *tempoin + " ";
- + utility = utility + vcodec_copy + " "
- + + "-f matroska - | "
- + + eseguibileplay + " "
- + + "- ";
- + if ( *filter != "")
- + utility = utility + *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[], const std::string nomefilein)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "probe") {
- + std::string utility (eseguibileprobe + " "
- + + "\"" + nomefilein + "\""
- + );
- + 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 (eseguibile_ffmpeg + " "
- + + "-h filter=" + std::string(argv[i+1])
- + );
- + printf ("\n");
- + if ( esegui(utility.c_str()) !=0) return false;
- + return false;
- + }
- + }
- + return true;
- +}
- +
- +
- +bool is_util_vftest (int argc, char * argv[],
- + const std::string nomefilein,
- + std::string *filtervalore,
- + std::string *tempoin)
- +{
- + // utility vftest 2 video verticali
- + // filtervalore per utility vftest
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "vftest") {
- + if (*filtervalore == "") {
- + printf ("\nè necessario usare -vf filter,filter per usare vftest.\n\n" );
- + return false;
- + }
- + // 2v
- + std::string utility (eseguibileplay + " "
- + + "\"" + nomefilein + "\" "
- + + "-vf \"split[a][b]; [a]pad=iw:(ih*2)+4:color=888888 [src]; [b]"
- + + *filtervalore
- + + " [filt]; [src][filt]overlay=((main_w - w)/2):main_h/2\" "
- + );
- + if (*tempoin != "")
- + utility = utility + *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[],
- + const std::string nomefilein,
- + std::string *filtervalore,
- + std::string *tempoin)
- +{
- + // utility vftestsp video split
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "vftestsp") {
- + if (*filtervalore == "") {
- + printf ("\nè necessario usare -vf filter,filter per usare vftestsp.\n\n" );
- + return false;
- + }
- + // 2v
- + std::string utility (eseguibileplay + " "
- + + "\"" + nomefilein + "\" "
- + + "-vf \"split [main][tmp]; [tmp] crop=iw/2:ih:iw/2:0,"
- + + *filtervalore
- + + " [filter]; [main][filter] overlay=W/2:0\" "
- + );
- + if (*tempoin != "")
- + utility = utility + *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) )
- + 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[],
- + const std::string nomefilein,
- + std::string *nome_file_senza_ext,
- + std::string *maps,
- + std::string *tempodur,
- + bool *debug)
- +{
- + 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", 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_mkv;
- + std::string tipo = nuova_estensione_mkv;
- + if ( (argc-1) >= (i+2) ){
- + std::string container = (argv[i+2]);
- + if ( container == "avi"){
- + formato = format_out_avi;
- + tipo = nuova_estensione_avi;
- + }
- + else if ( container == "mp4"){
- + formato = format_out_mp4;
- + tipo = nuova_estensione_mp4;
- + }
- + }
- + tipo = "_MUXED_" + tipo;
- + std::string daeseguire;
- + std::string nuovo_nome_file_out_muxed = check_fileout_name_e_rename (*nome_file_senza_ext, tipo);
- + daeseguire = eseguibile_ffmpeg + " "
- + + "-i "+ "\"" + nomefilein + "\"" + " "
- + + "-i " + "\"" + nome_file_audio + "\"" + " ";
- + if (*maps == "")
- + daeseguire = daeseguire + "-map 0:0 -map 1:0 " + " ";
- + else
- + daeseguire = daeseguire + *maps + " ";
- + // un po inutile solo per test
- + if (*tempodur != "")
- + daeseguire = daeseguire + *tempodur + " ";
- + // -----------------------------
- + daeseguire = daeseguire + vcodec_copy + " "
- + + formato + " "
- + + + "\"" + nuovo_nome_file_out_muxed + "\"";
- + printf ("\n%s\n\n", daeseguire.c_str() );
- + if (! *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[],
- + const std::string nomefilein,
- + std::string *tempoin,
- + std::string *tempodur,
- + std::string *maps)
- +{
- + // 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 = eseguibile_ffmpeg + " -i "
- + + "\"" + nomefilein + "\"" + " ";
- + if ( *tempoin != "")
- + utility = utility + *tempoin + " ";
- + if ( *tempodur != "")
- + utility = utility + *tempodur + " ";
- + if ( *maps != "")
- + utility = utility + *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;
- +}
- diff -Naur -x '*~' src/routines/r-util.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.h
- --- src/routines/r-util.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util.h 2013-08-23 14:30:29.796263380 +0200
- @@ -0,0 +1,35 @@
- +#ifndef R_UTIL_H
- +#define R_UTIL_H
- +
- +bool is_util_mkvinfo (int argc, char * argv[], std::string nomefilein, std::string nomedelfile, std::string *estensione_file_in);
- +bool is_util_mkvmerge (int argc, char * argv[], std::string nomefilein, std::string nomedelfile, std::string *estensione_file_in);
- +bool is_util_play (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *filter,
- + std::string *tempoin,
- + std::string *maps
- + );
- +bool is_util_probe (int argc, char * argv[], std::string nomefilein);
- +bool is_util_help_filter (int argc, char * argv[]);
- +bool is_util_vftest (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *filtervalore,
- + std::string *tempoin);
- +bool is_util_vftestsp (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *filtervalore,
- + std::string *tempoin);
- +bool is_util_calc_scale (int argc, char * argv[]);
- +bool is_muxer (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *nome_file_senza_ext,
- + std::string *maps,
- + std::string *tempodur,
- + bool *debug);
- +bool is_util_volumedetect (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *tempoin,
- + std::string *tempodur,
- + std::string *maps);
- +
- +#endif
- diff -Naur -x '*~' src/routines/r-util-sox.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.cpp
- --- src/routines/r-util-sox.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.cpp 2013-08-22 20:00:11.448639365 +0200
- @@ -0,0 +1,132 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-util-sox.h"
- +
- +bool is_util_sox (int argc, char * argv[],
- + const std::string nomefilein,
- + std::string *nome_file_senza_ext,
- + std::string *audio_parm,
- + std::string *vcodec,
- + std::string *rate,
- + std::string *maps,
- + std::string *tempoin,
- + std::string *tempodur,
- + bool *debug)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "sox") {
- + time_t now;
- + double seconds, durata;
- + std::string sox_norm ("norm -3");
- + std::string sox_compand_std_2 ("compand 0.3,1 6:-70,-40,-20 -11 -90 0.2 gain -n -3"); //2:1
- + 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");
- + /*
- + 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");
- + */
- + std::string sox_effect;
- + std::string sox_show ("-S ");
- + std::string nuovo_nome_file_out_mka = check_fileout_name_e_rename (*nome_file_senza_ext, "_SOX_.mka");
- + std::string nuovo_nome_file_out_mux = check_fileout_name_e_rename (*nome_file_senza_ext, "_MUX_.mkv");
- + std::string daeseguire ("");
- + int prossimo = 2;
- + if ( !check_num_param (argc,i,1) ){
- + printf ("Usare: sox norm | comp | compf [noshow mux]\n");
- + printf ("noshow: non mostra sox progress\n");
- + printf ("mux: muxa il file %s\n\n", nuovo_nome_file_out_mux.c_str() );
- + return false;
- + }
- + if (
- + *audio_parm == audio_parm_none
- + || *audio_parm == audio_parm_copy
- + || *vcodec == vcodec_copy
- + ) {
- + 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 {
- + printf ("\n\n");
- + printf ("Usare: sox norm | comp | compf [noshow mux]\n");
- + printf ("noshow: non mostra sox progress\n");
- + printf ("mux: muxa il file %s\n\n", nuovo_nome_file_out_mux.c_str() );
- + return false;
- + }
- +
- + if ( (argc-1) >= (i+2) ){
- + if ( std::string(argv[i+2]) == "noshow" ){
- + sox_show = "";
- + prossimo = prossimo +1;
- + }
- + }
- + daeseguire = eseguibile_ffmpeg + " " + "-i "
- + + "\"" + nomefilein + "\"" + " ";
- + if (*rate != "")
- + daeseguire = daeseguire + *rate + " ";
- + if (*maps != "")
- + daeseguire = daeseguire + *maps + " ";
- + if (*tempoin != "")
- + daeseguire = daeseguire + *tempoin + " ";
- + if (*tempodur != "")
- + daeseguire = daeseguire + *tempodur + " ";
- + daeseguire = daeseguire + "-vn -f sox - | sox "
- + + sox_show + "-t sox - -t sox -" + " "
- + + sox_effect + " | "
- + + eseguibile_ffmpeg + " -y "
- + + "-i - -f matroska" + " "
- + + *audio_parm + " " +
- + + "\"" + nuovo_nome_file_out_mka + "\"";
- + printf ("\n\n%s\n\n", daeseguire.c_str() );
- + if (! *debug){
- + seconds = time(&now);
- + if ( esegui(daeseguire.c_str()) !=0) return false;
- + durata = difftime(time(&now),seconds);
- + printf ("\n\nTempo conversione: ");
- + stampatempo (durata);
- + printf ("\n");
- + stampa_info_file (nuovo_nome_file_out_mka);
- + printf ("\n");
- + }
- + if ( (argc-1) >= (i+prossimo) ){
- + if ( std::string(argv[i+prossimo]) == "mux" ){
- + // even aggiungere i param video e tempo
- + prossimo = prossimo +1;
- + daeseguire = eseguibile_ffmpeg + " "
- + + "-i "
- + + "\"" + nomefilein + "\"" + " "
- + + "-i "
- + + "\"" + nuovo_nome_file_out_mka + "\"" + " "
- + + "-map 0:0 -map 1:0 " + " "
- + + vcodec_copy + " "
- + + "-f matroska" + " "
- + + + "\"" + nuovo_nome_file_out_mux + "\"";
- + printf ("%s\n\n", daeseguire.c_str() );
- + if (! *debug){
- + if ( esegui(daeseguire.c_str()) !=0) return false;
- + printf ("\n\nTempo conversione: ");
- + stampatempo (durata);
- + printf ("\n");
- + stampa_info_file (nuovo_nome_file_out_mux);
- + printf ("\n");
- + }
- + }
- + else
- + printf ("Processare ora il video con -an e/o muxare.\n\n");
- + }
- + else
- + printf ("Processare ora il video con -an e/o muxare.\n\n");
- +
- + return false;
- + }
- + }
- + return true;
- +}
- +
- diff -Naur -x '*~' src/routines/r-util-sox.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.h
- --- src/routines/r-util-sox.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-util-sox.h 2013-08-21 04:25:15.184019259 +0200
- @@ -0,0 +1,15 @@
- +#ifndef R_UTIL_SOX_H
- +#define R_UTIL_SOX_H
- +
- +bool is_util_sox (int argc, char * argv[],
- + std::string nomefilein,
- + std::string *nome_file_senza_ext,
- + std::string *audio_parm,
- + std::string *vcodec,
- + std::string *rate,
- + std::string *maps,
- + std::string *tempoin,
- + std::string *tempodur,
- + bool *debug);
- +
- +#endif
- 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
- --- src/routines/r-video-asp-avi.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.cpp 2013-08-21 20:07:24.587579371 +0200
- @@ -0,0 +1,83 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-asp-avi.h"
- +
- +bool is_mpeg4_avi_xvid
- + (int argc, char * argv[],
- + int *param_tot_previsti,
- + std::string *vcodec,
- + std::string *preset,
- + std::string *profile,
- + std::string *set_264,
- + int *b_v_rate,
- + std::string *bitrate_video,
- + int *pass,
- + std::string *nuova_estensione,
- + std::string *audio_parm,
- + std::string *format_out,
- + std::string *audio_codec_is,
- + std::string *video_codec_is
- + )
- +{
- + 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;
- + *param_tot_previsti = *param_tot_previsti +1;
- + }
- + if (std::string(argv[i]) == "-avi") {
- + is_avi = true;
- + *param_tot_previsti = *param_tot_previsti +1;
- + }
- + if (std::string(argv[i]) == "-xvid") {
- + is_xvid = true;
- + *param_tot_previsti = *param_tot_previsti +1;
- + }
- + }
- + if (
- + is_mpeg4
- + || is_avi
- + || is_xvid
- + ){
- + *vcodec = vcodec_mpeg4;
- + *video_codec_is = VIDEO_IS_MPEG4;
- + *preset="";
- + *profile="";
- + *set_264="";
- + if (*b_v_rate == 0)
- + *bitrate_video = bitrate_video_mpeg4_default;
- + if (*pass == 3)
- + *pass = 2;
- + }
- + if ( is_xvid ){
- + if ( *nuova_estensione == nuova_estensione_mp4 ){
- + printf ("\nAttenzione,\n-xvid non è compatibile con il formato -mp4\n");
- + printf ("Usare -mpeg4 con il formato -mp4\n\n");
- + return false;
- + }
- + *vcodec = vcodec_mpeg4 + " " + xvid_tag;
- + *video_codec_is = VIDEO_IS_MPEG4_XVID;
- + }
- + if (is_avi){
- + // check -mp4
- + if ( *nuova_estensione == nuova_estensione_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 ( (*audio_codec_is != AUDIO_IS_LAME)
- + && (*audio_codec_is != "")
- + ){
- + *audio_parm = audio_parm_lame;
- + *audio_codec_is = AUDIO_IS_LAME;
- + }
- + *format_out = format_out_avi;
- + *nuova_estensione = nuova_estensione_avi;
- + }
- +
- + return true;
- +}
- +
- 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
- --- src/routines/r-video-asp-avi.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-asp-avi.h 2013-08-21 17:23:35.340588386 +0200
- @@ -0,0 +1,22 @@
- +#ifndef R_VIDEO_ASP_AVI_H
- +#define R_VIDEO_ASP_AVI_H
- +
- +bool is_mpeg4_avi_xvid
- + (int argc, char * argv[],
- + int *param_tot_previsti,
- + std::string *vcodec,
- + std::string *preset,
- + std::string *profile,
- + std::string *set_264,
- + int *b_v_rate,
- + std::string *bitrate_video,
- + int *pass,
- + std::string *nuova_estensione,
- + std::string *audio_parm,
- + std::string *format_out,
- + std::string *audio_codec_is,
- + std::string *video_codec_is
- + );
- +
- +
- +#endif
- diff -Naur -x '*~' src/routines/r-video-generali.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.cpp
- --- src/routines/r-video-generali.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.cpp 2013-08-22 16:12:07.980554268 +0200
- @@ -0,0 +1,138 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-generali.h"
- +
- +bool passate (int argc, char * argv[], int *param_tot_previsti, int *pass)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-pass") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + *pass = atoi(argv[i+1]);
- + // check
- + if (*pass < 1 || *pass >3){
- + printf ("\nInserire -pass 2 o 3.\n");
- + return false;
- + }
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool frame_rate (int argc, char * argv[], int *param_tot_previsti, std::string *rate)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-r") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + *rate = "-r " + std::string(argv[i+1]);
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +bool video_bit_rate (int argc, char * argv[], int *param_tot_previsti, int *b_v_rate, std::string *bitrate_video)
- +{
- + // 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) )
- + return false;
- + // check argomento 300 to 4000
- + *b_v_rate = atoi(argv[i+1]);
- + if ( *b_v_rate < 300 || *b_v_rate > 4000) {
- + printf ("\nInserire un bitrate video corretto.\n");
- + return false;
- + }
- + // fine check
- + *bitrate_video = "-b:v " + std::string(argv[i+1]) + "k";
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +void is_mp4_out (int argc, char * argv[], int *param_tot_previsti, std::string *format_out, std::string *nuova_estensione)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-mp4") {
- + *format_out = format_out_mp4;
- + *nuova_estensione = nuova_estensione_mp4;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +bool is_aspect (int argc, char * argv[], int *param_tot_previsti, std::string *aspetto)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-aspect") {
- + if ( !check_num_param (argc,i,1) )
- + return false;
- + *aspetto = "-aspect " + std::string(argv[i+1]);
- + *param_tot_previsti = *param_tot_previsti +2;
- + break;
- + }
- + }
- + return true;
- +}
- +
- +
- +void is_vcopy_copy (int argc, char * argv[],
- + int *param_tot_previsti,
- + std::string *vcodec,
- + std::string *rate,
- + std::string *preset,
- + std::string *profile,
- + std::string *set_264,
- + std::string *bitrate_video,
- + std::string *filter,
- + int *pass,
- + std::string *audio_parm,
- + std::string *a_filter,
- + std::string *video_codec_is,
- + std::string *audio_codec_is)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-vcopy") {
- + *vcodec = vcodec_vcopy;
- + *video_codec_is = "";
- + // azzeramento altri paramentri video
- + *rate="";
- + *preset="";
- + *profile="";
- + *set_264="";
- + *bitrate_video="";
- + *filter="";
- + *pass=1;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-copy") {
- + *vcodec = vcodec_copy;
- + *video_codec_is = "";
- + // azzeramento altri paramentri video e audio
- + *rate="";
- + *preset="";
- + *profile="";
- + *set_264="";
- + *bitrate_video="";
- + *filter="";
- + *a_filter="";
- + *pass=1;
- + *audio_parm="";
- + *audio_codec_is = "";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- diff -Naur -x '*~' src/routines/r-video-generali.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.h
- --- src/routines/r-video-generali.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-generali.h 2013-08-22 16:09:22.785748353 +0200
- @@ -0,0 +1,24 @@
- +#ifndef R_VIDEO_GENERALI_H
- +#define R_VIDEO_GENERALI_H
- +
- +bool passate (int argc, char * argv[], int *param_tot_previsti, int *pass);
- +bool frame_rate (int argc, char * argv[], int *param_tot_previsti, std::string *rate);
- +bool video_bit_rate (int argc, char * argv[], int *param_tot_previsti, int *b_v_rate, std::string *bitrate_video);
- +void is_mp4_out (int argc, char * argv[], int *param_tot_previsti, std::string *format_out, std::string *nuova_estensione);
- +bool is_aspect (int argc, char * argv[], int *param_tot_previsti, std::string *aspetto);
- +void is_vcopy_copy (int argc, char * argv[],
- + int *param_tot_previsti,
- + std::string *vcodec,
- + std::string *rate,
- + std::string *preset,
- + std::string *profile,
- + std::string *set_264,
- + std::string *bitrate_video,
- + std::string *filter,
- + int *pass,
- + std::string *audio_parm,
- + std::string *a_filter,
- + std::string *video_codec_is,
- + std::string *audio_codec_is);
- +
- +#endif
- diff -Naur -x '*~' src/routines/r-video-x264.cpp /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.cpp
- --- src/routines/r-video-x264.cpp 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.cpp 2013-08-21 12:09:58.040152055 +0200
- @@ -0,0 +1,123 @@
- +#include "../main.h"
- +#include "../funzioni.h"
- +#include "r-video-x264.h"
- +
- +void no_fast (int argc, char * argv[], int *param_tot_previsti, bool *nofastfirst)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-nofast") {
- + *nofastfirst = true;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_preset (int argc, char * argv[], int *param_tot_previsti, std::string *preset)
- +{
- + for (int i=2; i<argc; i++) {
- +
- + if (std::string(argv[i]) == "-fast") {
- + *preset = preset_fast;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-medium") {
- + *preset = preset_medium;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-slow") {
- + *preset = preset_slow;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- +
- + }
- +}
- +
- +void is_profile (int argc, char * argv[], int *param_tot_previsti, std::string *profile)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-main") {
- + *profile = profile_main;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-high") {
- + *profile = profile_high;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- +
- + }
- +}
- +
- +void is_nopts (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-nopts") {
- + *set_264 = set_264_nopts;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_opencl (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-opencl") {
- + *set_264 = *set_264 + ":opencl";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_nr_denoise (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-nr200") {
- + *set_264 = *set_264 + ":nr=200";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-nr500") {
- + *set_264 = *set_264 + ":nr=500";
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- +
- +void is_level (int argc, char * argv[], int *param_tot_previsti, std::string *set_264)
- +{
- + for (int i=2; i<argc; i++) {
- + if (std::string(argv[i]) == "-level1") {
- + *set_264 = *set_264 + ":" + livello1;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level2") {
- + *set_264 = *set_264 + ":" + livello2;
- + *param_tot_previsti = * param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level3") {
- + *set_264 = *set_264 + ":" + livello3;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level4") {
- + *set_264 = *set_264 + ":" + livello4;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + if (std::string(argv[i]) == "-level5") {
- + *set_264 = *set_264 + ":" + livello5;
- + *param_tot_previsti = *param_tot_previsti +1;
- + break;
- + }
- + }
- +}
- diff -Naur -x '*~' src/routines/r-video-x264.h /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.h
- --- src/routines/r-video-x264.h 1970-01-01 01:00:00.000000000 +0100
- +++ /home/mc/Scrivania/cpp/3/730-ffmpeg-tool/src/routines/r-video-x264.h 2013-08-21 03:11:30.675569527 +0200
- @@ -0,0 +1,12 @@
- +#ifndef R_VIDEO_X264_H
- +#define R_VIDEO_X264_H
- +
- +void no_fast (int argc, char * argv[], int *param_tot_previsti, bool *nofastfirst);
- +void is_preset (int argc, char * argv[], int *param_tot_previsti, std::string *preset);
- +void is_profile (int argc, char * argv[], int *param_tot_previsti, std::string *profile);
- +void is_nopts (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
- +void is_opencl (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
- +void is_nr_denoise (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
- +void is_level (int argc, char * argv[], int *param_tot_previsti, std::string *set_264);
- +
- +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement