Apparently, ffmpeg uses SAR (sample aspect ratio) as fundamental metric.

Cingg's aspect_ratio variable in asset.h is DISPLAY aspect ratio, so we try
to work out DAR from sample_aspect_ratio provided by ffmpeg and (coded)
dimensions

https://stackoverflow.com/questions/69560311/confused-about-parpixel-aspect-ratio-in-video

====

SAR and PAR are the same. sample is the generic term for the elementary
"particles" of media. pixel is specific to video, whereas audio has sample.

sample aspect ratio is the term used in modern video codec standards.

The only equation to know is SAR * width / height = DAR.


====


we do not display sar/dar in our asset info, I guess we better to!


in ffmpeg.C


AVRational FFMPEG::to_sample_aspect_ratio(Asset *asset)

{

#if 1

        double display_aspect = asset->width / (double)asset->height;

        double sample_aspect = display_aspect / asset->aspect_ratio;

        int width = 1000000, height = width * sample_aspect + 0.5;

        float w, h;

        MWindow::create_aspect_ratio(w, h, width, height);

        return (AVRational){(int)w, (int)h};

-====-


and


-====-

vid->length = secs * vid->frame_rate;

                        vid->aspect_ratio =
(double)st->sample_aspect_ratio.num / st->sample_aspect_ratio.den;

                        vid->nudge = st->start_time;


-===--


May be this line needs correcting ? (on decoding)


-===--

float FFMPEG::ff_aspect_ratio(int stream)
                        {

        //return ffvideo[stream]->aspect_ratio;

        AVFormatContext *fmt_ctx = ffvideo[stream]->fmt_ctx;

        AVStream *strm = ffvideo[stream]->st;
                                AVCodecParameters *par =
ffvideo[stream]->st->codecpar;

        AVRational dar;

        AVRational sar = av_guess_sample_aspect_ratio(fmt_ctx, strm, NULL);

        if (sar.num && ffvideo[stream]->get_rotation_angle() == 0) {
                                   av_reduce(&dar.num, &dar.den,

                      par->width  * sar.num,

                      par->height * sar.den,

                      1024*1024);

                      return av_q2d(dar);

                      }

        return ffvideo[stream]->aspect_ratio;

}


-==--


I copied it from ffmpeg.


there is plenty of more complex explanations, for example at


https://lurkertech.com/lg/pixelaspect/


But I think for now we better to concentrate on what ffmpeg gives and takes.
-- 
Cin mailing list
Cin@lists.cinelerra-gg.org
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to