public static void ExtractAudio(Settings settings, String path, List <Tuple <CardInfo, String> > allEntries, InfoProgress progress)
        {
            foreach (var entry in allEntries)
            {
                progress.ProcessedSteps(1);
                if (progress.Cancelled)
                {
                    return;
                }

                CardInfo cardInfo = entry.Item1;
                if (!cardInfo.HasAudio())
                {
                    continue;
                }

                String outputAudioFilename = entry.Item2;
                String outputAudioFilepath = path + Path.DirectorySeparatorChar + outputAudioFilename;

                UtilsInputFiles.FileDesc audioFileDesc = cardInfo.episodeInfo.AudioFileDesc;
                var audioStreamInfo = cardInfo.episodeInfo.AudioStreamInfo;

                String arguments = String.Format("-v quiet -y -i \"{0}\" -map 0:{1} -ss \"{2}\" -to \"{3}\" -vn -c:a libvorbis \"{4}\"",
                                                 audioFileDesc.filename,                              // input file
                                                 audioStreamInfo.StreamIndex,                         // audio stream index
                                                 UtilsCommon.ToTimeArg(cardInfo.audioStartTimestamp), // start time
                                                 UtilsCommon.ToTimeArg(cardInfo.audioEndTimestamp),   // end time
                                                 outputAudioFilepath                                  // output file
                                                 );
                UtilsCommon.StartProcessAndGetOutput(InstanceSettings.systemSettings.formatConvertCommand, arguments);
            }
        }
        /// <summary>
        /// Extracts an image from a video file at a given time and resizes it. Resizing preserves aspect ratio.
        /// </summary>
        public static bool GetImage(String videoFilename, double time, String outFilename, double scale = 1)
        {
            String argumentString = String.Format("-y -v quiet -an -ss {0} -i \"{1}\" -f image2 -vf \"scale=iw*{2}/3628800:ih*{2}/3628800\" -vframes 1 \"{3}\"",
                                                  UtilsCommon.ToTimeArg(time),
                                                  videoFilename,
                                                  (int)(scale * 3628800), // int is needed because double will create values with comma (e.g "0,1"); 3628800=10! (has many divisors)
                                                  outFilename);

            UtilsCommon.StartProcessAndGetOutput(InstanceSettings.systemSettings.formatConvertCommand, argumentString);
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Returns some string that identifies this card information.
        /// </summary>
        /// <returns>The key.</returns>
        public String GetKey()
        {
            String str = String.Format("{0:000.}", episodeInfo.Number) + "__" + UtilsCommon.ToTimeArg(startTimestamp) + "__" + UtilsCommon.ToTimeArg(endTimestamp);

            return(Regex.Replace(str, "[^a-zA-Z0-9]", "_"));
        }