214
Brian DeShong September 16, 2008 Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Rickroll To Go With PHP, WURFL, and Other Open Source Tools

  • Upload
    zendcon

  • View
    4.200

  • Download
    0

Embed Size (px)

DESCRIPTION

"In a world where mobile content is becoming more prevalent by the day, how can we enhance the experience of gathering images, audio and video for consumption on mobile devices?Brian will demonstrate how you can leverage the Wireless Universal Resource File (WURFL), PHP, ImageMagick, ffmpeg, and other open source tools to optimize content for consumption on mobile devices."

Citation preview

Page 1: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Brian DeShongSeptember 16, 2008

Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Page 2: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Intro

2

Page 3: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Intro

Brian DeShong

2

Page 4: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Intro

Brian DeShongSenior Manager, Technology for Schematic

2

Page 5: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Intro

Brian DeShongSenior Manager, Technology for SchematicApplication and systems architect

2

Page 6: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Intro

Brian DeShongSenior Manager, Technology for SchematicApplication and systems architectDeveloper

2

Page 7: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Who is Schematic?

3

Page 8: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Who is Schematic?

Full-service interactive agency

3

Page 9: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Who is Schematic?

Full-service interactive agencyOffices in Atlanta; New York; LA; San Francisco; Austin, TX; Minneapolis, MN; San Jose, Costa Rica

3

Page 10: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Who is Schematic?

Full-service interactive agencyOffices in Atlanta; New York; LA; San Francisco; Austin, TX; Minneapolis, MN; San Jose, Costa RicaSome clients include...

DellTargetDisneyNokiaComcastMTV

3

Page 11: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What are we talking about?

4

Page 12: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What are we talking about?

PC and mobile development are very different

4

Page 13: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What are we talking about?

PC and mobile development are very differentIdentifying devices with WURFL

4

Page 14: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What are we talking about?

PC and mobile development are very differentIdentifying devices with WURFLGenerating content for mobile consumption

Images, video, audioPHP, open source tools

4

Page 15: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Computers vs. Mobile Devices

5

Page 16: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

6

Page 17: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

6

Page 18: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

6

Page 19: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

6

Page 20: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

6

Page 21: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Dial-up Broadband T1+, etc.6

Page 22: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Dial-up Broadband T1+, etc.6

Page 23: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

7

Page 24: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

7

Page 25: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

7

Page 26: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

7

Page 27: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

EDGE 3G EVDO

7

Page 28: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

EDGE 3G EVDO Proxy, no proxy

7

Page 29: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

WURFL

8

Page 30: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What is it?

9

Page 31: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What is it?

Wireless Universal Resource File

9

Page 32: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What is it?

Wireless Universal Resource FileXML file containing characteristics of many mobile devices

9

Page 33: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What is it?

Wireless Universal Resource FileXML file containing characteristics of many mobile devicesOpen source

9

Page 34: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What is it?

Wireless Universal Resource FileXML file containing characteristics of many mobile devicesOpen sourcehttp://wurfl.sourceforge.net/

9

Page 35: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

10

WURFL Examples

Page 36: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

10

WURFL Examples

Page 37: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

10

WURFL Examples

Page 38: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

10

WURFL Examples

Page 39: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

10

WURFL Examples

Page 40: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How can we use WURFL?

11

Page 41: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How can we use WURFL?

Lookup device by user agent

11

Page 42: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How can we use WURFL?

Lookup device by user agentDevice data indicates its capabilities

iPhone320x4803GP, MP4 video @ 320x240, 30 fps

11

Page 43: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

12

Page 44: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display size

12

Page 45: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display sizeUser agent strings

12

Page 46: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display sizeUser agent stringsSupported audio, video, image formats

12

Page 47: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display sizeUser agent stringsSupported audio, video, image formatsStreaming capabilities

12

Page 48: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display sizeUser agent stringsSupported audio, video, image formatsStreaming capabilitiesHas QWERTY keyboard?

12

Page 49: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Data offered

Display sizeUser agent stringsSupported audio, video, image formatsStreaming capabilitiesHas QWERTY keyboard?XHTML, Ajax capabilities 12

Page 50: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

13

Page 51: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

wurfl.xml is ~8 MB in size!

13

Page 52: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

wurfl.xml is ~8 MB in size!Not a great idea to parse it from front end

13

Page 53: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

wurfl.xml is ~8 MB in size!Not a great idea to parse it from front endExtract data you need, place in database

Youʼll need a plan for updating from your source data

13

Page 54: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Use what you need

14

Page 55: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Use what you need

Display sizes

14

Page 56: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Use what you need

Display sizesRelevant video, audio formats supported

14

Page 57: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Use what you need

Display sizesRelevant video, audio formats supportedMIDP, CLDC versions supported

Handy in determining compatibility for applications

14

Page 58: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Use what you need

Display sizesRelevant video, audio formats supportedMIDP, CLDC versions supported

Handy in determining compatibility for applications

Bitmasks values are handy

14

Page 59: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Applying bitmask and DB

15

<?phpdefine(‘VIDEO_MP4’, 1);define(‘VIDEO_3GP’, 2);define(‘VIDEO_WMV’, 4);

// $videoFormats = 7;$videoFormats = VIDEO_MP4 | VIDEO_3GP | VIDEO_WMV;?>

id | manuf | model | video_formats----------------------------------1 | Nokia | N95 | 7

Page 60: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using it from PHP

16

Page 61: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using it from PHP

Itʼs just XML!

16

Page 62: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using it from PHP

Itʼs just XML!SimpleXML, DOM, etc.

16

Page 63: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using it from PHP

Itʼs just XML!SimpleXML, DOM, etc.Caching your lookups

MemcachedSQLite, other DBs

16

Page 64: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using it from PHP

Itʼs just XML!SimpleXML, DOM, etc.Caching your lookups

MemcachedSQLite, other DBs

Lookup by user agent$_SERVER[‘HTTP_USER_AGENT’]Opera: X-OperaMini-Phone-UA

16

Page 65: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary and other options

17

Page 66: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary and other options

Use WURFL responsibly and efficiently!PHP scripts on its websiteEmploy some caching techniques

17

Page 67: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary and other options

Use WURFL responsibly and efficiently!PHP scripts on its websiteEmploy some caching techniques

WURFL and other options are key to a great mobile experience

DeviceAtlas

17

Page 68: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Content Challenges

18

Page 69: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Some challenges

19

Page 70: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Some challenges

Varying amounts of bandwidth available

19

Page 71: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Some challenges

Varying amounts of bandwidth availableCostly data plans

Unlimited vs. per-MB/GB

19

Page 72: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Some challenges

Varying amounts of bandwidth availableCostly data plans

Unlimited vs. per-MB/GB

Different capabilities across devices

19

Page 73: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Some challenges

Varying amounts of bandwidth availableCostly data plans

Unlimited vs. per-MB/GB

Different capabilities across devicesLimited memory in devices

19

Page 74: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How to workaround them

20

Page 75: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How to workaround them

Serve content tailored to userʼs deviceEfficient use of resources and bandwidthDetermine if a given piece of content will work on the device before download

20

Page 76: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

How to workaround them

Serve content tailored to userʼs deviceEfficient use of resources and bandwidthDetermine if a given piece of content will work on the device before download

Hope for the best!User will sort it outIt will work or it wonʼt

20

Page 77: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

To be fair...

21

Page 78: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

To be fair...

None of this may be relevant in a few years

21

Page 79: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

To be fair...

None of this may be relevant in a few yearsMobile browsers and devices are evolving

21

Page 80: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

To be fair...

None of this may be relevant in a few yearsMobile browsers and devices are evolvingLow-end devices are prevalent in many parts of the world

Who is your audience, and where are they located?

21

Page 81: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tailoring Content for Devices

22

Page 82: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

Page 83: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

I pre-generate files and write them to disk

Page 84: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

I pre-generate files and write them to diskI can rely on them being in place when making decision

Page 85: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

I pre-generate files and write them to diskI can rely on them being in place when making decisionImages:foo_240x320.jpgfoo_320x240.jpg

Page 86: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

I pre-generate files and write them to diskI can rely on them being in place when making decisionImages:foo_240x320.jpgfoo_320x240.jpg

Video:foo_176x144.3gpfoo_176x144.mp4

Page 87: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

My Personal Approach

23

I pre-generate files and write them to diskI can rely on them being in place when making decisionImages:foo_240x320.jpgfoo_320x240.jpg

Video:foo_176x144.3gpfoo_176x144.mp4

Audio:foo.aac

Page 88: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Images

24

Page 89: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing image delivery

25

Page 90: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing image delivery

25

User visits site

Page 91: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing image delivery

25

User visits site

Device identified?

Page 92: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing image delivery

25

User visits site

Device identified?

No

Page 93: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing image delivery

25

User visits site

Device identified?

YesNo

Page 94: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing images with PHP

26

Page 95: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing images with PHP

Graphics extensions availableGDimagick (ImageMagick)

26

Page 96: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing images with PHP

Graphics extensions availableGDimagick (ImageMagick)

Command-line ImageMagick binaries

26

Page 97: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Using imagick

$imagick = new Imagick();$imagick->readImage(‘/astley/rick.jpg’);

27

Page 98: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

28

Page 99: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

Source Image: 507x398

28

Page 100: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

Thumbnailed image: 240x188

28

Page 101: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

Thumbnailed image: 240x188

$imagick->thumbnailImage(240, 0);

28

Page 102: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

Cropped thumbnail image: 240x320

28

Page 103: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Example

Cropped thumbnail image: 240x320

$imagick->cropThumbnailImage(240, 320);

28

Page 104: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

29

Page 105: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

Generating images on-demand is expensive

29

Page 106: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Gotchas

Generating images on-demand is expensiveKeep it cheap and/or infrequent

Write the different sizes to disk; routine cleanupMemcachedPre-generate them

29

Page 107: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary

30

Page 108: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary

Serving image tailored for deviceUses least amount of bandwidth possibleUses device resources efficiently

30

Page 109: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary

Serving image tailored for deviceUses least amount of bandwidth possibleUses device resources efficiently

Be smart with the server-side implementation!

30

Page 110: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Summary

Serving image tailored for deviceUses least amount of bandwidth possibleUses device resources efficiently

Be smart with the server-side implementation!Less complex than dealing with video, audio

30

Page 111: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Video

31

Page 112: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Video on mobile devices

32

Page 113: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Video on mobile devices

Most devices canʼt play the formats weʼre accustomed to on PCs

32

Page 114: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Video on mobile devices

Most devices canʼt play the formats weʼre accustomed to on PCs3GP is widely supported

32

Page 115: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Video on mobile devices

Most devices canʼt play the formats weʼre accustomed to on PCs3GP is widely supportedMPEG-4 on newer devices

32

Page 116: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

Page 117: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

User visits site

Page 118: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

User visits site

Device supports MPEG-4 video?

Page 119: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

User visits site

Device supports MPEG-4 video?

No

Serve3GP

Page 120: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

User visits site

Device supports MPEG-4 video?

YesNo

Serve3GP

ServeMPEG-4

Page 121: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing video delivery

3321

User visits site

Device supports MPEG-4 video?

YesNo

Serve3GP

ServeMPEG-4

Max video resolution?

Page 122: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Video Sites

34

Page 123: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Video Sites

34

Page 124: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Video Sites

34

Page 125: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Video Sites

34

Page 126: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile Video Sites

34

Page 127: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing for mobile

35

Page 128: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing for mobile

Lower resolution176x144, 320x240

35

Page 129: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing for mobile

Lower resolution176x144, 320x240

Reduce video frameratePlayback looks jerkyBut it requires less bandwidth!

35

Page 130: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing for mobile

Lower resolution176x144, 320x240

Reduce video frameratePlayback looks jerkyBut it requires less bandwidth!

Reduce bitrates35

Page 131: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

36

Page 132: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpeg, Mencoder

36

Page 133: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpeg, MencoderOn2 Flix Engine for Flash (commercial)

36

Page 134: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpeg, MencoderOn2 Flix Engine for Flash (commercial)Anystream Agility

36

Page 135: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpeg, MencoderOn2 Flix Engine for Flash (commercial)Anystream AgilityCommercial tools to read Windows Media, other DRMʼd formats

36

Page 136: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

37

Page 137: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Generating videos is not cheap

37

Page 138: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Generating videos is not cheapShould not be done in real time

End user will have to wait for it!

37

Page 139: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Generating videos is not cheapShould not be done in real time

End user will have to wait for it!

Pre-generate with an offline processStore them on diskPurge when and if needed

37

Page 140: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Generating videos is not cheapShould not be done in real time

End user will have to wait for it!

Pre-generate with an offline processStore them on diskPurge when and if needed

Weʼll look at FFmpeg shortly!

37

Page 141: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Audio

38

Page 142: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Audio on mobile devices

39

Page 143: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Audio on mobile devices

Devices have been playing MP3s for years now

39

Page 144: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Audio on mobile devices

Devices have been playing MP3s for years nowWider support than video

39

Page 145: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Audio on mobile devices

Devices have been playing MP3s for years nowWider support than videoMP3, AAC formats are well supported

39

Page 146: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing audio delivery

402921

Page 147: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing audio delivery

402921

User visits site

Page 148: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing audio delivery

402921

User visits site

AAC audio

supported?

Page 149: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing audio delivery

402921

User visits site

AAC audio

supported?

No

ServeMP3

Page 150: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Optimizing audio delivery

402921

User visits site

AAC audio

supported?

YesNo

ServeMP3

ServeAAC

Page 151: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

41

Page 152: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpeg

41

Page 153: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpegTiMidity++ (MIDI to PCM)

41

Page 154: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Tools

FFmpegTiMidity++ (MIDI to PCM)Note:

Iʼm not dealing with MP3 licensing issues here!

41

Page 155: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

42

Page 156: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Again, generating audio isnʼt cheap

42

Page 157: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Again, generating audio isnʼt cheapShouldnʼt transcode in real time

42

Page 158: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Again, generating audio isnʼt cheapShouldnʼt transcode in real timePre-generate in an offline process

42

Page 159: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Again, generating audio isnʼt cheapShouldnʼt transcode in real timePre-generate in an offline process

42

Page 160: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Expense

Again, generating audio isnʼt cheapShouldnʼt transcode in real timePre-generate in an offline process

What can we use?Surprise! FFmpeg! 42

Page 161: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

What’s this FFmpeg stuff?

43

Page 162: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Basics

44

Page 163: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Basics

Decodes and encodes audio and video streams

44

Page 164: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Basics

Decodes and encodes audio and video streamsMany A/V formats supported

44

Page 165: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Basics

Decodes and encodes audio and video streamsMany A/V formats supportedSupports use of external libraries to handle additional formats

44

Page 166: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Basics

Decodes and encodes audio and video streamsMany A/V formats supportedSupports use of external libraries to handle additional formatsRuns on many platforms (Windows, OS X, Linux)

44

Page 167: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Usage

ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...

45

Page 168: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Usage

ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...

45ffmpeg -h: 504 lines!Extensive amount of options for both audio and video

Page 169: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Usage

ffmpeg [[infile options] -i infile]... {[outfile options] outfile}...

45ffmpeg -h: 504 lines!Extensive amount of options for both audio and video

Page 170: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg: Video

46

Page 171: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

Page 172: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

Page 173: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

-vcodec: video codec to use

Page 174: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

-vcodec: video codec to use

-s: frame size

Page 175: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

-vcodec: video codec to use

-s: frame size

-r: video framerate

Page 176: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

-vcodec: video codec to use

-s: frame size

-r: video framerate

-b: bitrate

Page 177: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

47

Notable video encoding options

-acodec: audio codec to use

-vcodec: video codec to use

-s: frame size

-r: video framerate

-b: bitrateffmpeg -i rr.mp4 \ -acodec libfaac \ -vcodec h263 \ -s 176x144 \ -r 12 \ foo.3gp

Page 178: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

48

Page 179: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

48

Page 180: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

320x240MPEG-4, AAC

30 fps244kbps6.2 MB

48

Page 181: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

320x240MPEG-4, AAC

30 fps244kbps6.2 MB

176x1443GP, AAC

30 fps90kbps2.3 MB

48

Page 182: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

320x240MPEG-4, AAC

30 fps244kbps6.2 MB

176x1443GP, AAC

30 fps90kbps2.3 MB

176x1443GP, AAC

8 fps63kbps1.6 MB

48

Page 183: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Grab screenshots!

$ ffmpeg \ -i rr.mp4 \ -f image2 \ frame%2d.jpg 49

Page 184: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

50

Page 185: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

50

Page 186: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg: Audio

51

Page 187: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

Page 188: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

-acodec: audio codec to use

Page 189: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

-acodec: audio codec to use

-ar: audio sampling rate

Page 190: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

-acodec: audio codec to use

-ar: audio sampling rate

-ab: audio bitrate

Page 191: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

-acodec: audio codec to use

-ar: audio sampling rate

-ab: audio bitrate

-ac: number of channels

Page 192: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

52

Notable audio encoding options

-acodec: audio codec to use

-ar: audio sampling rate

-ab: audio bitrate

-ac: number of channels

ffmpeg -i iib.mp3 \ -ab 64000 \ -ac 1 \ foo.mp3

Page 193: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

53

Page 194: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

53

Original:128kbps4.1MB

Page 195: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

53

Original:128kbps4.1MB

Second Clip:64kbps

2.05MB (1/2)

Page 196: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

53

Original:128kbps4.1MB

Second Clip:64kbps

2.05MB (1/2)

Third Clip:32kbps

1.025MB (1/4)

Page 197: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Examples

53

Original:128kbps4.1MB

Second Clip:64kbps

2.05MB (1/2)

Third Clip:32kbps

1.025MB (1/4)

Final Clip:8kbps

1.025MB (???)

Page 198: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg Summary

54

Page 199: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg Summary

54

Powerful tool!

Page 200: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg Summary

54

Powerful tool!Takes a lot to master it

Probably makes more sense to A/V experts

Page 201: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg Summary

54

Powerful tool!Takes a lot to master it

Probably makes more sense to A/V experts

But itʼs easy enough to get the job done right

Page 202: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

FFmpeg Summary

54

Powerful tool!Takes a lot to master it

Probably makes more sense to A/V experts

But itʼs easy enough to get the job done rightIts manpage is your friend!

Page 203: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

In Closing...

55

Page 204: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile is tricky!

56

Page 205: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile is tricky!

All of those combinationsDevicesProvidersBandwidth / data plansCapabilities

56

Page 206: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile is tricky!

All of those combinationsDevicesProvidersBandwidth / data plansCapabilities

Use resources efficiently56

Page 207: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Mobile is tricky!

All of those combinationsDevicesProvidersBandwidth / data plansCapabilities

Use resources efficientlyOptimize the experience for the end user 56

Page 208: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Resources

57

Page 209: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Resources

WURFL: http://wurfl.sourceforge.net/

57

Page 210: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Resources

WURFL: http://wurfl.sourceforge.net/FFmpeg: http://ffmpeg.mplayerhq.hu/

57

Page 211: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Resources

WURFL: http://wurfl.sourceforge.net/FFmpeg: http://ffmpeg.mplayerhq.hu/ImageMagick: http://www.imagemagick.org/

PECL extension: http://pecl.php.net/package/imagick/

57

Page 212: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

For more information, please see me or visithttp://www.schematic.com/#/JoinUs/

It goes without saying: Schematic is only as good as the people who work here. That’s why we’re so particular about recruiting, training, nurturing, and retaining the very best people in our field.

If you have digital expertise (technical, creative, managerial–or something else entirely), enthusiasm, curiosity, and the ability to collaborate with others, we’d love to hear from you.

We’re Hiring!

58

Page 213: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Thanks!

http://www.deshong.net/http://www.schematic.com/

[email protected]@schematic.com

59

Page 214: Rickroll To Go With PHP, WURFL, and Other Open Source Tools

Thanks!

http://www.deshong.net/http://www.schematic.com/

[email protected]@schematic.com

59