Closed alkesta closed 13 years ago
(I can't understand English very well. I am sorry I may write wrong English.) I think I encountered the same problem.
Please modify the minimum height value of your preset file (upper side of the "height" block is minimum value) less equal 204 and try again. The calculation seems to keep original frame aspect ratio. But the preset values of the range of frame size deny your original frame aspect ratio. We have to preset minimum width and/or minimum height with calculating which have the same aspect ratio as the source video frame and which have the size smaller equal the maximum.
My trouble is:
Environment: Ubuntu 11.04 (Arista Transcoder 0.9.6) Input video: 1280x720 (pixel aspect ratio = 1.0) Target device: Sony PSP (480x272) Frame size of the video I got: 484x272
The frame aspect ratio of my source is 16:9. Before modifying the acceptable frame size is only 480x272 (not 16:9). So I have to modify the preset of the range of the frame size to accept 480x270 (16:9 and smaller than 480x272). I modified the minimum height to 270. Now I get the video which frame size is 480x270 and I can play it on PSP well.
By the way, I think the pixel aspect ratio is the parameter of the source video. I suggest to multiply owidth by the pixel aspect ratio.
--- transcoder.py 2010-07-09 05:58:05.000000000 +0900
+++ transcoder.py.modified 2011-05-31 15:42:53.895658489 +0900
@@ -367,6 +367,12 @@
hmin, hmax = self.preset.vcodec.height
owidth, oheight = self.info.videowidth, self.info.videoheight
+ try:
+ if self.info.videocaps[0].has_key("pixel-aspect-ratio"):
+ owidth = int(owidth * float(self.info.videocaps[0]["pixel-aspect-ratio"]))
+ except KeyError:
+ # The videocaps we are looking for may not even exist, just ignore
+ pass
width, height = owidth, oheight
# Scale width / height to fit requested min/max
@@ -403,12 +409,6 @@
vbox = "videobox top=%i bottom=%i ! ffmpegcolorspace ! " % \
(-px, -px)
- try:
- if self.info.videocaps[0].has_key("pixel-aspect-ratio"):
- width = int(width * float(self.info.videocaps[0]["pixel-aspect-ratio"]))
- except KeyError:
- # The videocaps we are looking for may not even exist, just ignore
- pass
# FIXME Odd widths / heights seem to freeze gstreamer
if width % 2:
I guess that setting minimum width and minimum height to 4 works well in most of cases.
Thanks, patch applied in 06c79cd
input video: 1280x544 wmin, wmax = 480 hmin, hmax = 272 after transcoding output video 640x272 After this code block:
Calculate video width/height and add black bars if necessary
dimension is 480x204. But next code block recalculate dimension to 640x272:
if height < hmin: height = hmin width = int((float(hmin) / oheight) * owidth) elif height > hmax: height = hmax width = int((float(hmax) / oheight) * owidth)