Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.
3058 Discussions

Media for mobile issue with finish the sclaing video

Dmitry_K_5
Beginner
260 Views

Hello,

I have applied M4M solution for scaling video in my app and on reasonable amount of videos (6-20 items) it mostly each time ended with issue. The issue is the transformation can not be stopped. App is processing video almost till 99% and after that I noticed constant call of garbage collector.

It is float bug which means it can not be reproduce with guarantee each time, but for reasonable amount of video it is almost happens every time. Please see my module below. I run it on Android 4.4. Xiaomi Note from the Service.

Do you have any idea why this issue happens?

08-25 13:04:36.509 29887-10194/com.example D/TAG: VideoProcessor:onProgress: 0.99767864
08-25 13:04:36.509 29887-10194/com.example D/TAG: VideoProcessor:onProgress: 0.9989656
08-25 13:04:37.839 29887-10194/com.example D/dalvikvm: GC_FOR_ALLOC freed 11342K, 34% free 52789K/79940K, paused 52ms, total 52ms
08-25 13:04:41.449 29887-10194/com.example D/dalvikvm: GC_FOR_ALLOC freed 11316K, 34% free 52771K/79940K, paused 47ms, total 47ms

public class MediaForMobile {

private static final String DEFAULT_VIDEO_MIME_TYPE = "video/avc";
private static final int DEFAULT_BITRATE = 2500;
private static final int DEFAULT_FRAME_RATE = 30;
private static final int DEFAULT_VIDEO_FRAME_INTERVAL = 1;

private static final String DEFAULT_AUDIO_MIME_TYPE = "audio/mp4a-latm";
private static final int DEFAULT_AUDIO_PROFILE = MediaCodecInfo.CodecProfileLevel.AACObjectLC;
private static final int DEFAULT_AUDIO_BITRATE = 96 * 1024;
private static final int DEFAULT_AUDIO_SAMPLE_RATE = 44100;
private static final int DEFAULT_AUDIO_CHANNEL_COUNT = 2;

private AudioFormat originAudioFormat;
private MediaComposer mediaComposer;
private AndroidMediaObjectFactory factory;
private Uri mediaUri;

public void init(Context context, org.m4m.IProgressListener listener, CopyFileParams params) {
    try {
        factory = new AndroidMediaObjectFactory(context);
        mediaComposer = new org.m4m.MediaComposer(factory, listener);

        mediaUri = new Uri(params.getFrom().getFile().getAbsolutePath());
        Log.d(App.TAG_MEDIA, "TAG_MEDIA: " + mediaUri);
        MediaFileInfo mediaFileInfo = new org.m4m.MediaFileInfo(new AndroidMediaObjectFactory(context));
        mediaFileInfo.setUri(mediaUri);
        originAudioFormat = (org.m4m.AudioFormat) mediaFileInfo.getAudioFormat();
        Log.d(App.TAG, "Video format: " + mediaFileInfo.getVideoFormat().getMimeType());
    } catch (IOException e) {
        Log.e(App.TAG, "Failed to obtain the path", e);
    }
}

public void configureVideoEncoder(Pair<Integer, Integer> videoParams) {
    VideoFormatAndroid videoFormat = new VideoFormatAndroid(
            DEFAULT_VIDEO_MIME_TYPE,
            videoParams.first,
            videoParams.second
    );
    videoFormat.setVideoBitRateInKBytes(DEFAULT_BITRATE);
    videoFormat.setVideoFrameRate(DEFAULT_FRAME_RATE);
    videoFormat.setVideoIFrameInterval(DEFAULT_VIDEO_FRAME_INTERVAL);
    videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
    mediaComposer.setTargetVideoFormat(videoFormat);
}

public void configureAudioEncoder() {
    AudioFormatAndroid audioFormat = new AudioFormatAndroid(
            DEFAULT_AUDIO_MIME_TYPE,
            originAudioFormat.getAudioSampleRateInHz(),
            originAudioFormat.getAudioChannelCount()
    );
    audioFormat.setAudioBitrateInBytes(DEFAULT_AUDIO_BITRATE);
    audioFormat.setAudioProfile(DEFAULT_AUDIO_PROFILE);
    mediaComposer.setTargetAudioFormat(audioFormat);
}

public void transcodeVideo(CopyFileParams params) {
    try {
        mediaComposer.addSourceFile(mediaUri);
        mediaComposer.setTargetFile(params.getTo().getFile().getAbsolutePath());
        mediaComposer.start();
    } catch (IOException e) {
        Log.e(App.TAG, "Failed to obtain file paths", e);
    }
}

public void release() {
    mediaComposer = null;
}

}

0 Kudos
1 Reply
Anna_B_Intel
Employee
260 Views

Hi Dmitry,

Media for Mobile became open source, so you can ask your questions here: https://github.com/INDExOS/media-for-mobile This forum is dedicated to other products: Media SDK and Media Server Studio.

Best wishes,

Anna

0 Kudos
Reply