JohanBlome / encapp

Easy way to test video encoders in Android in large scale.
BSD 3-Clause "New" or "Revised" License
20 stars 15 forks source link

Downscale not working #194

Closed saurabh-ittiam closed 4 months ago

saurabh-ittiam commented 4 months ago

I understand that the encapp supports change in resolution on the fly. I have not been able to get it working. How to configure the encapp to downscale in encode or transcode path? Which java file performs this operation?

saurabh-ittiam commented 4 months ago

Hello @JohanBlome Could you please take a look at it and guide me how to enable downscale?

JohanBlome commented 4 months ago

There is no scaling available unless using an encoded input and decodes it to a surface. The reason for this is that 1) for scaling buffer the number of ways to do it (and opinions on the right way) are so many. For the purpose of Encapp doing the scaling outside of Encapp and let the encoder do what it does is more productive. 2) The scaling of surfaces on the other hand is something that have fewer ways to do it and most often the default way is used and therefore of more interesting to look at.

To test scaling you will need an encoded source, decode it into a surface and then encode at a different resolution. If this does not work there is a bug and I'll happily take a look at it.

chemag commented 4 months ago

Saurabh, are you concerned about surface-based scaling, or about something like vendor.qti-ext-enc-caps-preprocess or vendor.qti-ext-down-scalar?

JohanBlome commented 4 months ago

That also works if you have a Qcom chipset. Even with buffers (I think).

chemag commented 4 months ago

That also works if you have a Qcom chipset. Even with buffers (I think).

Yeah. The extensions I suggested (vendor.qti-ext-enc-caps-preprocess and vendor.qti-ext-down-scalar) are QC-only (the "qti" part should give it).

JohanBlome commented 4 months ago

I verified that the following works: test { input { filepath: "x_1920x1080.mp4" } common { id: "bitrate_surface" description: "Verify encoding bitrate - surface" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" surface: true resolution: "320x200" } }

And this works as well: test { input { filepath: "walk1.y4m" } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" resolution: "320x200" bitrate: "90 Mbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" }
parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" }
parameter { key: "quality" type: intType value: "100" } } }

With one problem. You will have to set the pix format on the command line --pix_fmt nv12 (I'll fix this error).

saurabh-ittiam commented 4 months ago

Saurabh, are you concerned about surface-based scaling, or about something like vendor.qti-ext-enc-caps-preprocess or vendor.qti-ext-down-scalar?

Thanks. But I am looking for generic scalar (default Android).

saurabh-ittiam commented 4 months ago

I verified that the following works: test { input { filepath: "x_1920x1080.mp4" } common { id: "bitrate_surface" description: "Verify encoding bitrate - surface" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" surface: true resolution: "320x200" } }

And this works as well: test { input { filepath: "walk1.y4m" } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" resolution: "320x200" bitrate: "90 Mbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" } parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" } parameter { key: "quality" type: intType value: "100" } } }

With one problem. You will have to set the pix format on the command line --pix_fmt nv12 (I'll fix this error).

Thanks for the tests you performed at your end. I will use these as reference and check. This is good to know.

JohanBlome commented 4 months ago

I verified that the following works: test { input { filepath: "x_1920x1080.mp4" } common { id: "bitrate_surface" description: "Verify encoding bitrate - surface" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" surface: true resolution: "320x200" } }

And this works as well: test { input { filepath: "walk1.y4m" } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" resolution: "320x200" bitrate: "90 Mbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" } parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" } parameter { key: "quality" type: intType value: "100" } } }

With one problem. You will have to set the pix format on the command line --pix_fmt nv12 (I'll fix this error).

The latter example is flawed. Encapp will scale it before running: I tried: " test { input { filepath: "X.y4m" pix_fmt: nv12 } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" }
parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" }
parameter { key: "quality" type: intType value: "100" } } } " It does encode but fails writing the container. I'll add this to my backlog.

JohanBlome commented 4 months ago

I verified that the following works: test { input { filepath: "x_1920x1080.mp4" } common { id: "bitrate_surface" description: "Verify encoding bitrate - surface" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" surface: true resolution: "320x200" } } And this works as well: test { input { filepath: "walk1.y4m" } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" resolution: "320x200" bitrate: "90 Mbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" } parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" } parameter { key: "quality" type: intType value: "100" } } } With one problem. You will have to set the pix format on the command line --pix_fmt nv12 (I'll fix this error).

The latter example is flawed. Encapp will scale it before running: I tried: " test { input { filepath: "X.y4m" pix_fmt: nv12 } common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } configure { codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" } parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" } parameter { key: "quality" type: intType value: "100" } } } " It does encode but fails writing the container. I'll add this to my backlog.

This works now, the following was sent: " test { common { id: "bitrate_surface" description: "Verify encoding bitrate - buffer" } input { filepath: "/sdcard/walk1.y4m.1920x1080.29.97.nv12.yuv" resolution: "1920x1080" pix_fmt: nv12 framerate: 29.97 } configure { parameter { key: "vendor.qti-ext-down-scalar.output-width" type: intType value: "320" } parameter { key: "vendor.qti-ext-down-scalar.output-height" type: intType value: "200" } parameter { key: "quality" type: intType value: "100" } codec: "c2.qti.hevc.encoder" bitrate: "500 kbps" } } " Result was a downscaled playable video. Fix 21d7069596dc47b578990681e904ca6a76dcd88d .