Пример #1
0
        // ReSharper disable once SuggestBaseTypeForParameter
        public static string[] ExtractUsm(FileInfo file)
        {
            var usm   = new CriUsmStream(file.FullName);
            var files = usm.DemultiplexStreams(new MpegStream.DemuxOptionsStruct
            {
                ExtractVideo = true,
                ExtractAudio = true
            });

            return(files);
        }
Пример #2
0
        private void Process(string fileName)
        {
            Console.WriteLine($"File: {fileName}");
            var usmStream = new CriUsmStream(fileName);

            Console.WriteLine("Demuxing...");
            usmStream.DemultiplexStreams(new MpegStream.DemuxOptionsStruct()
            {
                AddHeader         = false,
                AddPlaybackHacks  = false,
                ExtractAudio      = true,
                ExtractVideo      = true,
                SplitAudioStreams = false
            });
        }
Пример #3
0
        private void Process(string fileName)
        {
            Console.WriteLine($"File: {fileName}");
            var usmStream = new CriUsmStream(fileName);

            Console.WriteLine("Demuxing...");
            usmStream.DemultiplexStreams(new MpegStream.DemuxOptionsStruct()
            {
                AddHeader         = false,
                AddPlaybackHacks  = false,
                ExtractAudio      = true,
                ExtractVideo      = true,
                SplitAudioStreams = false
            });

            if (!string.IsNullOrEmpty(OutputDir) && !Directory.Exists(OutputDir))
            {
                Directory.CreateDirectory(OutputDir);
            }

            JoinOutputFile(usmStream);
        }
Пример #4
0
        public static void DecodeUsmFiles(FileInfo filename)
        {
            var  volume       = 1F;
            var  mode         = 16;
            var  loop         = 0;
            var  ciphKey1     = 0x92EBF464;
            uint ciphKey2     = 0x7E896318;
            var  path         = Directory.GetCurrentDirectory();
            var  cridCommands = " -a 92EBF464 -b 7E896318 -v -n \"" +
                                filename.FullName + "\"";

            Console.WriteLine(filename.Name + " - 解密m2v文件...");
            var process = new Process
            {
                StartInfo =
                {
                    FileName        = path + @"\crid.exe",
                    Arguments       = cridCommands,
                    UseShellExecute = true,
                    CreateNoWindow  = true
                }
            };

            process.Start();
            process.WaitForExit();
            var af     = new CriUsmStream(filename.FullName);
            var option = new MpegStream.DemuxOptionsStruct
            {
                ExtractAudio      = true,
                SplitAudioStreams = true
            };

            af.DemultiplexStreams(option);
            foreach (var hcafile in new DirectoryInfo(filename.DirectoryName).GetFiles("*.bin",
                                                                                       SearchOption.AllDirectories))
            {
                if (!hcafile.Name.Contains(filename.Name.Substring(0, filename.Name.Length - 4)))
                {
                    continue;
                }
                using (var inputFileStream = File.Open(hcafile.FullName, FileMode.Open, FileAccess.Read))
                {
                    Console.WriteLine(hcafile.Name + " - 解密hca...");
                    using (var outputFileStream =
                               File.Open(
                                   filename.DirectoryName + @"\" + filename.Name.Substring(0, filename.Name.Length - 4) +
                                   @".demux\" + hcafile.Name.Substring(0, hcafile.Name.Length - 4) + ".wav",
                                   FileMode.Create, FileAccess.Write))
                    {
                        var decodeParams = DecodeParams.CreateDefault();
                        decodeParams.Key1        = ciphKey1;
                        decodeParams.Key2        = ciphKey2;
                        decodeParams.KeyModifier = 0;

                        var audioParams = AudioParams.CreateDefault();

                        audioParams.InfiniteLoop       = AudioParams.Default.InfiniteLoop;
                        audioParams.SimulatedLoopCount = AudioParams.Default.SimulatedLoopCount;
                        audioParams.OutputWaveHeader   = true;

                        using (var hcaStream = new HcaAudioStream(inputFileStream, decodeParams, audioParams))
                        {
                            var read       = 1;
                            var dataBuffer = new byte[1024];

                            while (read > 0)
                            {
                                read = hcaStream.Read(dataBuffer, 0, dataBuffer.Length);

                                if (read > 0)
                                {
                                    outputFileStream.Write(dataBuffer, 0, read);
                                }
                            }
                        }
                    }
                }

                File.Delete(hcafile.FullName);
            }

            var m2vfiles = new DirectoryInfo(filename.DirectoryName + @"\" +
                                             filename.Name.Substring(0, filename.Name.Length - 4) + @".demux\")
                           .GetFiles("*.m2v", SearchOption.AllDirectories);
            var m2vfile  = m2vfiles[0];
            var wavfiles = new DirectoryInfo(filename.DirectoryName + @"\" +
                                             filename.Name.Substring(0, filename.Name.Length - 4) + @".demux\")
                           .GetFiles("*.wav", SearchOption.AllDirectories);
            var wavefile       = wavfiles[0];
            var ffmpegCommands = "-i " + "\"" + m2vfile.FullName + "\"" + " -i " + "\"" + wavefile.FullName + "\"" +
                                 " -c:v copy -c:a aac -strict experimental " + "\"" + filename.DirectoryName + @"\" +
                                 filename.Name.Substring(0, filename.Name.Length - 4) + @".demux\" +
                                 filename.Name.Substring(0, filename.Name.Length - 4) + "_final.mp4" + "\"";

            Console.WriteLine(filename.Name + " - 合并m2v、wav文件...");
            var process2 = new Process
            {
                StartInfo =
                {
                    FileName        = path + @"\ffmpeg.exe",
                    Arguments       = ffmpegCommands,
                    UseShellExecute = true,
                    CreateNoWindow  = true
                }
            };

            process2.Start();
            process2.WaitForExit();
        }
Пример #5
0
        protected override void DoTaskForFile(string path, IVgmtWorkerStruct pMpegDemuxStruct, DoWorkEventArgs e)
        {
            MpegDemuxStruct demuxStruct = (MpegDemuxStruct)pMpegDemuxStruct;

            MpegStream.DemuxOptionsStruct demuxOptions = new MpegStream.DemuxOptionsStruct();

            demuxOptions.ExtractAudio = demuxStruct.ExtractAudio;
            demuxOptions.ExtractVideo = demuxStruct.ExtractVideo;

            demuxOptions.AddHeader         = demuxStruct.AddHeader;
            demuxOptions.SplitAudioStreams = demuxStruct.SplitAudioTracks;
            demuxOptions.AddPlaybackHacks  = demuxStruct.AddPlaybackHacks;

            switch (demuxStruct.SourceFormat)
            {
            case "ASF (MS Advanced Systems Format)":
            case "WMV (MS Advanced Systems Format)":
                MicrosoftAsfContainer asfStream = new MicrosoftAsfContainer(path);
                asfStream.DemultiplexStreams(demuxOptions);
                break;

            case "BIK (Bink Video Container)":
                BinkStream binkStream = new BinkStream(path);
                binkStream.DemultiplexStreams(demuxOptions);
                break;

            case "DSI (Racjin/Racdym PS2 Video)":
                RacjinDsiStream dsiStream = new RacjinDsiStream(path);
                dsiStream.DemultiplexStreams(demuxOptions);
                break;

            case "DVD Video (VOB)":
                DvdVideoStream dvdStream = new DvdVideoStream(path);
                dvdStream.DemultiplexStreams(demuxOptions);
                break;

            case "Electronic Arts VP6 (VP6)":
                ElectronicArtsVp6Stream vp6Stream = new ElectronicArtsVp6Stream(path);
                vp6Stream.DemultiplexStreams(demuxOptions);
                break;

            case "Electronic Arts MPC (MPC)":
                ElectronicArtsMpcStream mpcStream = new ElectronicArtsMpcStream(path);
                mpcStream.DemultiplexStreams(demuxOptions);
                break;

            case "H4M (Hudson GameCube Video)":
                HudsonHvqm4VideoStream hvqmStream = new HudsonHvqm4VideoStream(path);
                hvqmStream.DemultiplexStreams(demuxOptions);
                break;

            case "MO (Mobiclip)":
                MobiclipStream.MovieType movieType = MobiclipStream.GetMobiclipStreamType(path);

                switch (movieType)
                {
                //case MobiclipStream.MovieType.NintendoDs:
                //    MobiclipNdsStream mobiclipNdsStream = new MobiclipNdsStream(path);
                //    mobiclipNdsStream.DemultiplexStreams(demuxOptions);
                //    break;
                case MobiclipStream.MovieType.Wii:
                    MobiclipWiiStream mobiclipWiiStream = new MobiclipWiiStream(path);
                    mobiclipWiiStream.DemultiplexStreams(demuxOptions);
                    break;

                default:
                    throw new FormatException(String.Format("Unsupported Mobiclip type, for file: {0}", Path.GetFileName(path)));
                }

                break;

            case "MPEG":
                int mpegType = MpegStream.GetMpegStreamType(path);

                switch (mpegType)
                {
                case 1:
                    Mpeg1Stream mpeg1Stream = new Mpeg1Stream(path);
                    mpeg1Stream.DemultiplexStreams(demuxOptions);
                    break;

                case 2:
                    Mpeg2Stream mpeg2Stream = new Mpeg2Stream(path);
                    mpeg2Stream.DemultiplexStreams(demuxOptions);
                    break;

                default:
                    throw new FormatException(String.Format("Unsupported MPEG type, for file: {0}", Path.GetFileName(path)));
                }
                break;

            case "MPS (PSP UMD Movie)":
                SonyPspMpsStream mpsStream = new SonyPspMpsStream(path);
                mpsStream.DemultiplexStreams(demuxOptions);
                break;

            case "PAM (PlayStation Advanced Movie)":
                SonyPamStream pamStream = new SonyPamStream(path);
                pamStream.DemultiplexStreams(demuxOptions);
                break;

            case "PMF (PSP Movie Format)":
                SonyPmfStream pmfStream = new SonyPmfStream(path);
                pmfStream.DemultiplexStreams(demuxOptions);
                break;

            case "PSS (PlayStation Stream)":
                SonyPssStream sps = new SonyPssStream(path);
                sps.DemultiplexStreams(demuxOptions);
                break;

            case "SFD (CRI Sofdec Video)":
                SofdecStream ss = new SofdecStream(path);
                ss.DemultiplexStreams(demuxOptions);
                break;

            case "THP":
                NintendoThpMovieStream thp = new NintendoThpMovieStream(path);
                thp.DemultiplexStreams(demuxOptions);
                break;

            case "USM (CRI Movie 2)":
                CriUsmStream cus = new CriUsmStream(path);
                cus.DemultiplexStreams(demuxOptions);
                break;

            case "XMV (Xbox Media Video)":
                XmvStream xmv = new XmvStream(path);
                xmv.DemultiplexStreams(demuxOptions);
                break;

            default:
                throw new FormatException("Source format not defined.");
            }

            this.outputBuffer.Append(Path.GetFileName(path) + Environment.NewLine);
        }