GNOME Bugzilla – Bug 338991
[patch] Videoscale doesn't pass on pixel-aspect ratio
Last modified: 2006-04-28 14:33:58 UTC
Please describe the problem: Videoscale resets the pixel aspect ratio of an incoming stream to 1/1 unless specifically told not to through the caps. The default/correct behaviour should be to keep the incoming pixel aspect ratio unless something else is specified. Example of working gst-launch pipeline: gst-launch-0.10 dvdreadsrc title="5" ! decodebin name="dvd" dvd. ! ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)YUY2 ! videoscale method=1 ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=360,height=288,pixel-aspect-ratio=\(fraction\)16/15 ! ffmpegcolorspace ! xvimagesink dvd. ! audioconvert ! alsasink Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 63971 [details] [review] patch to handle PAR better like so?
The patch fixes the problem for me in Thoggen.
With this patch, using only width or height in the out caps it does not respect original aspect ratio. Using this pipeline over a file with 480 x 368: GST_DEBUG=videoscale:5 gst-launch-0.10 --gst-debug-no-color filesrc location="marlango y bose.avi" ! decodebin ! videoscale ! video/x-raw-yuv,width=100 ! ffmpegcolorspace ! ximagesink gives this debug output: DEBUG (0x8ae74c8 - 0:00:00.934618000) videoscale(24650) gstvideoscale.c(586):gst_video_scale_fixate_caps:<videoscale0> scaling input with 480x368 and PAR 1/1 to output PAR 1/1 DEBUG (0x8ae74c8 - 0:00:00.934641000) videoscale(24650) gstvideoscale.c(588):gst_video_scale_fixate_caps:<videoscale0> resulting output should respect ratio of 30/23 DEBUG (0x8ae74c8 - 0:00:00.934660000) videoscale(24650) gstvideoscale.c(597):gst_video_scale_fixate_caps:<videoscale0> keeping video height DEBUG (0x8ae74c8 - 0:00:00.934676000) videoscale(24650) gstvideoscale.c(609):gst_video_scale_fixate_caps:<videoscale0> scaling to 480x368 DEBUG (0x8ae74c8 - 0:00:00.934710000) videoscale(24650) gstvideoscale.c(629):gst_video_scale_fixate_caps:<videoscale0> fixated othercaps to video/x-raw-yuv, width=(int)100, height=(int)368, framerate=(fraction)25/1, pixel-aspect-ratio=(fraction)1/1, format=(fourcc)I420
Notice that also adding pixel-aspect-ratio to the above pipeline makes it loop forever. This code works for me for calculating width/height when only one of them is provided: /* start with same height, because of interlaced video */ if (h) { GST_DEBUG_OBJECT (base, "keeping video height"); w = h * num / den; } else if (w) { GST_DEBUG_OBJECT (base, "keeping video width"); h = w * den / num; } else { GST_DEBUG_OBJECT (base, "approximating but keeping video height"); h = from_h; w = h * num / den;
Created attachment 64187 [details] [review] updated patch don't ignore fixed output width and height.
what do you mean with "adding pixel-aspect-ratio to the above pipeline makes it loop forever"? I was unable to produce something that loops forever.
Well, I'm not sure now if the loop was caused when adding videorate element or without it (see http://bugzilla.gnome.org/show_bug.cgi?id=339013 ). I will try again with clean HEAD versions.
Yes, without using videoscale at all: gst-launch-0.10 -v --gst-debug-no-color filesrc location="Arrebato(Zulueta,1979).avi" ! decodebin ! videoscale ! video/x-raw-yuv,width=100,pixel-aspect-ratio=\(fraction\)1/1 ! ffmpegcolorspace ! ximagesink works correctly (i.e: it plays) but: gst-launch-0.10 -v --gst-debug-no-color filesrc location="Arrebato(Zulueta,1979).avi" ! decodebin ! videoscale ! video/x-raw-yuv,width=100,pixel-aspect-ratio=\(fraction\)2/1 ! ffmpegcolorspace ! ximagesink the pipeline remains in PAUSE state and never works: [...] /pipeline0/decodebin0/mad0.src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)48000, channels=(int)2 Program received signal SIGINT, Interrupt.
+ Trace 67811
Thread NaN (LWP 1632)
ok, that is normal, gst-launch cannot make a connection to ximagesink when the pixel-aspect-ratio does not match that of the xserver, the pipeline never prerolls. Does the patch otherwise work for you?
* gst/videoscale/gstvideoscale.c: (gst_video_scale_transform_caps), (gst_video_scale_fixate_caps), (gst_video_scale_src_event): Videoscale doesn't pass on pixel-aspect ratio. Handle all fixation cases better. Fixes #338991