Собрав arista озадачился не работающим пресетом для PSP. После
, сделал фикс в 0.9.6-2 все работает.
Патч исправляет расчет высоты и ширины изображения с учетом необходимой кратности 16-ти и вносит правильные параметры в пресет:
Код: Выделить всё
diff -ur arista-0.9.6-orig/arista/transcoder.py arista-0.9.6/arista/transcoder.py
--- arista-0.9.6-orig/arista/transcoder.py 2010-07-08 23:58:05.000000000 +0300
+++ arista-0.9.6/arista/transcoder.py 2011-01-02 01:08:36.000000000 +0200
@@ -363,45 +363,65 @@
# =================================================================
# Calculate video width/height and add black bars if necessary
# =================================================================
- wmin, wmax = self.preset.vcodec.width
- hmin, hmax = self.preset.vcodec.height
-
+ wmin, wmax = self.preset.vcodec.width # should be multiples of 16
+ hmin, hmax = self.preset.vcodec.height # should be multiples of 16
+
owidth, oheight = self.info.videowidth, self.info.videoheight
width, height = owidth, oheight
+ deviceaspectratio = wmax/hmax # PSP: 480/272=1.76(16:9) wmin, hmin 368x208
+ oaspectratio = owidth/oheight # Sintel_1280x544: 1280/544=2.35 320x136
+ cropvalue = 0
+ vbox = ""
+
# Scale width / height to fit requested min/max
- if owidth < wmin:
- width = wmin
- height = int((float(wmin) / owidth) * oheight)
- elif owidth > wmax:
- width = wmax
- height = int((float(wmax) / owidth) * oheight)
-
- if height < hmin:
- height = hmin
- width = int((float(hmin) / oheight) * owidth)
- elif height > hmax:
+ if deviceaspectratio == oaspectratio: # for 1.76 movie
+ width = wmax
height = hmax
- width = int((float(hmax) / oheight) * owidth)
-
- # Add any required padding
- # TODO: Remove the extra colorspace conversion when no longer
- # needed, but currently xvidenc and possibly others will fail
- # without it!
- vbox = ""
- if width < wmin and height < hmin:
- wpx = (wmin - width) / 2
- hpx = (hmin - height) / 2
- vbox = "videobox left=%i right=%i top=%i bottom=%i ! ffmpegcolorspace ! " % \
- (-wpx, -wpx, -hpx, -hpx)
- elif width < wmin:
- px = (wmin - width) / 2
- vbox = "videobox left=%i right=%i ! ffmpegcolorspace ! " % \
- (-px, -px)
- elif height < hmin:
- px = (hmin - height) / 2
- vbox = "videobox top=%i bottom=%i ! ffmpegcolorspace ! " % \
- (-px, -px)
+ elif deviceaspectratio < oaspectratio: # for 2.35 movie
+ if owidth < wmin:
+ width = wmin # width = 368
+ height = int((float(wmin) / owidth) * oheight) # height = 156
+ while height % 16: #if height not multiples of 16
+ height += 1 # height = 160 multiples of 16
+ width = int((float(height) / oheight) * owidth) # new width = 376
+ while (width + cropvalue) % 16:
+ cropvalue += 1
+ px = -(cropvalue / 2) # add padding
+ elif owidth > wmax:
+ width = wmax # width = 480
+ height = int((float(wmax) / owidth) * oheight) # height = 204
+ while height % 16: #if height not multiples of 16
+ height += 1 # height = 208 multiples of 16
+ width = int((float(height) / oheight) * owidth) # # new width = 489
+ if width % 2:
+ width += 1 # width = 490
+ cropvalue = width - wmax # width crop needed - 10 px
+ px = cropvalue / 2
+ if cropvalue > 0:
+ vbox = "videobox left=%i right=%i ! ffmpegcolorspace ! " % (px, px)
+ elif deviceaspectratio < oaspectratio: # for 1.33 movie
+ if height < hmin:
+ height = hmin
+ width = int((float(hmin) / oheight) * owidth)
+ while width % 16:
+ width += 1
+ height = int((float(width) / owidth) * oheight)
+ while (height + cropvalue) % 16:
+ cropvalue += 1
+ px = -(cropvalue / 2)
+ elif oheight > hmax:
+ height = hmax
+ width = int((float(hmax) / oheight) * owidth)
+ while width % 16:
+ width += 1
+ height = int((float(height) / oheight) * owidth)
+ if height % 2:
+ height += 1
+ cropvalue = height - hmax
+ px = cropvalue / 2
+ if cropvalue > 0:
+ vbox = "videobox top=%i bottom=%i ! ffmpegcolorspace ! " % (px, px)
try:
if self.info.videocaps[0].has_key("pixel-aspect-ratio"):
diff -ur arista-0.9.6-orig/presets/psp.json arista-0.9.6/presets/psp.json
--- arista-0.9.6-orig/presets/psp.json 2010-06-10 03:11:41.000000000 +0300
+++ arista-0.9.6/presets/psp.json 2011-01-05 03:41:16.101000079 +0200
@@ -1,5 +1,5 @@
{
- "version": "1.1",
+ "version": "1.2",
"description": "H.264/AAC for Playstation portable",
"author": {
"name": "Daniel G. Taylor",
@@ -11,43 +11,43 @@
{
"vcodec": {
"passes": [
- "pass=qual quantizer=27 subme=4 threads=0"
+ "bitrate=420 vbv-buf-capacity=500 pass=pass1 cabac=true dct8x8=false ref=3 bframes=3 b-pyramid=false weightb=false trellis=true me=umh subme=6 threads=0"
],
- "container": "qtmux",
+ "container": "mp4mux",
"name": "x264enc",
"height": [
- 272,
+ 144,
272
],
"width": [
- 480,
+ 320,
480
],
"rate": [
- 1,
+ 25,
25
]
},
- "container": "qtmux",
- "name": "Low",
+ "container": "mp4mux",
+ "name": "Normal",
"extension": "mp4",
"acodec": {
"passes": [
- "bitrate=96000 profile=LC"
+ "bitrate=128000 profile=LC"
],
- "container": "qtmux",
+ "container": "mp4mux",
"name": "faac",
"depth": [
- 8,
- 24
+ 16,
+ 16
],
"channels": [
- 1,
+ 2,
2
],
"width": [
- 8,
- 24
+ 16,
+ 16
],
"rate": [
48000,
@@ -58,43 +58,43 @@
{
"vcodec": {
"passes": [
- "pass=qual quantizer=21 me=umh subme=6 ref=2 threads=0"
+ "bitrate=320 vbv-buf-capacity=500 pass=pass1 cabac=true dct8x8=false ref=3 bframes=3 b-pyramid=false weightb=false trellis=true me=umh subme=6 threads=0"
],
- "container": "qtmux",
+ "container": "mp4mux",
"name": "x264enc",
"height": [
- 272,
- 272
+ 112,
+ 208
],
"width": [
- 480,
- 480
+ 368,
+ 368
],
"rate": [
- 1,
- 30
+ 15,
+ 15
]
},
- "container": "qtmux",
- "name": "Normal",
+ "container": "mp4mux",
+ "name": "Low",
"extension": "mp4",
"acodec": {
"passes": [
- "bitrate=128000 profile=LC"
+ "bitrate=96000 profile=LC"
],
- "container": "qtmux",
+ "container": "mp4mux",
"name": "faac",
"depth": [
- 8,
- 24
+ 16,
+ 16
],
"channels": [
- 1,
+ 2,
2
],
"width": [
- 8,
- 24
+ 16,
+ 16
],
"rate": [
48000,