Evaluating AI Coding Engineering Capabilities: A Case Study on Batch Audio Extraction
When assessing AI programming tools, the focus should shift from simply generating code to delivering stable, maintainable software. Using a batch audio extraction tool as a case study, this article details the engineering principles required for production-ready applications, including requirement decomposition, architectural separation of UI and execution, task state machines, media probing, precise progress tracking, and robust error handling. It provides a comprehensive framework for evaluating and iterating AI-generated code from a prototype to a reliable engineering implementation.
1. Evaluating AI Coding: From “Can Generate” to “Can Deliver”
Asking an AI programming tool to generate a desktop application is no longer just about code completion. What truly matters is whether it can understand requirement constraints, establish a reasonable program structure, handle input anomalies, and run consistently and stably in a real-world environment.
A batch audio extraction tool is an excellent case study to observe these capabilities. It appears to be a simple “select video, specify format, click convert” process, but behind the scenes, it involves the file system, media processing, desktop event loops, background tasks, progress calculation, and resource recovery.
Therefore, when evaluating the generated results, one should not draw conclusions based solely on the volume of code, UI screenshots, or a single successful conversion. A more reasonable evaluation sequence is:
- Have the requirements been accurately translated into acceptable features?
- Can the software structure support time-consuming tasks without blocking the UI?
- Can the conversion process correctly handle different inputs and failure scenarios?
- Are the output files complete, safe, and located in a clear directory?
- Is the program easy to test, maintain, and extend?
The following content provides engineering implementation and acceptance methods. It does not imply that any specific model has passed these tests, nor does it offer unverified performance conclusions.
2. Establish a Requirements Checklist Before Discussing Code Quality
“Build a comprehensive, smoothly running tool” is not a clear enough development requirement. The more ambiguous the input to an AI programming tool, the more likely the generated result will only cover the ideal path.
It is recommended to break down the requirements into six groups.
1. File Import
The application should support selecting a single file, selecting multiple files, and scanning directories on demand. Recursive scanning must be explicitly enabled by the user to avoid accidentally importing a massive number of files in a single operation.
The file list should display at least the file name, source path, task status, and failure reason. When importing duplicates, identification should be based on the normalized full path rather than just the file name, as files with the same name may exist in different directories.
For directories that cannot be accessed during scanning, they should be logged and skipped rather than interrupting the entire import process.
2. Output Configuration
Users should be able to select the target audio type and output directory. Options related to audio quality should change dynamically based on the encoding method: lossy encoding typically focuses on parameters like bitrate, while lossless or uncompressed output is better suited for displaying settings like sample rate, bit depth, and channel count.
Do not mechanically place all parameters into a single form. Options irrelevant to the current output method should be hidden or disabled to prevent the UI from accepting settings that the underlying system does not actually use.
3. Conversion Control
Basic operations include start, cancel, remove task, clear list, and open output directory. Whether adding files is allowed during an ongoing conversion should also be defined in advance.
For an initial version, fixing the current batch is usually easier to implement and verify. Dynamically appending tasks requires further definition of queue updates, total progress adjustments, and batch completion conditions.
4. Status Feedback
A progress bar cannot replace status descriptions. The program must also distinguish between states such as waiting, probing media, converting, canceling, success, and failure, allowing the user to understand what the application is doing.
5. Security and Recovery
By default, existing files should not be overwritten, incomplete outputs should be cleaned up upon failure, and users should be allowed to view an error summary. For cancellation operations, it should also be specified whether the successfully completed results are retained.
6. Environment Check
A desktop UI launching does not equate to having media processing capabilities. Before starting a conversion, the application should check whether the underlying processing components are available, whether the target encoding is supported, and whether the output directory is writable.
3. Core Architecture: Separating UI, Scheduling, and Execution
The most common flaw in desktop applications is executing time-consuming conversions directly within button click events.
Most desktop UIs rely on an event loop to handle repainting, clicks, and window management. When an event handler takes too long to return, even if conversion is still in progress, the window may appear unresponsive, buttons may fail, or it may prompt as “Not Responding”.
A clear structure can be divided into four layers:
- UI Layer: Receives user operations and displays status.
- Task Scheduling Layer: Maintains the task queue, concurrency limits, and cancellation signals.
- Conversion Execution Layer: Probes media, launches processing processes, and collects results.
- File Management Layer: Generates output paths, cleans up temporary files, and commits successful results.
Background execution units should not arbitrarily and directly modify UI controls. A safer, standard approach is: the background sends events, and the UI thread periodically reads these events and updates the controls.
The schematic flow is as follows:
User clicks start-> Validate configuration-> Fix current batch-> Add tasks to queue-> Execute conversion in background-> Send progress and result events-> UI thread updates list and status bar
The key here is not how many background threads are used, but whether the boundaries of responsibility are clear and whether status updates are predictable.
4. Batch Processing Requires a Clear Task State Machine
If you use a simple “is completed” boolean to represent a task, you will quickly encounter problems like being unable to distinguish between cancellation and failure, repeated start clicks, or buttons not restoring after a task ends.
It is recommended to establish explicit states for individual tasks:
Pending -> Probing -> Converting -> Success|-> Failed|-> Canceling -> Canceled
For files without audio tracks, they can be recorded as failed or given a separate “Skipped” state, but this should be consistent within the product rules.
Each task should also be associated with the following information:
- Unique task identifier;
- Input and expected output paths;
- Actual conversion configuration used;
- Current status and progress;
- Start time and end time;
- Error category and brief description.
The task identifier is particularly important. When a background event reaches the UI, it should look up the corresponding task based on the identifier rather than relying on the row number in the list. Otherwise, sorting, deleting, or filtering could cause progress to be displayed on the wrong file.
5. Media Conversion: Probe First, Then Decide Strategy
File extensions can only serve as an initial screening criterion and cannot prove that the internal media content is valid. A seemingly normal video file might lack an audio track, contain multiple audio tracks, or have a corrupted media index.
Therefore, before converting, try to obtain:
- Whether an audio stream exists;
- Number of audio tracks and available metadata;
- Media duration;
- Audio encoding format;
- Sample rate and channel count.
If multiple audio tracks exist, the application should clearly specify which one to use. A basic version for general users can select the default audio track based on predefined rules, but it should not silently make an incomprehensible choice.
You should also distinguish between two types of operations.
Direct extraction means that when the encoding and target container are compatible, the original compressed data is retained without re-encoding. It usually processes faster and avoids the quality loss caused by repeated lossy encoding.
Re-encoding requires decoding and then generating new audio according to the target configuration. It is suitable for changing the encoding method, sample rate, or channel count, but consumes more computing resources; if lossy encoding is used, it may further degrade audio quality.
An application cannot simply change the extension to fake a format conversion, nor can it guarantee that any input can be losslessly converted to any target format.
6. Progress Bars Should Reflect Real Progress, Not Create False Certainty
The progress of a single file conversion can be estimated based on the processed media time relative to the total duration:
Single file progress = Processed media time / Total media duration
However, this method has prerequisites: the total duration is reliable, and the underlying component can continuously provide valid progress. If the media duration is unknown or the metadata is abnormal, an “indeterminate progress” state should be displayed rather than artificially advancing the progress at a uniform speed.
Batch total progress also has two common metrics:
- Counting by file quantity: simple and intuitive, but easily underestimates the impact of large files.
- Weighted by media duration: better aligns with workload distribution in some scenarios, but still cannot accurately represent actual time consumed.
The UI should ideally display both “number of completed tasks” and “current file progress” to prevent users from misunderstanding the estimated value as precise remaining time.
Even if the underlying progress reaches nearly 100%, the task should not be marked as successful until the processing process has ended and necessary validations are complete.
7. Explicit Output Directories and File Naming
“Default output to the current program directory” is not an inherently clear rule. The directory where the program files are located, the working directory at startup, and the user-selected directory might be three completely different locations.
Relative paths are typically affected by the current working directory; launching from a shortcut, terminal, or file manager may yield inconsistent results. The installation directory might also lack write permissions, so it cannot be taken for granted as the output location.
A more reliable solution is:
- Display the resolved absolute output path in the UI.
- Check before starting whether the directory exists, can be created, and is writable.
- Allow users to modify the path and save the last valid configuration if needed.
- Avoid describing the default path only in text while the actual behavior contradicts the description.
Naming conflicts also need explicit handling. A basic strategy could be appending an incremental number to the original file name, but with concurrent tasks, a simple “check for existence first, then write” can still cause race conditions. The scheduling layer should uniformly assign output names and, if necessary, use exclusive creation methods.
8. Mitigating Failure Risks with Temporary Files
Writing converted data directly to the final file name can easily leave results that appear normal but are actually incomplete.
A safer process is:
Determine final path-> Generate unique temporary path in the same output directory-> Execute conversion-> Check processing results-> Commit temporary file as final file-> Update task status
The temporary path needs to retain format information recognizable by the underlying processing component, or the execution layer must explicitly specify the output container to avoid format detection failures caused by temporary naming.
Completion checks should at least consider the process exit status, whether the file exists, whether the file size is reasonable, and whether the result can be probed again. For scenarios with higher requirements, decoding verification can be added, but the additional overhead must be weighed.
Renaming within the same file system is generally better at preventing users from seeing half-finished products, but the specific atomicity and overwrite behavior still depend on the runtime environment and cannot be guaranteed unconditionally.
9. Cancellation and Exit Are Core Features
A cancel button should not just modify the UI text. It needs to pass the cancellation intent to the scheduling and execution layers.
A reasonable process includes:
- Not starting tasks that have not yet executed;
- Sending a termination request to the currently running processing process;
- Waiting for necessary exits and resource recovery;
- Cleaning up incomplete temporary files;
- Retaining outputs that have already been successfully completed;
- Marking the related tasks as canceled.
Window closure should also use the same lifecycle management logic. If tasks are still running, the user should be prompted to choose between continuing to wait or canceling the exit, to prevent background processes from continuing to consume resources after the window disappears.
10. How to Evaluate AI-Generated Results
Passing a syntax check only proves that the code can be parsed at the syntax level; it does not prove that dependencies exist, media can be processed, the UI does not freeze, or exception recovery is correct.
It is recommended to establish at least the following acceptance matrix:
| Test Scenario | Key Checks |
|---|---|
| Single valid media file | Output is readable, audio tracks and config match expectations |
| Batch conversion of multiple files | Status maps correctly, failures do not affect subsequent tasks |
| File without audio track or corrupted | Clear prompt, no false success result generated |
| Paths with spaces and special characters | Parameters passed correctly, no command concatenation risks |
| Output directory not writable | Clear explanation before conversion or upon failure |
| Existing file with the same name | Default to no overwrite, name allocation is explainable |
| Cancellation or window close during conversion | Process cleanup is complete, no obvious residue |
| Large volume of file imports | UI remains responsive, resource usage is controllable |
When calling external processing processes, prioritize passing inputs as an array of parameters rather than concatenating user paths into a string executable by a command interpreter. This not only reduces path escaping issues but also mitigates command injection risks.
Additionally, check whether the runtime logs contain sufficient diagnostic information and whether they unnecessarily log sensitive paths. The UI should provide an understandable error summary, while diagnostic logs retain moderate detail; the two should be distinguished.
11. Iterative Path from Prototype to Maintainable Tool
The most effective route is not to demand all features at once, but to verify layer by layer:
Step 1: Implement single-file conversion to confirm the media processing pipeline is effective.
Step 2: Introduce background execution and event notifications to verify that the window still responds normally during conversion.
Step 3: Add batch queues, naming conflict handling, and single-task failure isolation.
Step 4: Improve cancellation, exit, temporary files, and error logging.
Step 5: Add enhancement features such as configuration saving, recursive directory scanning, and controlled concurrency.
Each step should retain test samples and expected results. This not only facilitates checking the AI programming output but also reduces regression issues during subsequent modifications.
Conclusion
The actual value of AI programming lies not in how many lines of code it generates at once, but in whether it helps developers establish the correct structure, exposes implicit constraints, and lowers the cost of verification and maintenance.
Taking the batch audio extraction tool as an example, what truly determines delivery quality is often not the file selection button or the format dropdown, but the background task organization, media probing, progress semantics, path rules, failure cleanup, and resource recovery. Incorporating these aspects into requirements and acceptance criteria is the only way to move from a “looks usable” demo to an engineering implementation with clear behavior, trustworthy results, and sustainable maintainability.
