ypresto / android-transcoder

MP4 video transcode using Android MediaCodec API, pure Java (not LGPL nor patent issue!). Supports API >= 18.
Apache License 2.0
833 stars 238 forks source link

640x360 Resolution #50

Open aaronwardle opened 7 years ago

aaronwardle commented 7 years ago

Hi,

First of all thanks for creating this great library it works super quick compared to a lot of other methods.

With our project we are recording video at 1080p 16:9 so we can make use of some camera features such as stabilisation, however we need to output the video at 640x360 resolution we have managed to get this working with your source code however we are finding that the output video is quite bad and has lots of artefacts unless we set the bitrate very high.

Do you have any suggestions on how we can improve the output quality?

Thanks Aaron

ypresto commented 7 years ago

See https://github.com/ypresto/android-transcoder/issues/40#issuecomment-277697028 . Supported resolutions (and combinations of it and bitrate) can be different by devices. And currently, there is no easy way to detect it. /etc/media_profiles.xml or etc. on each device might be useful for detection.

ypresto commented 7 years ago

For example, my device has below file: (It seems used by CamcorderProfile)

        ...

        <EncoderProfile quality="high" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="42000000"
                   width="3840"
                   height="2160"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

        <EncoderProfile quality="qcif" fileFormat="3gp" duration="60">
            <Video codec="h264"
                   bitRate="128000"
                   width="176"
                   height="144"
                   frameRate="30" />
            <Audio codec="amrnb"
                   bitRate="12200"
                   sampleRate="8000"
                   channels="1" />
        </EncoderProfile>

        <EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
            <Video codec="h264"
                   bitRate="512000"
                   width="320"
                   height="240"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="156000"
                   sampleRate="48000"
                   channels="2" />
        </EncoderProfile>

        <EncoderProfile quality="cif" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="1200000"
                   width="352"
                   height="288"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

       <EncoderProfile quality="480p" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="6000000"
                   width="720"
                   height="480"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

        <EncoderProfile quality="720p" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="12000000"
                   width="1280"
                   height="720"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

        <EncoderProfile quality="1080p" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="17000000"
                   width="1920"
                   height="1080"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

        <EncoderProfile quality="2160p" fileFormat="mp4" duration="30">
            <Video codec="h264"
                   bitRate="42000000"
                   width="3840"
                   height="2160"
                   frameRate="30" />
            <Audio codec="aac"
                   bitRate="96000"
                   sampleRate="48000"
                   channels="1" />
        </EncoderProfile>

        ...

    <VideoEncoderCap name="h264" enabled="true"
        minBitRate="64000" maxBitRate="100000000"
        minFrameWidth="176" maxFrameWidth="3840"
        minFrameHeight="144" maxFrameHeight="2160"
        minFrameRate="15" maxFrameRate="30" />

    ...
adrianknight89 commented 5 years ago

Unfortunately, 720p is too big for mobile phones and users with low bandwidth connection. I too would like to see the ability to produce 360p videos.