[Libav-user] Help with FFMPEG

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Help with FFMPEG

Pedro Constantino
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

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help with FFMPEG

Carl Eugen Hoyos-2
Am Do., 18. Juli 2019 um 12:54 Uhr schrieb Pedro Constantino
<[hidden email]>:
> 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.

Does this work with ffmpeg, the command line interface?
If it does not work, there is a good chance that the issue is not in your code.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help with FFMPEG

Pedro Constantino
Hi Carl,

Yes, I was able to do this by command line

On Thu, Jul 18, 2019 at 12:11 PM Carl Eugen Hoyos <[hidden email]> wrote:
Am Do., 18. Juli 2019 um 12:54 Uhr schrieb Pedro Constantino
<[hidden email]>:
> 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.

Does this work with ffmpeg, the command line interface?
If it does not work, there is a good chance that the issue is not in your code.

Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help with FFMPEG

Carl Eugen Hoyos-2
In reply to this post by Pedro Constantino
Am Do., 18. Juli 2019 um 12:54 Uhr schrieb Pedro Constantino
<[hidden email]>:

> 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

It appears that you actually want to reencode to theora, but I don't see that
in your code.

> and forward the stream to an Icecast Server.
>
> Problem:
> I am getting the error  "[ogg @ 0000020ff60ac100] Extradata corrupted"

Did you try to forward the extradata that the theora encoder produces
to the ogg muxer?

Please do not top-post here, Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help with FFMPEG

Pedro Constantino
How am am I supposed to reencode? From the examples I saw, they only copied the parameters and set the new codec id. Do I need some extra step on my code?

On Thu, Jul 18, 2019 at 12:23 PM Carl Eugen Hoyos <[hidden email]> wrote:
Am Do., 18. Juli 2019 um 12:54 Uhr schrieb Pedro Constantino
<[hidden email]>:

> 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

It appears that you actually want to reencode to theora, but I don't see that
in your code.

> and forward the stream to an Icecast Server.
>
> Problem:
> I am getting the error  "[ogg @ 0000020ff60ac100] Extradata corrupted"

Did you try to forward the extradata that the theora encoder produces
to the ogg muxer?

Please do not top-post here, Carl Eugen
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".