From 709d429b8efc5d60a0ed5c63b608672694b5f351 Mon Sep 17 00:00:00 2001 From: kaihere14 Date: Sun, 18 Oct 2026 05:41:03 +0530 Subject: [PATCH] Print ccextractor.cnf warnings after the command line is parsed Warnings about bad lines in ccextractor.cnf were logged before the command line was parsed, while the logger still targeted stdout. With --stdout they ended up in front of the captions, and --quiet did not silence them. Hold the messages back, point the logger at the parsed messages target, then print them. Also fix the FIX_PADDING and INVESTIGATE_PACKET tag typos in docs/ccextractor.cnf.sample, add the missing '=' to tags that take a value, and list the tags that are actually read. --- docs/ccextractor.cnf.sample | 20 ++++++++++++++------ src/rust/src/lib.rs | 22 +++++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/docs/ccextractor.cnf.sample b/docs/ccextractor.cnf.sample index 953953ef1..30b47892a 100644 --- a/docs/ccextractor.cnf.sample +++ b/docs/ccextractor.cnf.sample @@ -3,6 +3,14 @@ # # To enable required option please uncomment option # +# Only these tags are read: INPUT_SOURCE, BUFFER_INPUT, NOFONT_COLOR, +# NOTYPE_SETTING, OUTPUT_FORMAT, VIDEO_EDITED, GOP_TIME, FIX_PADDING, +# GUI_MODE_REPORTS, NO_PROGRESS_BAR, CAP_FILE, PROFANITY_FILE, START_AT, +# END_AT, INVESTIGATE_PACKET, FULL_BIN, NO_SYNC, HAUPPAUGE_MODE, +# MP4_VIDEO_TRACK, USE_PIC_ORDER, AUTO_MYTH, WTV_MPEG2, DATE_FORMAT, +# NO_ROLL_UP, FORCED_RU, DIRECT_ROLLUP and SCREEN_TO_PROCESS. +# Any other tag below is not supported yet and is reported as unknown. +# # The Input Source tag option gives ability to user @@ -173,7 +181,7 @@ INPUT_SOURCE=0 # 0 = no # 1 = yes -#FIX_PADDINDG=0 +#FIX_PADDING=0 # If you hate the repeated lines caused by the roll-up # emulation, you can have ccextractor write only one @@ -203,7 +211,7 @@ INPUT_SOURCE=0 # 2 # 3 -#FORCED_RU +#FORCED_RU= # This tag trim line # This tag take number in its input and there meaning @@ -277,12 +285,12 @@ INPUT_SOURCE=0 # start extraction from the time specified # this tag only accepts SS, MM:SS or HH:MM:SS -#START_AT +#START_AT= # End extraction at the time specified # this tag only accepts SS, MM:SS or HH:MM:SS -#END_AT +#END_AT= # If no CC packets are detected based on the PMT, try # to find data in all packets by scanning. @@ -291,7 +299,7 @@ INPUT_SOURCE=0 # 0 = no # 1 = yes -#INVASTIGATE_PACKET=0 +#INVESTIGATE_PACKET=0 # If the video was recorder using a Hauppauge card, it # might need special processing. This parameter will @@ -309,7 +317,7 @@ INPUT_SOURCE=0 # 0 = no # 1 = yes -#MP4_VIDEO_TRACK +#MP4_VIDEO_TRACK= # File need to be encoding in which format # This tag take number in its input and there meaning diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 6ff459bb4..1ff0e86b5 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -789,20 +789,21 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch let mut opt = Options::default(); let mut _tlt_config = TeletextConfig::default(); - // Settings from ccextractor.cnf are applied first so command line options override them + // Settings from ccextractor.cnf are applied first so command line options override them. + // The messages are held back until the command line is parsed, because only then is it known + // whether messages go to stdout, stderr or nowhere (--stdout, --quiet). + let mut config_messages: Vec = Vec::new(); match std::fs::read_to_string(CONFIG_FILE_NAME) { Ok(contents) => { for warning in opt.apply_config(&contents) { - lib_ccxr::info!( + config_messages.push(format!( "{}:{}: {}, ignoring this line\n", - CONFIG_FILE_NAME, - warning.line, - warning.message - ); + CONFIG_FILE_NAME, warning.line, warning.message + )); } } Err(e) if e.kind() == std::io::ErrorKind::NotFound => {} - Err(e) => lib_ccxr::info!("Could not read {}: {}\n", CONFIG_FILE_NAME, e), + Err(e) => config_messages.push(format!("Could not read {}: {}\n", CONFIG_FILE_NAME, e)), } opt.parse_parameters( @@ -812,6 +813,13 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch &mut _profane, ); + if let Some(mut logger) = lib_ccxr::util::log::logger_mut() { + logger.set_target(opt.messages_target); + } + for message in config_messages { + lib_ccxr::info!("{}", message); + } + // Handle --list-tracks mode: list tracks and exit early if opt.list_tracks_only { use std::path::Path;