DrKLO/Telegram · warning

usage: %s [options] input_file output_file\n

Error message

usage: %s [options] input_file output_file\n

What it means

repacketizer_demo is a CLI utility that reads length-prefixed Opus packets from a binary input file and either merges multiple packets into one (-merge N) or splits multi-frame packets into individual frames (-split). With fewer than 3 arguments (program name + input + output), it prints the usage string and returns EXIT_FAILURE. The usage() function at line 39 only prints to stderr; it does not exit, so the caller checks argc and exits.

Source

Thrown at TMessagesProj/jni/opus/src/repacketizer_demo.c:41

   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "opus.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_PACKETOUT 32000

void usage(char *argv0)
{
   fprintf(stderr, "usage: %s [options] input_file output_file\n", argv0);
}

static void int_to_char(opus_uint32 i, unsigned char ch[4])
{
    ch[0] = i>>24;
    ch[1] = (i>>16)&0xFF;
    ch[2] = (i>>8)&0xFF;
    ch[3] = i&0xFF;
}

static opus_uint32 char_to_int(unsigned char ch[4])
{
    return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16)
         | ((opus_uint32)ch[2]<< 8) |  (opus_uint32)ch[3];
}

int main(int argc, char *argv[])
{

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Provide both input and output file paths as positional arguments: `repacketizer_demo [options] input_file output_file`.
  2. If using options, ensure they appear before the two positional file arguments (the loop at line 74 iterates only up to argc-2).

Example fix

// before
repacketizer_demo input.oct
// after
repacketizer_demo input.oct output.oct
Defensive patterns

Strategy: validation

Validate before calling

// Validate argument count before invoking repacketizer_demo
if (argc < 3) {
    fprintf(stderr, "usage: %s [options] input_file output_file\n", argv[0]);
    return EXIT_FAILURE;
}

Prevention

When it happens

Trigger: Running the binary with zero, one, or two total arguments (e.g., just `repacketizer_demo` or `repacketizer_demo input.16k` without an output path). The check at line 69 requires argc >= 3.

Common situations: Script typo missing the output argument; unfamiliarity with the tool's required positional arguments; shell quoting that swallowed an argument.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/87131ed52f5ed152. Report an issue: GitHub.