private void metaGenerator_MetaReady(string filename, VideoMetadataUseful meta) { lock (this) { // 2 cases: meta is ready for one of the draggies, or for one of the outstanding media var draggyMaybe = _draggies.FirstOrDefault(x => x.Filename == filename); if (draggyMaybe != null) { draggyMaybe.Meta = meta; if (MetaReadyForDraggy != null) MetaReadyForDraggy(filename, meta); return; } // at this point it could be one of outstanding media (video or audio) var outstandingMaybeVid = outstandingVideo.FirstOrDefault(x => x.FileName == filename); if (outstandingMaybeVid != null) { // TODO: handle variable fps, fps == proj.fps and counted frames for PENTAX avis outstandingMaybeVid.FileLengthSec = meta.GetVideoDurationSec(Proj.FrameRate); // remember, this clip could be different fps, we need proj's fps var projFramesThisOne = Proj.SecToFrame(outstandingMaybeVid.FileLengthSec ?? 0); outstandingMaybeVid.FileLengthFrames = projFramesThisOne; outstandingMaybeVid.FrameEnd = projFramesThisOne; if (outstandingMaybeVid is VidkaClipVideo) { var outstandingMaybeVidVVV = (VidkaClipVideo)outstandingMaybeVid; outstandingMaybeVidVVV.HasAudioXml = meta.HasAudio; } outstandingMaybeVid.IsNotYetAnalyzed = false; outstandingVideo.Remove(outstandingMaybeVid); if (MetaReadyForOutstandingVideo != null) MetaReadyForOutstandingVideo(outstandingMaybeVid, meta); return; } var outstandingMaybeAud = outstandingAudio.FirstOrDefault(x => x.FileName == filename); if (outstandingMaybeAud != null) { outstandingMaybeAud.FileLengthSec = meta.AudioDurationSec; var projFramesThisOne = Proj.SecToFrame(outstandingMaybeAud.FileLengthSec ?? 0); outstandingMaybeAud.FileLengthFrames = projFramesThisOne; outstandingMaybeAud.FrameEnd = projFramesThisOne; outstandingAudio.Remove(outstandingMaybeAud); if (MetaReadyForOutstandingAudio != null) MetaReadyForOutstandingAudio(outstandingMaybeAud, meta); return; } } }
private void dragAndDropMan_MetaReadyForOutstandingVideo(VidkaClipVideo vclip, VideoMetadataUseful meta) { ___UiTransactionBegin(); UpdateCanvasWidthFromProjAndDimdim(); ___UiTransactionEnd(); }
private void dragAndDropMan_MetaReadyForOutstandingAudio(VidkaClipAudio aclip, VideoMetadataUseful meta) { editor.PleaseRepaint(); }
private void dragAndDropMan_MetaReadyForDraggy(string filename, VideoMetadataUseful meta) { ___UiTransactionBegin(); var newLengthFrames = dragAndDropMan.Draggies.FirstOrDefault().LengthInFrames; UiObjects.SetDraggyCoordinates( text: "" + newLengthFrames + "\nframes", frameLength: newLengthFrames ); ___UiTransactionEnd(); }
private void callbackMetaReady(string filename, VideoMetadataUseful metaXml) { if (vclip == null) return; vclip.CustomAudioLengthSec = metaXml.AudioDurationSec; this.InvokeOrNot_IDontGiveAShit_JustDoIt(() => updateAudioInfo(vclip)); //shitboxAlignVideoAudioControl.Update_audionDuration(VClip.CustomAudioLengthSec); }
private void RunFfMpegMeta(string filename, string outFilename) { Process process = new Process(); ProcessStartInfo si = new ProcessStartInfo(); // Configure the process using the StartInfo properties. si.FileName = FfprobeExecutable; si.Arguments = String.Format("-v quiet -print_format xml -show_format -show_streams -count_frames \"{0}\"", filename); si.UseShellExecute = false; si.RedirectStandardOutput = true; si.CreateNoWindow = true; si.WindowStyle = ProcessWindowStyle.Hidden; try { using (Process ppp = Process.Start(si)) { using (StreamReader reader = ppp.StandardOutput) { string resultXmlString = reader.ReadToEnd(); File.WriteAllText(outFilename, resultXmlString); MetaXml = LoadMetaFromXmlString(resultXmlString); } ppp.WaitForExit(); } ResultCode = OpResultCode.OK; } catch (Win32Exception ex) { if (ex.NativeErrorCode == 2) ResultCode = OpResultCode.FileNotFound; else { ResultCode = OpResultCode.OtherError; ErrorMessage = ex.Message; } } catch (Exception ex) { ResultCode = OpResultCode.OtherError; ErrorMessage = ex.Message; } }