[Libav-user] Help with FFMPEG

Pedro Constantino pedro.constantino at tekever.com
Thu Jul 18 13:48:46 EEST 2019


Hi,

I am new to FFMPEG and video streaming, and I am stuck in a problem for a
couple of weeks now. I will describe the problem that I am having hoping
that someone could help.

*Context:*
I want to stream a video from VLC (RTSP and MP4) to my C# application where
I want to reencode the video frames to OGG and forward the stream to an
Icecast Server.

*Problem:*
I am getting the error  "*[ogg @ 0000020ff60ac100] Extradata corrupted*" and
I have no idea on how to fix this. I have the following code

 private bool openOutput()
        {

            int ret;
            _pOutputFormatContext = ffmpeg.avformat_alloc_context();
            fixed (AVFormatContext** ppOutputFormatContext =
&_pOutputFormatContext)
            {
                ret =
ffmpeg.avformat_alloc_output_context2(ppOutputFormatContext, null, "ogg",
configuration.Destination);
                //ret =
ffmpeg.avformat_alloc_output_context2(ppOutputFormatContext, null, "webm",
configuration.Destination);
                if (ret < 0)
                {
                    return false;
                }
            }

            AVOutputFormat* out_format = ffmpeg.av_guess_format(null,
configuration.Destination, null);

            // Configure output video stream
            _pOutputStream =
ffmpeg.avformat_new_stream(_pOutputFormatContext, null);

            AVStream* pInputVideoStream = null;

            for (var i = 0; i < _pInputFormatContext->nb_streams; i++)
            {
                if (_pInputFormatContext->streams[i]->codec->codec_type ==
AVMediaType.AVMEDIA_TYPE_VIDEO)
                {
                    pInputVideoStream = _pInputFormatContext->streams[i];
                }
            }

            _pOutputStream->avg_frame_rate =
pInputVideoStream->avg_frame_rate;
            _pOutputStream->time_base = pInputVideoStream->time_base;
            _pOutputStream->sample_aspect_ratio =
pInputVideoStream->sample_aspect_ratio;
            ffmpeg.avcodec_parameters_copy(_pOutputStream->codecpar,
pInputVideoStream->codecpar);

            _pOutputStream->codecpar->codec_type =
AVMediaType.AVMEDIA_TYPE_VIDEO;
            _pOutputStream->codecpar->codec_id =
AVCodecID.AV_CODEC_ID_THEORA;

            AVDictionary* opt_dict;

            ffmpeg.av_dict_set(&opt_dict, "content_type",
"application/ogg", 0);
            ffmpeg.av_dict_set(&opt_dict, "user_agent", "GCS", 0);

            fixed (AVFormatContext** ppOutputFormatContext =
&_pOutputFormatContext)
            {
                ret = ffmpeg.avio_open2(&_pOutputFormatContext->pb,
configuration.Destination, ffmpeg.AVIO_FLAG_WRITE, null, &opt_dict);
                if (ret < 0)
                {
                    return false;
                }
            }

            ret = ffmpeg.avformat_write_header(_pOutputFormatContext, null);

            if (ret < 0)
            {
                return false;
            }

            ffmpeg.av_dump_format(_pOutputFormatContext, 0,
configuration.Destination, 1);

            return true;
        }


What am I doing wrong? Or what am I missing?

Best regards,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190718/4bb77438/attachment.html>


More information about the Libav-user mailing list