예제 #1
0
        private void btn_tak_pcm_Click(object sender, EventArgs e)
        {
            if (SELECTED_FILES == null)
            {
                return;
            }

            var ffmp = new FFmpeg(prog.CDCRUSH.FFMPEG_PATH);
            var tak  = new Tak(prog.CDCRUSH.TOOLS_PATH);

            tak.onComplete = (s) => {
                LOG.log($"TAK Operation Complete - {s}");
            };

            ffmp.onComplete = (s) => {
                LOG.log($"FFMPEG Operation Complete - {s}");
            };

            string INPUT  = SELECTED_FILES[0];
            string OUTPUT = Path.ChangeExtension(INPUT, ".tak");

            // This will make FFMPEG read the PCM file, convert it to WAV on the fly
            // and feed it to TAK, which will convert and save it.

            ffmp.convertPCMStreamToWavStream((ffmpegIn, ffmpegOut) => {
                var sourceFile = File.OpenRead(INPUT);
                tak.encodeFromStream(OUTPUT, (takIn) => {
                    ffmpegOut.CopyTo(takIn);
                    takIn.Close();
                });
                sourceFile.CopyTo(ffmpegIn);                            // Feed PCM to FFMPEG
                ffmpegIn.Close();
            });
        }        // --
예제 #2
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (CrushParams)jobData;

            // Working file is already set and points to either TEMP or INPUT folder
            INPUT = track.workingFile;
            // NOTE: OUTPUT path is generated later with the setupfiles() function

            // Before compressing the tracks, get and store the MD5 of the track
            using (var md5 = System.Security.Cryptography.MD5.Create())
            {
                using (var str = File.OpenRead(INPUT))
                {
                    track.md5 = BitConverter.ToString(md5.ComputeHash(str)).Replace("-", "").ToLower();
                }
            }

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                setupHandlers(ecm);

                // New filename that is going to be generated:
                setupFiles(".bin.ecm");
                ecm.ecm(INPUT, OUTPUT); // old .bin file from wherever it was to temp/bin.ecm
            }
            else                        // AUDIO TRACK :
            {
                // Get Audio Data. (codecID, codecQuality)
                Tuple <string, int> audioQ = p.audioQuality;

                // New filename that is going to be generated:
                setupFiles(AudioMaster.getCodecExt(audioQ.Item1));

                // I need ffmpeg for both occations
                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                setupHandlers(ffmp);

                if (audioQ.Item1 == "TAK")
                {
                    var tak = new Tak(CDCRUSH.TOOLS_PATH);

                    // This will make FFMPEG read the PCM file, convert it to WAV on the fly
                    // and feed it to TAK, which will convert and save it.
                    ffmp.convertPCMStreamToWavStream((ffmpegIn, ffmpegOut) => {
                        var sourceFile = File.OpenRead(INPUT);
                        tak.encodeFromStream(OUTPUT, (takIn) => {
                            ffmpegOut.CopyTo(takIn);
                            takIn.Close();
                        });
                        sourceFile.CopyTo(ffmpegIn);                    // Feed PCM to FFMPEG
                        ffmpegIn.Close();
                    });
                }
                else
                {
                    // It must be FFMPEG
                    ffmp.encodePCM(audioQ.Item1, audioQ.Item2, INPUT, OUTPUT);
                }
            }    //- end if (track.isData)
        }// -----------------------------------------