[FFmpeg-user] how to programmatically set live_start_index

Louis Letourneau lletourn49 at gmail.com
Wed Nov 16 17:37:27 EET 2016


I'm not sure if this belongs in user or devel, but here goes.

I'm working with m3u8 files. They can sometimes be live, sometimes VOD.

For live, I need to start the processing from the start. using the command
line I would

ffmpeg --live_start_index 0 -i file.m3u8 [...]

How do I reproduce this in code using the libraries?
I can read VOD just fine, it's only the live ones I can't process.
live_start_index is always -3
I tried
av_opt_set_int(av_format_ctx_->priv_data, "live_start_index", 0, 0)

but it just doesn't work
--------------->
    AVFormatContext* av_format_ctx_;
    if (avformat_open_input(&av_format_ctx_, filename.c_str(), NULL, NULL)
!= 0)
        return false;  // Couldn't open file

    // Retrieve stream information
    if (avformat_find_stream_info(av_format_ctx_, NULL) < 0)
        return false;

    cout << "Format: " << av_format_ctx_->iformat->name << endl;
    if(av_opt_set_int(av_format_ctx_->priv_data, "live_start_index", 0, 0)
!= 0)
        cerr << "Couldn't set option" << endl;
    av_dump_format(av_format_ctx_, 0, filename.c_str(), 0);
[.,..]
--------------->

I have looked at the examples, and I also understand ffplay and ffmpeg pass
the parameters using code in cmdutils, but my case isn't parameter based.

Thanks for the help
Louis


More information about the ffmpeg-user mailing list