@@ -817,8 +817,6 @@ impl Command for SetSegmentVisibilityCommand {
817817 }
818818}
819819
820- /// Command to detach audio tracks from a specific segment within a video track.
821- /// This creates new audio tracks from the segment's audio streams.
822820pub struct DetachSegmentAudioCommand {
823821 track_index : usize ,
824822 segment_index : usize ,
@@ -901,7 +899,8 @@ impl Command for DetachSegmentAudioCommand {
901899
902900 if let Track :: Video ( vt) = track {
903901 let vt = std:: sync:: Arc :: make_mut ( vt) ;
904- vt. track . segments [ self . segment_index ] = video_track_mut. track . segments [ self . segment_index ] . clone ( ) ;
902+ vt. track . segments [ self . segment_index ] =
903+ video_track_mut. track . segments [ self . segment_index ] . clone ( ) ;
905904 vt. update_duration ( ) ;
906905 }
907906
@@ -958,8 +957,6 @@ impl Command for DetachSegmentAudioCommand {
958957 }
959958}
960959
961- /// Command to detach subtitle tracks from a specific segment within a video track.
962- /// This creates new subtitle tracks from the segment's subtitle streams.
963960pub struct DetachSegmentSubtitleCommand {
964961 track_index : usize ,
965962 segment_index : usize ,
@@ -999,7 +996,6 @@ impl Command for DetachSegmentSubtitleCommand {
999996 }
1000997 } ;
1001998
1002- // Check segment index
1003999 if self . segment_index >= video_track. track . segments . len ( ) {
10041000 return Err ( Error :: IndexOutOfBounds (
10051001 self . segment_index ,
@@ -1008,21 +1004,15 @@ impl Command for DetachSegmentSubtitleCommand {
10081004 }
10091005
10101006 let segment = & video_track. track . segments [ self . segment_index ] ;
1011-
1012- // Check if segment has subtitle streams
10131007 if segment. metadata . subtitles . is_empty ( ) {
10141008 return Err ( Error :: InvalidConfig (
10151009 "Segment has no subtitle streams to detach" . into ( ) ,
10161010 ) ) ;
10171011 }
10181012
1019- // Save original segment metadata for undo
10201013 self . old_segment_metadata = Some ( segment. metadata . clone ( ) ) ;
1021-
1022- // Clone video track for modification
10231014 let mut video_track_mut = video_track. as_ref ( ) . clone ( ) ;
10241015
1025- // Detach subtitle tracks from the segment
10261016 let detached_subtitle_tracks: Vec < Track > = video_track_mut
10271017 . detach_segment_subtitle_tracks ( self . segment_index )
10281018 . into_iter ( )
@@ -1035,18 +1025,17 @@ impl Command for DetachSegmentSubtitleCommand {
10351025 ) ) ;
10361026 }
10371027
1038- // Update the video track with modified segment
10391028 let track = manager
10401029 . get_mut ( self . track_index )
10411030 . ok_or_else ( || Error :: IndexOutOfBounds ( self . track_index , manager_len) ) ?;
10421031
10431032 if let Track :: Video ( vt) = track {
10441033 let vt = std:: sync:: Arc :: make_mut ( vt) ;
1045- vt. track . segments [ self . segment_index ] = video_track_mut. track . segments [ self . segment_index ] . clone ( ) ;
1034+ vt. track . segments [ self . segment_index ] =
1035+ video_track_mut. track . segments [ self . segment_index ] . clone ( ) ;
10461036 vt. update_duration ( ) ;
10471037 }
10481038
1049- // Insert detached subtitle tracks
10501039 let mut inserted_indices = Vec :: new ( ) ;
10511040 for ( i, track) in detached_subtitle_tracks. into_iter ( ) . enumerate ( ) {
10521041 let insert_idx = self . track_index + 1 + i;
@@ -1074,7 +1063,6 @@ impl Command for DetachSegmentSubtitleCommand {
10741063 manager. remove_track ( idx) ?;
10751064 }
10761065
1077- // Restore original segment metadata
10781066 let manager_len = manager. len ( ) ;
10791067 let track = manager
10801068 . get_mut ( self . track_index )
@@ -1099,8 +1087,6 @@ impl Command for DetachSegmentSubtitleCommand {
10991087 }
11001088}
11011089
1102- /// Command to trim/remove gaps around a specific segment.
1103- /// This removes the gap before and after the specified segment.
11041090pub struct RemoveSegmentGapCommand {
11051091 track_index : usize ,
11061092 segment_index : usize ,
@@ -1178,7 +1164,11 @@ impl Command for RemoveSegmentGapCommand {
11781164
11791165 // Restore start gap
11801166 if start_gap > Duration :: ZERO {
1181- let start_index = if self . segment_index == 0 { 0 } else { self . segment_index } ;
1167+ let start_index = if self . segment_index == 0 {
1168+ 0
1169+ } else {
1170+ self . segment_index
1171+ } ;
11821172
11831173 for i in start_index..segments_count {
11841174 track. shift_segment_timeline ( i, start_gap) ?;
@@ -1211,7 +1201,6 @@ impl Command for RemoveSegmentGapCommand {
12111201 }
12121202}
12131203
1214- /// Command to trim/remove the gap before (to the left of) a specific segment.
12151204pub struct RemoveSegmentLeftGapCommand {
12161205 track_index : usize ,
12171206 segment_index : usize ,
@@ -1293,7 +1282,6 @@ impl Command for RemoveSegmentLeftGapCommand {
12931282 }
12941283}
12951284
1296- /// Command to trim/remove the gap after (to the right of) a specific segment.
12971285pub struct RemoveSegmentRightGapCommand {
12981286 track_index : usize ,
12991287 segment_index : usize ,
0 commit comments