sunlubo / SwiftFFmpeg

A Swift wrapper for the FFmpeg API
Apache License 2.0
511 stars 83 forks source link

Set analyzeduration, or similar options #9

Closed smhk closed 5 years ago

smhk commented 5 years ago

I'm wondering if there's a way to read, and set analyzeduration and similar options,

    let fmtCtx = AVFormatContext()
    fmtCtx.  something  .analyzeduration = 1000

opt.h ...

int av_set_options_string(void *ctx, const char *opts,
                          const char *key_val_sep, const char *pairs_sep);

/**
 * Parse the key-value pairs list in opts. For each key=value pair found,
 * set the value of the corresponding option in ctx.
 * .. etc

analyzeduration is an integer (microseconds) https://ffmpeg.org/ffmpeg-formats.html

I had a guess at reading it, let AD = try fmtCtx.integer(forKey: "analyzeduration") crashes,

I had a guess at this sort of thing, try fmtCtx.set(1000, forKey: "analyzeduration") crashes ..

Is it possible?

sunlubo commented 5 years ago

This code run successfully on my mac, please show me your crash info.

let fmtCtx = try AVFormatContext(url: "/Users/sun/AV/kda.flv")
try fmtCtx.set(1000, forKey: "analyzeduration")
print(try fmtCtx.integer(forKey: "analyzeduration"))
1000
Program ended with exit code: 0
iT-Boyer commented 2 years ago

I want to do it this way by options:

 let option:[String:String] = ["probesize":"4096"]
guard let _ = try? fmtCtx.findStreamInfo(options: [option]) else{return}

but print this log:Option 'probesize' not found.