@@ -145,6 +145,7 @@ impl Message<Stop> for Actor {
145145 self . recording_dir . clone ( ) ,
146146 std:: mem:: take ( & mut self . segments ) ,
147147 cursors,
148+ self . segment_factory . fragmented ,
148149 )
149150 . await ?;
150151
@@ -610,51 +611,69 @@ async fn stop_recording(
610611 recording_dir : PathBuf ,
611612 segments : Vec < RecordingSegment > ,
612613 cursors : Cursors ,
614+ fragmented : bool ,
613615) -> Result < CompletedRecording , RecordingError > {
614616 use cap_project:: * ;
615617
616618 let make_relative = |path : & PathBuf | {
617619 RelativePathBuf :: from_path ( path. strip_prefix ( & recording_dir) . unwrap ( ) ) . unwrap ( )
618620 } ;
619621
622+ let segment_metas: Vec < _ > = futures:: stream:: iter ( segments)
623+ . then ( async |s| {
624+ let to_start_time = |timestamp : Timestamp | {
625+ timestamp
626+ . duration_since ( s. pipeline . start_time )
627+ . as_secs_f64 ( )
628+ } ;
629+
630+ MultipleSegment {
631+ display : VideoMeta {
632+ path : make_relative ( & s. pipeline . screen . path ) ,
633+ fps : s. pipeline . screen . video_info . unwrap ( ) . fps ( ) ,
634+ start_time : Some ( to_start_time ( s. pipeline . screen . first_timestamp ) ) ,
635+ } ,
636+ camera : s. pipeline . camera . map ( |camera| VideoMeta {
637+ path : make_relative ( & camera. path ) ,
638+ fps : camera. video_info . unwrap ( ) . fps ( ) ,
639+ start_time : Some ( to_start_time ( camera. first_timestamp ) ) ,
640+ } ) ,
641+ mic : s. pipeline . microphone . map ( |mic| AudioMeta {
642+ path : make_relative ( & mic. path ) ,
643+ start_time : Some ( to_start_time ( mic. first_timestamp ) ) ,
644+ } ) ,
645+ system_audio : s. pipeline . system_audio . map ( |audio| AudioMeta {
646+ path : make_relative ( & audio. path ) ,
647+ start_time : Some ( to_start_time ( audio. first_timestamp ) ) ,
648+ } ) ,
649+ cursor : s
650+ . pipeline
651+ . cursor
652+ . as_ref ( )
653+ . map ( |cursor| make_relative ( & cursor. output_path ) ) ,
654+ }
655+ } )
656+ . collect :: < Vec < _ > > ( )
657+ . await ;
658+
659+ let needs_remux = if fragmented {
660+ segment_metas. iter ( ) . any ( |seg| {
661+ let display_path = seg. display . path . to_path ( & recording_dir) ;
662+ display_path. is_dir ( )
663+ } )
664+ } else {
665+ false
666+ } ;
667+
668+ let status = if needs_remux {
669+ Some ( StudioRecordingStatus :: NeedsRemux )
670+ } else {
671+ Some ( StudioRecordingStatus :: Complete )
672+ } ;
673+
620674 let meta = StudioRecordingMeta :: MultipleSegments {
621675 inner : MultipleSegments {
622- segments : futures:: stream:: iter ( segments)
623- . then ( async |s| {
624- let to_start_time = |timestamp : Timestamp | {
625- timestamp
626- . duration_since ( s. pipeline . start_time )
627- . as_secs_f64 ( )
628- } ;
629-
630- MultipleSegment {
631- display : VideoMeta {
632- path : make_relative ( & s. pipeline . screen . path ) ,
633- fps : s. pipeline . screen . video_info . unwrap ( ) . fps ( ) ,
634- start_time : Some ( to_start_time ( s. pipeline . screen . first_timestamp ) ) ,
635- } ,
636- camera : s. pipeline . camera . map ( |camera| VideoMeta {
637- path : make_relative ( & camera. path ) ,
638- fps : camera. video_info . unwrap ( ) . fps ( ) ,
639- start_time : Some ( to_start_time ( camera. first_timestamp ) ) ,
640- } ) ,
641- mic : s. pipeline . microphone . map ( |mic| AudioMeta {
642- path : make_relative ( & mic. path ) ,
643- start_time : Some ( to_start_time ( mic. first_timestamp ) ) ,
644- } ) ,
645- system_audio : s. pipeline . system_audio . map ( |audio| AudioMeta {
646- path : make_relative ( & audio. path ) ,
647- start_time : Some ( to_start_time ( audio. first_timestamp ) ) ,
648- } ) ,
649- cursor : s
650- . pipeline
651- . cursor
652- . as_ref ( )
653- . map ( |cursor| make_relative ( & cursor. output_path ) ) ,
654- }
655- } )
656- . collect :: < Vec < _ > > ( )
657- . await ,
676+ segments : segment_metas,
658677 cursors : cap_project:: Cursors :: Correct (
659678 cursors
660679 . into_values ( )
@@ -671,7 +690,7 @@ async fn stop_recording(
671690 } )
672691 . collect ( ) ,
673692 ) ,
674- status : Some ( StudioRecordingStatus :: Complete ) ,
693+ status,
675694 } ,
676695 } ;
677696
0 commit comments