Summer Term 2015 Dr. Ing. Bashar Altakrouri Daniel Burmeister M.Sc. Ambient Computing Group Institute of Telematics University of Lübeck www.itm.uni-luebeck.de {altakrouri, burmeister}@itm.uni-luebeck.de Exercise 1 Media Metadata Analysis
Institute für of Beispielsysteme Telematics Ambient Forschungsgruppe Computing Group Systembeispiele Overall goals Supplement/enhance the lecture material We will expand the lecture topics with a unique software engineering perspective. Gain experience with software development tools and industry-standard media frameworks FFMPEG, Node.JS Framework. Gain experience with Streaming Server and Client Applications 2
Institute für of Beispielsysteme Telematics Ambient Forschungsgruppe Computing Group Systembeispiele Course Webpage https://www.itm.uni-luebeck.de/teaching/ss2015/ media-trans/ https://moodle.uni-luebeck.de/course/view.php? id=943 3
Institute für of Beispielsysteme Telematics Ambient Forschungsgruppe Computing Group Systembeispiele Agenda Overview Introduction and overview of key media abstractions Process You will need to complete the exercises according to the presented material. You may be provided skeleton code/project with notes and hints. You will need to search and read the reference documentation for the needed API s and classes needed to complete the exercise. The exercises SHOULD be completed individually. Some exercises do have a homework! Homeworks are mandatory and should be submitted on time. 4
Digital Audio Basic Video Streaming Media Metadata Analysis Digital Video Video On-demand Streaming 5
( Fast Forward mpeg) The File Format Fracas An open-source collection of cross-platform programs and libraries for recording, converting and streaming audio and video Supports a large number of file containers and codecs via libavcodec (e.g. mov, mp4, avi, flv/ h.264, mpeg2, jpeg, mp3, VP6, etc.) Includes several components (written in C) Programs: ffmpegconverter, ffserver, ffplay Libraries: libavutil, libavcodec, libavformat, libavdevice, libswscale Used in a broad range of software projects (see: http://ffmpeg.org/projects.html) 6
( Fast Forward mpeg) Examples To convert a WAV file to a 128kbps MP3 file ffmpeg -i Input.wav -ab 128 Output.mp3 To encode a video with a 128kbps audio bitrate and 1,200kbps video stream ffmpeg -i InputFile.avi -ab 128 -b 1200 OutputFile.mpg 19 ffmpeg commands for all needs http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs 7
Media Abstractions Video Chunk Video Chunk AudioChunk Other Chunk Video Chunk Video Chunk AudioChunk Other Chunk 8
Media Abstractions Container Stream Packet Packet Stream Packet Packet Packet Stream Packet Packet 9
Media Abstractions Container: file on the server container is a file (or network data source) that contains one or more Stream objects of audio and video data. Stream: a set of sequential chunks of data Streams are really virtual concepts; Containers really just contain a bunch of Packets. But each Packet usually has a stream id associated with it, and all Packets with that stream id represent the same type of (usually time-based) data. For example in many FLV video files, there is a stream with id "0" that contains all video data, and a stream with id "1" that contains all audio data. Codecs: tells how it is compressed. In other words how to unlock it (key) Packet: represents an encoded piece of data that can be placed in an Container for a given Stream of data. Timestamps in an Packet are determined by the Container it came from (or is going to). For example, FLV Packets are always in milliseconds (1/1000 of a second). 10
Media Abstractions Sources? Container Stream Packet Audio Samples IStream Stream Packet StreamCoder (Codecs) Video Samples 11
Example Media Format Flash FLV Container Stream IStream Stream
Quick intro to Node.js Building scalable network applications using JavaScript on the server side Build using C code Very fast Node.js Non-blocking code Possible applications Websocket server (i.e., chatting server) V8 JavaScript Runtime File upload clients Real-time data applications Node is not A web framework Multi-threaded
Quick intro to Node.js Blocking code Non-blocking code
Quick intro to Node.js Blocking code Non-blocking code Non-blocking code
Node Package Manager (npm) npm is (like maven or gradle) a package managing system build tool Uses a meta description file in JSON format
Important CLI-commands Run just npm shows help npm search <packagename> searches for a package npm install <packagename> installs a package Options for install: -g adds it to global scope (available from everywhere) --save adds the dependency to package.json file npm start runs file defined in script section of package.json Available packages including API: https://www.npmjs.com Inspect package.json in detail: http://browsenpm.org/package.json
Important CLI-commands
Node.js Hello Console Create a file called hello.js in a folder MyHelloProject Write down Go into your project directory MyHelloProject and run `npm install`. To start the module run npm start To execute a single file run node hello.js
Node.js Hello HTTP Create a file called hello-http.js in a folder MyHelloHttpProject Write down Go into your project directory MyHelloHttpProject and run `npm install`. To start the module run npm start To execute a single file run node hello-http.js
Node.js Event Loop JavaScript has certain characteristics that make it very different than other dynamic languages, namely that it has no concept of threads. Its model of concurrency is completely based around events. - Ryan Dahl (Node.js creator)
Institute für of Beispielsysteme Telematics Ambient Forschungsgruppe Computing Group Systembeispiele Setting up FFMPEG and Node.js Media metadata analysis 22
Setting the environment Install node.js https://nodejs.org/download/ Verify the installation: $ node v Install npm https://www.npmjs.com/package/npm Automatically installed with node.js when using the package manager Verify the installation: $ npm v Install ffmpeg https://www.ffmpeg.org/download.html Verify the installation: $ ffmpeg Python 2.7.x https://www.python.org/downloads/ Chrome Browser https://www.google.de/chrome/browser/desktop/ Package Managers - apt-get (Linux) - Chocolatey (Windows) - Homebrew (OSX) Add all binaries to the environment variables, if not done automatically by chocolatey, apt or homebrew 23
Exercise 1 Overview 1/3 Excerpt from main_ex1.js 24
Exercise 1 Overview 2/3 Excerpt from main_ex1.js 25
Exercise 1 Overview 3/3 Excerpt from metadata.js 26
Exercise 1 End