44
Intel® INDE Android Media Pack Дмитрий Рыжков Архитектор Программного Обеспечения Intel

резников дмитрий

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: резников дмитрий

Intel® INDE Android Media Pack Дмитрий Рыжков

Архитектор Программного Обеспечения

Intel

Page 2: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Пакет рассчитанный на разработчиков

нативных и мультимедийных приложений

Отладка

Оптимизация

Повышение производительности и

энергоэффективности приложений

2

Intel® INDE

Page 3: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Находится по адресу http://software.intel.com/en-us/intel-inde

3

Intel® INDE

Page 4: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice 4

Менеджер пакетов

Page 5: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Media

• Intel C++ Compiler for Android

• Intel Threading Building Blocks

• Compute Code Builder

• Intel GPA

5

Что внутри

Page 6: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Транскодирование видео с заданными параметрами.

• Обрезка видео (сегментирование)

• Склейка нескольких файлов в один

• Захват видео в приложениях, использующих OpenGL

• Наложение аудио, видео эффектов

• Трансляция видео

• Получение информации о медиа файле

• Работает на всех устроствах с Android 4.3 и выше

6

Media

Page 7: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Оптимизирующий компилятор доступный для Android

• Может дать до 30% прироста производительности после

простой пересборки проекта

• Стоимость при покупке как отдельного продукта $79.95, в

составе INDE – бесплатно

• Совместим с GNU C++, легко интегрируется в Eclipse, MS

Visual Studio

7

Intel C++ Compiler for Android

Page 8: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Кроссплатформенная библиотека шаблонов для создания

параллельного кода

• Абстрагирует работу над созданием, синхронизацией

потоков, данных

• Скрывает детали архитектуры, позволяя работать на более

высоком, абстрактном уровне

8

Intel Threading Building Blocks

Page 9: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Отладка, анализ кода Google Renderscript и OpenCL

• Работает как отдельно, так и как часть Eclipse или MS

Visual Studio

9

Compute Code Builder

Page 10: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Инструменты для анализа различных факторов, влияющих на

производительность и энергопотребление мобильных

приложений

• GPA System Analyzer

• GPA Frame Analyzer

• GPA Platform Analyzer

10

Intel GPA

Page 11: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

11

GPA System Analyzer

Page 12: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

12

GPA Frame Analyzer

Page 13: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

13

GPA Frame Analyzer

Page 14: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

14

GPA Platform Analyzer

Page 15: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Media Pack

15

Page 16: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Надстройка над нативными компонентами Android

• MediaExtractor

• MediaCodec

• MediaMuxer

• Использует аппаратное ускорение

• Работает на всех архитектурах

• Требование – Android 4.3 и выше

16

Media Pack

Page 17: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice 17

Установка

Page 18: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Поставляется как набор библиотек + примеры

18

Media Pack

Page 19: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Game Capturing – захват видео из приложения, использующего Open GL

• Transcode Video – преобразование видео с заданными параметрами

• Join Video – склейка двух видео файлов

• Cut Video – вырезание из видео заданного сегмента

• Video Effect – преобразование видео с наложением видео эффекта

• Audio Effect - преобразование видео с наложением аудио эффекта

• Streaming from Camera – трансляция видео с камеры на сервис Wowza

• Get Media File Info – получение информации о медиа файле

19

Примеры

Page 20: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Перекодирование видео

20

Page 21: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice 21

Перекодирование видео • ComposerTranscodeActivity – обеспечивает выбор видео файла и

отображает его на предпросмотре

• ComposerTranscodeCoreActivity – выводит подробную информацию о

выбранном видео файле, выполняет его преобразование

Page 22: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Ключевым компонентом является класс MediaComposer

Реализация включает 5-ть простых шагов

• Создать объект MediaComposer

• Указать путь к исходному, результирующему файлам

• Задать параметры результирующего видео

• Реализовать интерфейс MediaComposer.IProgressListener

• Запустить процесс преобразования

22

Перекодирование видео

Page 23: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

1. Создать объект MediaComposer

MediaComposer mediaComposer = new AndroidMediaObjectFactory(getApplicationContext());

• AndroidMediaObjectFactory – фабрика, с помощью которой

инициализируются все классы Media Pack

23

Инициализация MediaComposer

Page 24: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

2. Указать путь к исходному, результирующему файлам

String srcPath = “…”;

String dstPath = “…”;

mediaComposer.addSourceFile(srcPath); mediaComposer.setTargetFile(dstPath);

24

Пути к файлам

Page 25: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

3. Задать параметры результирующего видео

String videoMimeType = “video/avc”;

int videoFrameWidth = 640;

int videoFrameHeight = 480;

int videoBitRate = 5000;

int videoFrameRate = 30;

int videoIFrameInterval = 1;

VideoFormatAndroid videoFormat = new VideoFormatAndroid(videoMimeType, videoFrameWidth, videoFrameHeight);

videoFormat.setVideoBitRateInKBytes(videoBitRate);

videoFormat.setVideoFrameRate(videoFrameRate);

videoFormat.setVideoIFrameInterval(videoIFrameInterval);

mediaComposer.setTargetVideoFormat(videoFormat);

25

Параметры видео

Page 26: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

3. Задать параметры результирующего видео

String audioMimeType = “audio/mp4a-latm”;

int audioSampleRate = 48000;

int audioChannelCount = 2;

int audioProfile = MediaCodecInfo.CodecProfileLevel.AACObjectLC;

AudioFormatAndroid audioFormat = new AudioFormatAndroid(audioMimeType , audioSampleRate, audioChannelCount);

audioFormat.setAudioBitrate(audioBitRate);

audioFormat.setAudioAacProfile(audioProfile);

mediaComposer.setTargetAudioFormat(audioFormat); 26

Параметры аудио

Page 27: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

4. Реализовать интерфейс MediaComposer.IProgressListener

public MediaComposer.IProgressListener progressListener = new MediaComposer.IProgressListener();

• public void onMediaStart()

• public void onMediaProgress(float progress)

• public void onMediaDone()

• public void onMediaPause()

• public void onMediaStop()

• public void onError(Exception exception)

mediaComposer.addProgressListener(progressListener);

27

Обратные вызовы

Page 28: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

mediaComposer.start();

• Создание, инициализация декодера, энкодера, муксера

• Построение конвейера

• Декодирование, обработка, кодирование

28

Запуск

Page 29: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Захват видео в играх

29

Page 30: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Создает поверхность

• Приложение рисует очередной кадр на экран и на

поверхность GLCapture

• Кодирует отрисованный кадр в видео

30

Захват видео в играх

Page 31: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Реализация включает 5-ть шагов

• Создать объект GLCapture

• Указать путь к видео файлу

• Задать параметры видео

• Запустить процесс, cконфигурировать поверхность

• Внести изменения в функцию рисования

31

Захват видео в играх

Page 32: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

1. Создать объект GLCapture

GLCapture capture = new GLCapture(new

AndroidMediaObjectFactory());

32

Создание объекта GLCapture

Page 33: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

2. Указать путь к видео файлу

String videoPath = “…”;

capture.setTargetFile(videoPath);

33

Куда записываем

Page 34: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

3. Задать параметры видео

int videoWidth = 720;

int videoHeight = 1280;

int videoFrameRate = 30;

int videoIFrameInterval = 1;

int videoBitRate = 1000;

String videoCodec = "video/avc";

VideoFormatAndroid videoFormat = new VideoFormatAndroid(videoCodec, videoWidth, videoHeight);

videoFormat.setVideoBitRateInKBytes(videoBitRate);

videoFormat.setVideoFrameRate(videoFrameRate);

videoFormat.setVideoIFrameInterval(videoIFrameInterval);

capture.setTargetVideoFormat(videoFormat);

34

Параметры видео

Page 35: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

4. Запустить процесс, cконфигурировать поверхность

capture.start();

В функции с активным OpenGL контекстом

• onSurfaceChanged(GL10 gl, int width, int height)

• onDrawFrame(GL10 gl)

int videoWidth = 720;

int videoHeight = 1280;

capture.setSurfaceSize(videoWidth, videoHeight)

35

Запуск

Page 36: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

render();

capture.beginCaptureFrame();

render();

capture.endCaptureFrame();

36

Функция рисования

Page 37: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• beginCaptureFrame – переключает текущий Open GL

контекст на контекст поверхности

• endCaptureFrame – восстанавливает предыдущий контекст

37

Функция рисования

Page 38: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

frameBuffer.bind();

renderScene();

frameBuffer.unbind();

texture.draw(frameBuffer.getTexture());

capture.beginCaptureFrame();

texture.draw(frameBuffer.getTexture());

capture.endCaptureFrame();

38

Использование Frame Buffer

Page 39: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Заключение

39

Page 40: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

• Не требует начальных знаний о том как работают медиа

компоненты Android

• Разрабатывайте приложение, не теряя время на отладку

• Предлагает множество моделей использования

40

Преимущества INDE Media Pack

Page 41: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Полезные ресурсы

41

Page 42: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

http://software.intel.com/en-us/intel-inde

http://software.intel.com/en-us/articles/intel-inde-frequently-asked-

questions

http://software.intel.com/en-us/forums/intel-integrated-native-

developer-experience-intel-inde

[email protected]

42

Полезные ресурсы

Page 43: резников дмитрий

Copyright © 2014, Intel Corporation. All rights reserved. *Other names and brands may be claimed as the property of others. Optimization Notice

Legal Disclaimer & Optimization Notice

INFORMATION IN THIS DOCUMENT IS PROVIDED “AS IS”. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL

OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. INTEL

ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY,

RELATING TO THIS INFORMATION INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A

PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER

INTELLECTUAL PROPERTY RIGHT.

Software and workloads used in performance tests may have been optimized for performance only on Intel

microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer

systems, components, software, operations and functions. Any change to any of those factors may cause the results to

vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated

purchases, including the performance of that product when combined with other products.

Copyright © 2014, Intel Corporation. All rights reserved. Intel, Pentium, Xeon, Xeon Phi, Core, VTune, Cilk, and the Intel

logo are trademarks of Intel Corporation in the U.S. and other countries.

Optimization Notice

Intel’s compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors.

These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or

effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use

with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable

product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804

43

Page 44: резников дмитрий