zmwangx/rust-ffmpeg

Encoder not parsing options?

miluxmilux opened this issue · 1 comments

Hi there,
Thanks for your work on this crate! I'm trying to modify the transcode_audio.rs example with more encoder options, but they don't seem to be taken into account. What am I doing wrong?
I just copied parse_opts from the other example and replaced line 112 with:

const DEFAULT_PARAMS: &str = "c:a=copy,hls_time=4,hls_playlist_type=vod,hls_segment_type=fmp4,hls_list_size=0,hls_segment_filename='audio-%d.m4s'";
let opts = parse_opts(DEFAULT_PARAMS.to_string()).expect("Could not parse args");
let encoder = encoder
     .open_as_with(codec, opts)
     .expect("Failed to open encoder with options"); 

It compiles and produces output, but doesn't seem to take the options into account. Any idea?
Thanks!

c:a=copy,hls_time=4,hls_playlist_type=vod,hls_segment_type=fmp4,hls_list_size=0,hls_segment_filename='audio-%d.m4s'

Those aren't codec options. The c:a=copy is a convenience option and the rest are for the hls muxer. Pretty easy to distinguish what's an encoder option and what's not: the ones you replaced in the x264 example can be found in https://ffmpeg.org/ffmpeg-codecs.html; yours are in https://ffmpeg.org/ffmpeg-formats.html. You can't just cram whatever options you specify on an FFmpeg command line, libav* don't work like that. The FFmpeg frontend is mostly outside the libav* libraries.

Study the format part of the API, e.g. format::open_with, to use muxers.