Skip to content

Commit c260202

Browse files
committed
Json
1 parent 56c9105 commit c260202

5 files changed

Lines changed: 18 additions & 10 deletions

File tree

czkawka_core/i18n/en/czkawka_core.ftl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,5 @@ core_invalid_extension_contains_space = { $extension } is not a valid extension
106106
core_invalid_extension_contains_dot = { $extension } is not a valid extension because it contains dot inside
107107
core_ffmpeg_unknown_encoder = Cannot encode { $file } using the { $encoder } encoder. The current FFmpeg build does not support this encoder. Use a different FFmpeg version with the required codec support or select another encoder.
108108
core_ffmpeg_error = FFmpeg error while processing { $file }, status code { $code }, reason { $reason }
109-
core_custom_command_missing_path_placeholder = Custom FFmpeg command must contain {"{PATH}"} as input file placeholder
109+
core_custom_command_missing_path_placeholder = Custom FFmpeg command must contain {"{PATH}"} as input file placeholder
110+
core_custom_command_empty = Custom FFmpeg command cannot be empty

czkawka_core/src/tools/video_optimizer/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl VideoOptimizer {
386386
return None;
387387
}
388388

389-
match process_video(stop_flag, &entry.path.to_string_lossy(), entry.size, video_transcode_params.clone()) {
389+
match process_video(stop_flag, &entry.path.to_string_lossy(), entry.size, &video_transcode_params) {
390390
Ok(_new_size) => Some(None),
391391
Err(e) => Some(Some(flc!("core_failed_to_optimize_video", file = entry.path.to_string_lossy(), reason = e))),
392392
}

czkawka_core/src/tools/video_optimizer/core/video_converter.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ pub fn check_video(mut entry: VideoTranscodeEntry) -> VideoTranscodeEntry {
4646
entry
4747
}
4848

49-
pub fn process_video(stop_flag: &Arc<AtomicBool>, video_path: &str, original_size: u64, params: VideoTranscodeFixParams) -> Result<(), String> {
49+
pub fn process_video(stop_flag: &Arc<AtomicBool>, video_path: &str, original_size: u64, params: &VideoTranscodeFixParams) -> Result<(), String> {
5050
let temp_output = Path::new(video_path).with_extension("czkawka_optimized.mp4");
5151

5252
if let Some(ref cmd) = params.custom_ffmpeg_command {
5353
run_custom_command(cmd, video_path, &temp_output, stop_flag)?;
5454
} else {
55-
run_standard_command(&params, video_path, &temp_output, stop_flag)?;
55+
run_standard_command(params, video_path, &temp_output, stop_flag)?;
5656
}
5757

5858
let metadata = fs::metadata(&temp_output).map_err(|e| {
@@ -124,8 +124,15 @@ fn run_custom_command(cmd: &str, video_path: &str, temp_output: &Path, stop_flag
124124

125125
let args: Vec<String> = cmd.split_whitespace().map(|t| if t == "{PATH}" { video_path.to_string() } else { t.to_string() }).collect();
126126

127-
let mut command = Command::new(&args[0]);
128-
command.args(&args[1..]).arg("-y").arg(temp_output);
127+
let Some(first_arg) = args.first() else {
128+
return Err(flc!("core_custom_command_empty"));
129+
};
130+
let Some(next_args) = args.get(1..) else {
131+
return Err(flc!("core_custom_command_empty"));
132+
};
133+
134+
let mut command = Command::new(first_arg);
135+
command.args(next_args).arg("-y").arg(temp_output);
129136

130137
run_ffmpeg_command(command, video_path, "custom", stop_flag, temp_output)
131138
}

krokiet/src/connect_row_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ mod context_menu {
999999
return;
10001000
}
10011001
let path = row.val_str.iter().nth(path_idx).expect("path_idx out of bounds").to_string();
1002-
add_excluded_paths(&app.global::<Settings>(), &[path.clone()]);
1002+
add_excluded_paths(&app.global::<Settings>(), std::slice::from_ref(&path));
10031003

10041004
// Also remove matching rows from results, keeping reference-group items.
10051005
let mut in_reference_group = false;

krokiet/src/file_actions/connect_optimize_video.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl ModelProcessor {
177177
&stop_flag_clone,
178178
&full_path,
179179
original_size,
180-
VideoTranscodeFixParams {
180+
&VideoTranscodeFixParams {
181181
codec: requested_video_codec,
182182
quality: target_quality,
183183
fail_if_not_smaller: fail_if_bigger,
@@ -270,12 +270,12 @@ impl ModelProcessor {
270270
}
271271

272272
#[cfg(not(test))]
273-
fn optimize_single_video(stop_flag: &Arc<AtomicBool>, video_path: &str, original_size: u64, transcode_params: VideoTranscodeFixParams) -> Result<(), String> {
273+
fn optimize_single_video(stop_flag: &Arc<AtomicBool>, video_path: &str, original_size: u64, transcode_params: &VideoTranscodeFixParams) -> Result<(), String> {
274274
czkawka_core::tools::video_optimizer::core::process_video(stop_flag, video_path, original_size, transcode_params)
275275
}
276276

277277
#[cfg(test)]
278-
fn optimize_single_video(_stop_flag: &Arc<AtomicBool>, video_path: &str, _original_size: u64, _transcode_params: VideoTranscodeFixParams) -> Result<(), String> {
278+
fn optimize_single_video(_stop_flag: &Arc<AtomicBool>, video_path: &str, _original_size: u64, _transcode_params: &VideoTranscodeFixParams) -> Result<(), String> {
279279
if video_path.contains("test_error") {
280280
return Err(format!("Test error for item: {video_path}"));
281281
}

0 commit comments

Comments
 (0)