728x90

출처 : MJPG streaming with a Raspberry Pi and a webcam

산딸기 마을에서 만든 rc_car를 이동하면서 구글 Cardboard로 3D 영상을 보기 위해서
RaspberryPI 두개로 각각 PI Camera로 3D 좌우 영상을 얻어 보았지만 싱크가 맞지 않아서,
3D 영상을 얻지 못했습니다.

그래서 3D 카메라를 찾다가 AliExpress에서 USB 타입의 듀얼 카메라를 구입습니다.
PaspberryPI에서 mjpg_streamer를 두번 실행해서, html로 두개의 영상을 좌우로 구성했습니다.

구글의 Cardboard로 핸드폰 브라우져의 좌우 영상보시면 3D 영상을 보실 수 있습니다.

AliExpress에서 구입한 Camera

Camera 설치 확인

USB 방식으로 RaspberryPI에 USB에 연결만 하면 바로 설치가 됩니다.

$ ls /dev/vi*
/dev/video0  /dev/video1

Camera 1 - mjpg_streamer 실행

$ mjpg_streamer -i "input_uvc.so -d /dev/video0 -n -y -f 15 -r 640x480"

Camera 2 - mjpg_streamer 실행

$ mjpg_streamer -i "input_uvc.so -d /dev/video1 -n -y -f 15 -r 640x480" -o "output_http.so -w /usr/local/www2 -p 8081"

듀얼 화면 구성 html 소스

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<script type="text/javascript" src="js-mjpeg/eventemitter2.min.js"></script>
<script type="text/javascript" src="js-mjpeg/mjpegcanvas.min.js"></script>

<script type="text/javascript" type="text/javascript">
function init() {

	var canvas_width = (document.body.clientWidth / 2);
	var canvas_heigth = canvas_width * 75 / 100;
	
	// Create the main viewer.
	var viewer_l = new MJPEGCANVAS.Viewer({
	  divID : 'mjpeg_l',
	  host : '192.168.1.190',
	  port : '8080',
	  width : canvas_width,
	  height : canvas_heigth,
	  topic : '/?action=stream'
	});
	
	var viewer_r = new MJPEGCANVAS.Viewer({
	  divID : 'mjpeg_r',
	  host : '192.168.1.190',
	  port : '8081',
	  width : canvas_width,
	  height : canvas_heigth,
	  topic : '/?action=stream'
	});
}
</script>
<style type="text/css">
body {
  margin: 0;
  padding: 0;
}

.blind, body, button, dd, dl, dt, fieldset, form, canvas {
  margin: 0;
  padding: 0;
}

.grid1_wrap, .grid2_wrap {
  margin: 0;
  box-sizing: border-box;
}

@media (min-width: 640px)
.grid1_wrap.news_wrap .brick-vowel {
  width: 50%;
}

.brick-house .brick-vowel {
  float: left;
  /* width: 100%; */
}
</style>
</head>

<body onload="init()">

<div class="flick-panel" style="height: 100%; transition-property: -webkit-transform; transition-duration: 0ms; position: absolute; width: 100%; left: 0px; top: 0px; float: left;">
	<div class="grid1_wrap news_wrap brick-house" data-last="true" style="padding-left:0px">
		<div class="brick-vowel" id="mjpeg_l"></div>
		<div class="brick-vowel" id="mjpeg_r"></div>
	</div>
</div>

</body>
</html>

ie에서 듀얼 화면 확인

핸드폰 브라우져에서 듀얼 화면 확인

Google Cardboard의 프라스틱 버전에 핸드폰 설치 

728x90
728x90

출처 : Using a 16x2 LCD Display with a Raspberry Pi
LCD Display Tutorial for Raspberry Pi
Interfacing 16x2 LCD with Raspberry Pi using GPIO & Python
16×2 LCD Module Control Using Python
rasbperry pi B gpio between extention board mapping
Raspberry Pi 2 Model B GPIO 40 Pin Block Pinout
How To Use A MCP23017 I2C Port Expander With The Raspberry Pi ? Part 1

Using a 16x2 LCD Display with a Raspberry Pi

Breadboard 설치된 최종 모습

회로도

실행 - lcd.lcd_init()

$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()

 

실행 - Line 1 문자열 출력

$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)

 

실행 - Line 2 문자열 출력

$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)
>>> lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
>>> lcd.lcd_string("Hello world", 2)

 

실행 - 최종

$ sudo python
Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chdir('/home/pi')
>>> import lcd
>>> lcd.lcd_init()
>>> lcd.lcd_byte(lcd.LCD_LINE_1, lcd.LCD_CMD)
>>> lcd.lcd_string("Raspberry PI", 2)
>>> lcd.lcd_byte(lcd.LCD_LINE_2, lcd.LCD_CMD)
>>> lcd.lcd_string("Hello world", 2)
>>> lcd.GPIO.cleanup()
>>> quit()

소스 lcd.py

#!/usr/bin/python
#
# HD44780 LCD Test Script for
# Raspberry Pi
#
# Author : Matt Hawkins
# Site   : http://www.raspberrypi-spy.co.uk
# 
# Date   : 03/08/2012
#

# The wiring for the LCD is as follows:
# 1 : GND
# 2 : 5V
# 3 : Contrast (0-5V)*
# 4 : RS (Register Select)
# 5 : R/W (Read Write)       - GROUND THIS PIN
# 6 : Enable or Strobe
# 7 : Data Bit 0             - NOT USED
# 8 : Data Bit 1             - NOT USED
# 9 : Data Bit 2             - NOT USED
# 10: Data Bit 3             - NOT USED
# 11: Data Bit 4
# 12: Data Bit 5
# 13: Data Bit 6
# 14: Data Bit 7
# 15: LCD Backlight +5V**
# 16: LCD Backlight GND

#import
import RPi.GPIO as GPIO
import time

# Define GPIO to LCD mapping
LCD_RS = 7
LCD_E  = 8
LCD_D4 = 25
LCD_D5 = 24
LCD_D6 = 23
LCD_D7 = 18
#LED_ON = 15

# Define some device constants
LCD_WIDTH = 16    # Maximum characters per line
LCD_CHR = True
LCD_CMD = False

LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line
LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line 

# Timing constants
E_PULSE = 0.00005
E_DELAY = 0.00005

def main():
  # Main program block

  # Initialise display
  lcd_init()

  # Toggle backlight on-off-on
  #GPIO.output(LED_ON, True)
  #time.sleep(1)
  #GPIO.output(LED_ON, False)
  #time.sleep(1)
  #GPIO.output(LED_ON, True)
  #time.sleep(1)

  # Send some centred test
  lcd_byte(LCD_LINE_1, LCD_CMD)
  lcd_string("Rasbperry Pi",2)
  lcd_byte(LCD_LINE_2, LCD_CMD)
  lcd_string("Model B",2)

  time.sleep(3) # 3 second delay

  # Send some left justified text
  lcd_byte(LCD_LINE_1, LCD_CMD)
  lcd_string("1234567890123456",1)
  lcd_byte(LCD_LINE_2, LCD_CMD)
  lcd_string("abcdefghijklmnop",1)

  time.sleep(3) # 3 second delay

  # Send some right justified text
  lcd_byte(LCD_LINE_1, LCD_CMD)
  lcd_string("Raspberrypi-spy",3)
  lcd_byte(LCD_LINE_2, LCD_CMD)
  lcd_string(".co.uk",3)

  time.sleep(30)

  # Turn off backlight
  #GPIO.output(LED_ON, False)

def lcd_init():
  GPIO.setmode(GPIO.BCM)       # Use BCM GPIO numbers
  GPIO.setup(LCD_E, GPIO.OUT)  # E
  GPIO.setup(LCD_RS, GPIO.OUT) # RS
  GPIO.setup(LCD_D4, GPIO.OUT) # DB4
  GPIO.setup(LCD_D5, GPIO.OUT) # DB5
  GPIO.setup(LCD_D6, GPIO.OUT) # DB6
  GPIO.setup(LCD_D7, GPIO.OUT) # DB7
  #GPIO.setup(LED_ON, GPIO.OUT) # Backlight enable  
  # Initialise display
  lcd_byte(0x33,LCD_CMD)
  lcd_byte(0x32,LCD_CMD)
  lcd_byte(0x28,LCD_CMD)
  lcd_byte(0x0C,LCD_CMD)  
  lcd_byte(0x06,LCD_CMD)
  lcd_byte(0x01,LCD_CMD)  

def lcd_string(message,style):
  # Send string to display
  # style=1 Left justified
  # style=2 Centred
  # style=3 Right justified

  if style==1:
    message = message.ljust(LCD_WIDTH," ")  
  elif style==2:
    message = message.center(LCD_WIDTH," ")
  elif style==3:
    message = message.rjust(LCD_WIDTH," ")

  for i in range(LCD_WIDTH):
    lcd_byte(ord(message[i]),LCD_CHR)

def lcd_byte(bits, mode):
  # Send byte to data pins
  # bits = data
  # mode = True  for character
  #        False for command

  GPIO.output(LCD_RS, mode) # RS

  # High bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x10==0x10:
    GPIO.output(LCD_D4, True)
  if bits&0x20==0x20:
    GPIO.output(LCD_D5, True)
  if bits&0x40==0x40:
    GPIO.output(LCD_D6, True)
  if bits&0x80==0x80:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)      

  # Low bits
  GPIO.output(LCD_D4, False)
  GPIO.output(LCD_D5, False)
  GPIO.output(LCD_D6, False)
  GPIO.output(LCD_D7, False)
  if bits&0x01==0x01:
    GPIO.output(LCD_D4, True)
  if bits&0x02==0x02:
    GPIO.output(LCD_D5, True)
  if bits&0x04==0x04:
    GPIO.output(LCD_D6, True)
  if bits&0x08==0x08:
    GPIO.output(LCD_D7, True)

  # Toggle 'Enable' pin
  time.sleep(E_DELAY)    
  GPIO.output(LCD_E, True)  
  time.sleep(E_PULSE)
  GPIO.output(LCD_E, False)  
  time.sleep(E_DELAY)   

if __name__ == '__main__':
  main()

pi4j - 핀 배열

pi4j - 예제

import java.text.SimpleDateFormat;
import java.util.Date;

import com.pi4j.component.lcd.LCDTextAlignment;
import com.pi4j.component.lcd.impl.GpioLcdDisplay;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiGpioProvider;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.RaspiPinNumberingScheme;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;

public class LcdExample2 {

	public final static int LCD_ROWS = 2;
	public final static int LCD_ROW_1 = 0;
	public final static int LCD_ROW_2 = 1;
	public final static int LCD_COLUMNS = 16;
	public final static int LCD_BITS = 4;

	public static void main(String args[]) throws InterruptedException {

		System.out.println("<--Pi4J--> GPIO 4 bit LCD example program");
		
		// create gpio controller
		final GpioController gpio = GpioFactory.getInstance();

		// initialize LCD
		//new GpioLcdDisplay(LCD_ROWS, LCD_COLUMNS, RaspiPin.GPIO_06, RaspiPin.GPIO_05, RaspiPin.GPIO_04, RaspiPin.GPIO_00, RaspiPin.GPIO_01, RaspiPin.GPIO_03);
		final GpioLcdDisplay lcd = new GpioLcdDisplay(LCD_ROWS, // number of row
																														// supported by LCD
				LCD_COLUMNS, // number of columns supported by LCD
				RaspiPin.GPIO_11, // LCD RS pin          7
				RaspiPin.GPIO_10, // LCD strobe pin      8
				RaspiPin.GPIO_06, // LCD data bit 1     25
				RaspiPin.GPIO_05, // LCD data bit 2     24
				RaspiPin.GPIO_04, // LCD data bit 3     23
				RaspiPin.GPIO_01); // LCD data bit 4    18

		// provision gpio pins as input pins with its internal pull up resistor
		// enabled
		/*
		final GpioPinDigitalInput myButtons[] = { 
				gpio.provisionDigitalInputPin(RaspiPin.GPIO_13, "B1", PinPullResistance.PULL_UP),
				gpio.provisionDigitalInputPin(RaspiPin.GPIO_07, "B2", PinPullResistance.PULL_UP),
				gpio.provisionDigitalInputPin(RaspiPin.GPIO_04, "B3", PinPullResistance.PULL_UP),
				gpio.provisionDigitalInputPin(RaspiPin.GPIO_12, "B4", PinPullResistance.PULL_UP)
		};

		// create and register gpio pin listener
		gpio.addListener(new GpioPinListenerDigital() {
			@Override
			public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
				if (event.getState() == PinState.LOW) {
					lcd.writeln(LCD_ROW_2, event.getPin().getName() + " PRESSED", LCDTextAlignment.ALIGN_CENTER);
				} else {
					lcd.writeln(LCD_ROW_2, event.getPin().getName() + " RELEASED", LCDTextAlignment.ALIGN_CENTER);
				}
			}
		}, myButtons);
		*/
		
		// clear LCD
		lcd.clear();
		Thread.sleep(1000);

		// write line 1 to LCD
		lcd.write(LCD_ROW_1, "The Pi4J Project");

		// write line 2 to LCD
		lcd.write(LCD_ROW_2, "----------------");

		// line data replacement
		for (int index = 0; index < 5; index++) {
			lcd.write(LCD_ROW_2, "----------------");
			Thread.sleep(500);
			lcd.write(LCD_ROW_2, "****************");
			Thread.sleep(500);
		}
		lcd.write(LCD_ROW_2, "----------------");

		// single character data replacement
		for (int index = 0; index < lcd.getColumnCount(); index++) {
			lcd.write(LCD_ROW_2, index, ">");
			if (index > 0)
				lcd.write(LCD_ROW_2, index - 1, "-");
			Thread.sleep(300);
		}
		for (int index = lcd.getColumnCount() - 1; index >= 0; index--) {
			lcd.write(LCD_ROW_2, index, "<");
			if (index < lcd.getColumnCount() - 1)
				lcd.write(LCD_ROW_2, index + 1, "-");
			Thread.sleep(300);
		}

		// left alignment, full line data
		lcd.write(LCD_ROW_2, "----------------");
		Thread.sleep(500);
		lcd.writeln(LCD_ROW_2, "<< LEFT");
		Thread.sleep(1000);

		// right alignment, full line data
		lcd.write(LCD_ROW_2, "----------------");
		Thread.sleep(500);
		lcd.writeln(LCD_ROW_2, "RIGHT >>", LCDTextAlignment.ALIGN_RIGHT);
		Thread.sleep(1000);

		// center alignment, full line data
		lcd.write(LCD_ROW_2, "----------------");
		Thread.sleep(500);
		lcd.writeln(LCD_ROW_2, "<< CENTER >>", LCDTextAlignment.ALIGN_CENTER);
		Thread.sleep(1000);

		// mixed alignments, partial line data
		lcd.write(LCD_ROW_2, "----------------");
		Thread.sleep(500);
		lcd.write(LCD_ROW_2, "<L>", LCDTextAlignment.ALIGN_LEFT);
		lcd.write(LCD_ROW_2, "<R>", LCDTextAlignment.ALIGN_RIGHT);
		lcd.write(LCD_ROW_2, "CC", LCDTextAlignment.ALIGN_CENTER);
		Thread.sleep(3000);

		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");

		// update time
		while (true) {
			// write time to line 2 on LCD
			//if (gpio.isHigh(myButtons)) {
				lcd.writeln(LCD_ROW_2, formatter.format(new Date()), LCDTextAlignment.ALIGN_CENTER);
			//}
			Thread.sleep(1000);
		}

		// stop all GPIO activity/threads by shutting down the GPIO controller
		// (this method will forcefully shutdown all GPIO monitoring threads and
		// scheduled tasks)
		// gpio.shutdown(); <--- implement this method call if you wish to terminate
		// the Pi4J GPIO controller
	}
}

컴파일 및 실행

$ javac -cp ../lib/pi4j-core.jar:../lib/pi4j-device.jar LcdExample2.java
$ sudo java -cp .:../lib/pi4j-core.jar:../lib/pi4j-device.jar LcdExample2

실행 결과



728x90
728x90

출처 : Configure Tomcat service linux
Installing Tomcat as a Linux Service
라즈베리파이(Raspberry Pi) 아파치 톰캣 서버(Tomcat Server) 설치방법 (JSP 서블릿 컨테이너, 자바 웹서버 구축)
sharplet/tomcat-init

tomcat7 설치

$ cd /usr/local
$ sudo wget http://apache.tt.co.kr/tomcat/tomcat-7/v7.0.75/bin/apache-tomcat-7.0.75.tar.gz
$ sudo tar -xvf apache-tomcat-7.0.75.tar.gz

tomcat 서비스 등록 - tomcat 파일 생성하기 

tomcat

$ sudo vi /etc/init.d/tomcat

#!/bin/sh
#
# /etc/init.d/tomcat7 -- startup script for the Tomcat 7 servlet engine
#
# Written by Miquel van Smoorenburg .
# Modified for Debian GNU/Linux	by Ian Murdock .
# Modified for Tomcat by Stefan Gybas .
# Modified for Tomcat6 by Thierry Carrez .
# Modified for Tomcat7 by Ernesto Hernandez-Novich .
# Additional improvements by Jason Brittain .
#
### BEGIN INIT INFO
# Provides:          tomcat7
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Should-Start:      $named
# Should-Stop:       $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Tomcat.
# Description:       Start the Tomcat servlet engine.
# sudo update-rc.d tomcat defaults
# sudo update-rc.d tomcat remove
# ls /etc/rc0.d
### END INIT INFO

set -e

## Source function library.
#. /etc/rc.d/init.d/functions
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt
export JAVA_OPTS="-Dfile.encoding=UTF-8 \
  -Dcatalina.logbase=/var/log/tomcat7 \
  -Dnet.sf.ehcache.skipUpdateCheck=true \
  -XX:+DoEscapeAnalysis \
  -XX:+UseConcMarkSweepGC \
  -XX:+CMSClassUnloadingEnabled \
  -XX:+UseParNewGC \
  -XX:MaxPermSize=128m \
  -Xms512m -Xmx512m"
export PATH=$JAVA_HOME/bin:$PATH
export TOMCAT_USER=root
export TOMCAT_HOME=/usr/local/apache-tomcat-7.0.75
export SHUTDOWN_WAIT=20

tomcat_pid() {
  echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ] 
  then
    echo "Tomcat is already running (pid: $pid)"
  else
    # Start tomcat
    echo "Starting tomcat"
    ulimit -n 100000
    umask 007
    /bin/su - $TOMCAT_USER -c $TOMCAT_HOME/bin/startup.sh
  fi


  return 0
}

stop() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Stoping Tomcat"
    /bin/su - $TOMCAT_USER -c $TOMCAT_HOME/bin/shutdown.sh

    let kwait=$SHUTDOWN_WAIT
    count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit";
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
      kill -9 $pid
    fi
  else
    echo "Tomcat is not running"
  fi
 
  return 0
}

case $1 in
start)
  start
;; 
stop)   
  stop
;; 
restart)
  stop
  start
;;
status)
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Tomcat is running with pid: $pid"
  else
    echo "Tomcat is not running"
  fi
;; 
esac    
exit 0

tomcat 권한설정

$ sudo chmod u+x /etc/init.d/tomcat

tomcat 실행 스크립트 파일 부팅시 자동으로 되도록 복사

$ sudo update-rc.d tomcat defaults

tomcat 서비스 명령으로 실행

$ sudo service tomcat restart
728x90
728x90

출처 : Simple project to allow turning on/off of an LED via GPIO pin #17.
라즈베리 파이 GPIO 제어 (CONSOLE, PYTHON)
raspberry-pi4j-samples
RPi Low-level peripherals
[라즈베리파이 중급] (6) WiringPi 설치 & 깜빡이는 LED

GPIO Led 연결하기

이미지 출처 : Simple project to allow turning on/off of an LED via GPIO pin #17.


Console 에서 LED 켜고 끄기

/sys/class/gpio 폴더로 이동

$ sudo su
# cd /sys/class/gpio
# ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Jan  1  1970 export
lrwxrwxrwx 1 root gpio    0 Jan  1  1970 gpiochip0 -> ../../devices/platform/soc/20200000.gpio/gpio/gpiochip0
-rwxrwx--- 1 root gpio 4096 Jan  1  1970 unexport

GPIO17 핀 초기화

심볼릭 링크가 걸린 gpio17 폴더가 생성된 것을 확인 할 수 있음

# echo 17 > /sys/class/gpio/export
# ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Aug 13 05:22 export
lrwxrwxrwx 1 root gpio    0 Aug 13 05:22 gpio17 -> ../../devices/platform/soc/20200000.gpio/gpio/gpio17
lrwxrwxrwx 1 root gpio    0 Jan  1  1970 gpiochip0 -> ../../devices/platform/soc/20200000.gpio/gpio/gpiochip0
-rwxrwx--- 1 root gpio 4096 Jan  1  1970 unexport

input/output 모드 설정

# echo out > /sys/class/gpio/gpio17/direction

LED 켜기

# echo 1 > /sys/class/gpio/gpio17/value

LED 끄기

# echo 0 > /sys/class/gpio/gpio17/value

GPIO17 핀 반환

# cd /sys/class/gpio
# echo 17 > /sys/class/gpio/unexport
# ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Aug 13 06:27 export
lrwxrwxrwx 1 root gpio    0 Jan  1  1970 gpiochip0 -> ../../devices/platform/soc/20200000.gpio/gpio/gpiochip0
-rwxrwx--- 1 root gpio 4096 Aug 13 06:46 unexport

java로 LED 켜고 끄기

pi4j 라이브러리 다운로드, 압축해제, 경로 이동

$ wget http://get.pi4j.com/download/pi4j-1.0.zip
$ unzip pi4j-1.0.zip 
$ cd pi4j-1.0/examples

컴파일

$ javac -cp ../lib/pi4j-core.jar ControlGpioExample.java

실행

$ sudo java -cp .:../lib/pi4j-core.jar ControlGpioExample
<--Pi4J--> GPIO Control Example ... started.
--> GPIO state should be: ON
--> GPIO state should be: OFF
--> GPIO state should be: ON
--> GPIO state should be: OFF
--> GPIO state should be: ON for only 1 second

ControlGpioExample.java 소스

// START SNIPPET: control-gpio-snippet

/*
 * #%L
 * **********************************************************************
 * ORGANIZATION  :  Pi4J
 * PROJECT       :  Pi4J :: Java Examples
 * FILENAME      :  ControlGpioExample.java  
 * 
 * This file is part of the Pi4J project. More information about 
 * this project can be found here:  http://www.pi4j.com/
 * **********************************************************************
 * %%
 * Copyright (C) 2012 - 2015 Pi4J
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

/**
 * This example code demonstrates how to perform simple state
 * control of a GPIO pin on the Raspberry Pi.  
 * 
 * @author Robert Savage
 */
public class ControlGpioExample {
    
    public static void main(String[] args) throws InterruptedException {
        
        System.out.println("<--Pi4J--> GPIO Control Example ... started.");
        
        // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();
        
        // provision gpio pin #01 as an output pin and turn on
        final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_00, "MyLED", PinState.HIGH);

        // set shutdown state for this pin
        pin.setShutdownOptions(true, PinState.LOW);

        System.out.println("--> GPIO state should be: ON");

        Thread.sleep(5000);
        
        // turn off gpio pin #01
        pin.low();
        System.out.println("--> GPIO state should be: OFF");

        Thread.sleep(5000);

        // toggle the current state of gpio pin #01 (should turn on)
        pin.toggle();
        System.out.println("--> GPIO state should be: ON");

        Thread.sleep(5000);

        // toggle the current state of gpio pin #01  (should turn off)
        pin.toggle();
        System.out.println("--> GPIO state should be: OFF");
        
        Thread.sleep(5000);

        // turn on gpio pin #01 for 1 second and then off
        System.out.println("--> GPIO state should be: ON for only 1 second");
        pin.pulse(1000, true); // set second argument to 'true' use a blocking call
        
        // stop all GPIO activity/threads by shutting down the GPIO controller
        // (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
        gpio.shutdown();
    }
}
//END SNIPPET: control-gpio-snippet

raspberry-pi4j-samples 의 Relay02.java 예제 사용하기

Relay02.java 예제는 핀번호를 인자로 실행해서 Command 입력으로 LED를 켜고 끄기가 가능함

raspberry-pi4j-samples 다운로드, 경로이동, 컴파일, 실행

$ git clone https://code.google.com/p/raspberry-pi4j-samples/
$ cd raspberry-pi4j-samples/Relay/src
$ javac -cp ~/pi4j-1.0/lib/pi4j-core.jar relay/Relay02.java
$ sudo java -cp .:../../../pi4j-1.0/lib/pi4j-core.jar relay.Relay02 0 
GPIO Control - pin 0... started.
--> GPIO state is Low
Type Q to quit.
So? > 1
Setting pin to high
--> GPIO state is High
So? > 0
Setting pin to low
--> GPIO state is Low
So? > q

Relay02.java 소스

package relay;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.Pin;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * 5v are required to drive the relay
 * The GPIO pins deliver 3.3v
 * To drive a relay, a relay board is required.
 * (it may contain what's needed to drive the relay with 3.3v)
 */
public class Relay02
{
  private static Pin relayPin = RaspiPin.GPIO_00;
  
  public static void main(String[] args) throws InterruptedException
  {
    int pin = 0;
    if (args.length > 0)
    {
      try 
      {
        pin = Integer.parseInt(args[0]);
      }
      catch (NumberFormatException nfe)
      {
        nfe.printStackTrace();
      }
      switch (pin)
      {
        case 0:
          relayPin = RaspiPin.GPIO_00;
          break;
        case 1:
          relayPin = RaspiPin.GPIO_01;
          break;
        case 2:
          relayPin = RaspiPin.GPIO_02;
          break;
        case 3:
          relayPin = RaspiPin.GPIO_03;
          break;
        case 4:
          relayPin = RaspiPin.GPIO_04;
          break;
        case 5:
          relayPin = RaspiPin.GPIO_05;
          break;
        case 6:
          relayPin = RaspiPin.GPIO_06;
          break;
        case 7:
          relayPin = RaspiPin.GPIO_07;
          break;
        case 8:
          relayPin = RaspiPin.GPIO_08;
          break;
        case 9:
          relayPin = RaspiPin.GPIO_09;
          break;
        case 10:
          relayPin = RaspiPin.GPIO_10;
          break;
        case 11:
          relayPin = RaspiPin.GPIO_11;
          break;
        case 12:
          relayPin = RaspiPin.GPIO_12;
          break;
        case 13:
          relayPin = RaspiPin.GPIO_13;
          break;
        case 14:
          relayPin = RaspiPin.GPIO_14;
          break;
        case 15:
          relayPin = RaspiPin.GPIO_15;
          break;
        case 16:
          relayPin = RaspiPin.GPIO_16;
          break;
        case 17:
          relayPin = RaspiPin.GPIO_17;
          break;
        case 18:
          relayPin = RaspiPin.GPIO_18;
          break;
        case 19:
          relayPin = RaspiPin.GPIO_19;
          break;
        case 20:
          relayPin = RaspiPin.GPIO_20;
          break;
        default: // Model a+ and B+ go up to 30
          System.out.println("Unknown GPIO pin [" + pin + "], must be between 0 & 20.");
          System.out.println("Defaulting GPIO_00");
          break;
      }
    }
    System.out.println("GPIO Control - pin " + pin + "... started.");

    // create gpio controller
    final GpioController gpio = GpioFactory.getInstance();

    // For a relay it seems that HIGH means NC (Normally Closed)...
    final GpioPinDigitalOutput outputPin = gpio.provisionDigitalOutputPin(relayPin); //, PinState.HIGH);

    System.out.println("--> GPIO state is " + (outputPin.isHigh()?"High":"Low"));
    
    boolean go = true;
    
    System.out.println("Type Q to quit.");
    while (go)
    {
      String user = userInput("So? > ");
      if ("Q".equalsIgnoreCase(user))
        go = false;
      else
      {
        int val = 0;
        try
        {
          val = Integer.parseInt(user);
          if (val != 0 && val != 1)
            System.out.println("Only 1 or 0, please");
          else
          {
            System.out.println("Setting pin to " + (val == 1 ? "high" : "low"));
            if (val == 0)
              outputPin.low();
            else
              outputPin.high();
            System.out.println("--> GPIO state is " + (outputPin.isHigh()?"High":"Low"));
          }
        }
        catch (NumberFormatException nfe)
        {
          nfe.printStackTrace();
        }
      }
    }
    gpio.shutdown();
  }

private static final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

  public static String userInput(String prompt)
  {
    String retString = "";
    System.err.print(prompt);
    try
    {
      retString = stdin.readLine();
    }
    catch(Exception e)
    {
      System.out.println(e);
      String s;
      try
      {
        s = userInput("<Oooch/>");
      }
      catch(Exception exception) 
      {
        exception.printStackTrace();
      }
    }
    return retString;
  }
}

728x90
728x90

출처 : How to build and run MJPG-Streamer on the Raspberry Pi
라즈베리파이 파이카메라 활용강좌 : 웹 스트리밍(Mjpg-Stream)
fishkingsin/mjpg_streamer.sh

MJPG streamer 컴파일 관련 라이브러리 설치

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install cmake libjpeg8-dev imagemagick libv4l-dev

videodev2.h 헤더파일 링크

$ sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h

MJPG streamer 소스 다운로드, 컴파일, 설치

$ echo "이전 git clone https://github.com/liamfraser/mjpg-streamer"
$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/mjpg-streamer-experimental/
$ make
$ sudo make install

LD_LIBRARY_PATH 경로 추가

$ echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/mjpg-streamer" | sudo tee -a /etc/profile

MJPG Streamer 실행

출처 : MJPG Streamer configuration

$ mjpg_streamer -i "input_raspicam.so -x 640 -y 480 -fps 10 -rot 180 -ex night" --output "output_http.so -w /usr/local/share/mjpg-streamer/www --port 8080"

또는

$ mjpg_streamer -i "input_raspicam.so -x 320 -y 240 -quality 30 -fps 15 -rot 180 -ex night"

MJPG Streamer 실행 - 최적옵션

$ mjpg_streamer -i "input_uvc.so -r 320x240 -f 10 -y" --output "output_http.so -w /usr/local/share/mjpg-streamer/www --port 8080"

html 코드

출처 : mjpegcanvasjs / Tutorials / CreatingASingleStreamCanvas

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="eventemitter2.min.js"></script>
<script type="text/javascript" src="mjpegcanvas.min.js"></script>

<script type="text/javascript" type="text/javascript">
  /**
   * Setup all visualization elements when the page is loaded. 
   */
  function init() {
    // Create the main viewer.
     var viewer = new MJPEGCANVAS.Viewer({
      divID : 'mjpeg',
     host : '192.168.0.14',
     port : '8080',
      width : 640,
       height : 480,
      topic : '/?action=stream'
     });
 }
</script>
</head>
 
<body onload="init()">
<h1>Simple MJPEG Canvas Example</h1>
<div id="mjpeg"></div>
</body>
</html>

V4L2(Video4Linux2) 부팅시 활성화 시키기

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

서비스등록

$ sudo vi /etc/init.d/mjpg_streamer

mjpg_streamer 파일 내용

#!/bin/bash
# /etc/init.d/mjpg_streamer.sh
# v0.2 phillips321.co.uk
### BEGIN INIT INFO
# Provides:          mjpg_streamer.sh
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mjpg_streamer for webcam
# Description:       Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO

#
export width=640
export height=480
export bitrate=10
export SHUTDOWN_WAIT=2

if [ -n "$2" ]; then
  width=$2 
fi

if [ -n "$3" ]; then
  height=$3
fi

if [ -n "$4" ]; then
  bitrate=$4
fi

export LD_MJPG_STREAMER=/usr/local/lib/mjpg-streamer

f_message(){
        echo "[+] $1"
}

mjpg_streamer_pid() {
  echo `ps aux | grep mjpg-streamer | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ] 
  then
    echo "mjpg_streamer is already running (pid: $pid)"
  else
    # Start mjpg_streamer
		f_message "Starting mjpg_streamer"
		mjpg_streamer -b -i "$LD_MJPG_STREAMER/input_uvc.so -r "$width"x"$height" -f $bitrate -y" -o "$LD_MJPG_STREAMER/output_http.so -p 8080 -w /usr/local/share/mjpg-streamer/www"
		sleep 2
		f_message "mjpg_streamer started"
  fi

  return 0
}

stop() {
  pid=$(mjpg_streamer_pid)
  if [ -n "$pid" ]
  then
    f_message "Stopping mjpg_streamer..."
    kill -9 $pid

    let kwait=$SHUTDOWN_WAIT
    let count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit";
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
      kill -9 $pid
    fi
  else
    echo "mjpg_streamer is not running"
  fi
 
  return 0
}

# Carry out specific functions when asked to by the system
case "$1" in
        start)
                 start
                 ;;
        stop)
                 stop
                 ;;
        restart)
                 stop
                 sleep 2
                 start
                 ;;
        resolution)
                resolution=`ps axu | grep mjpg-streamer | grep -v grep | awk '{ print $16 }'`
                if [ -n "$resolution" ];
                then
                        echo "${resolution}"
                else
                        echo "0x0"
                fi
                ;;
        status)
                pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk '{print $1}' | head -n 1`
                if [ -n "$pid" ];
                then
                        f_message "mjpg_streamer is running with pid ${pid}"
                        f_message "mjpg_streamer was started with the following command line"
                        cat /proc/${pid}/cmdline ; echo ""
                else
                        f_message "Could not find mjpg_streamer running"
                fi
                ;;
        *)
                f_message "Usage: $0 {start|stop|status|restart}"
                exit 1
                ;;
esac
exit 0

등록

$ sudo chmod u+x /etc/init.d/mjpg_streamer
$ sudo update-rc.d mjpg_streamer defaults

서비스 실행 및 실행 확인

$ sudo service mjpg_streamer start
$ sudo service mjpg_streamer status
[0m mjpg_streamer.service - LSB: mjpg_streamer for webcam
   Loaded: loaded (/etc/init.d/mjpg_streamer)
   Active: active (running) since Sat 2016-05-21 15:18:17 UTC; 8s ago
  Process: 1373 ExecStop=/etc/init.d/mjpg_streamer stop (code=killed, signal=TERM)
  Process: 1403 ExecStart=/etc/init.d/mjpg_streamer start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mjpg_streamer.service
           붴1407 mjpg_streamer -b -i /usr/local/lib/mjpg-streamer/input_uvc.so -r 320x240 -f 10 -y -o /usr/local/lib/mjpg-s...
 
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: TV-Norm...........: DEFAULT
May 21 15:18:15 raspberrypi mjpg_streamer[1403]: enabling daemon modeforked to background (1407)
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: www-folder-path...: /usr/local/share/mjpg-streamer/www/
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: HTTP TCP port.....: 8080
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: username:password.: disabled
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: commands..........: enabled
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: starting input plugin /usr/local/lib/mjpg-stream...vc.so
May 21 15:18:15 raspberrypi mjpg_streamer[1407]: MJPG-streamer [1407]: starting output plugin: /usr/local/lib/mjpg-stre...: 00)
May 21 15:18:17 raspberrypi mjpg_streamer[1403]: [+] mjpg_streamer started
May 21 15:18:17 raspberrypi systemd[1]: Started LSB: mjpg_streamer for webcam.
Hint: Some lines were ellipsized, use -l to show in full.
728x90
728x90

출처 : Raspberry Pi Camera Live Streaming
How to install FFMPEG, Libx264, LibRTMP, LibAACPlus, LibVPX on the Raspberry Pi (Debian “Wheezy” ARMHF)
ffmpeg native build - my experience
Installing FFMPEG for Raspberry Pi
파이카메라 활용강좌 : RTMP를 이용한 웹으로 H264 영상전송
FFmpeg CompilationGuide/RaspberryPi
Raspberry Pi - Troubleshooting

yasm 소스 다운로드, 컴파일

$ mkdir ~/workspace.ffmpeg
$ cd ~/workspace.ffmpeg
$ wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
$ tar xzvf yasm-1.2.0.tar.gz && cd yasm-1.2.0
$ ./configure && make
$ sudo make install

lame 소스 다운로드, 컴파일

$ cd ~/workspace.ffmpeg
$ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz
$ tar xzvf lame-3.99.tar.gz && cd lame-3.99
$ ./configure && make
$ sudo make install

faac 소스 다운로드, 컴파일

$ cd ~/workspace.ffmpeg
$ curl -#LO http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
$ tar xzvf faac-1.28.tar.gz && cd faac-1.28
$ ./configure
$ make

faac 컴파일 오류 수정

출처 : TOPIC: Setting server issues with FAAC Setting server issues with FAAC

In file included from mp4common.h:29:0,
                 from 3gp.cpp:28:
mpeg4ip.h:126:58: error: new declaration ‘char* strcasestr(const char*, const char*)’
/usr/include/string.h:369:28: error: ambiguates old declaration ‘const char* strcasestr(const char*, const char*)’
Makefile:415: recipe for target '3gp.o' failed
make[3]: *** [3gp.o] Error 1
make[3]: Leaving directory '/usr/src/faac-1.28/common/mp4v2'
Makefile:216: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/usr/src/faac-1.28/common'
Makefile:253: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/src/faac-1.28'
Makefile:182: recipe for target 'all' failed
make: *** [all] Error 2

파일 common/mp4v2/mpeg4ip.h 의 126 라인의 내용 주석으로 수정

$ vi common/mp4v2/mpeg4ip.h

// char *strcasestr(const char *haystack, const char *needle);

faac 재컴파일

$ make clean && make
$ sudo make install

H264 소스 다운로드, 컴파일

$ cd ~/workspace.ffmpeg $ git clone git://git.videolan.org/x264 $ cd x264 $ ./configure --enable-static $ make $ sudo make install install -d /usr/local/bin install x264 /usr/local/bin install -d /usr/local/include install -d /usr/local/lib install -d /usr/local/lib/pkgconfig install -m 644 ./x264.h /usr/local/include install -m 644 x264_config.h /usr/local/include install -m 644 x264.pc /usr/local/lib/pkgconfig install -m 644 libx264.a /usr/local/lib ranlib /usr/local/lib/libx264.a $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

기존에 설치되어 있는 ffmpeg 삭제

$ sudo apt-get --purge autoremove ffmpeg

ffmpeg 소스 다운로드, 컴파일

$ cd ~/workspace.ffmpeg
$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
$ cd ffmpeg
$ ./configure --prefix=/opt/ffmpeg --arch=armel --target-os=linux --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-version3 --disable-mmx
$ make
$ sudo make install
$ export PATH=$PATH:/opt/ffmpeg/bin

V4L2(Video4Linux2) 드라이버 활성화

$ ls /dev/vi*
ls: cannot access /dev/vi*: No such file or directory
$ sudo modprobe bcm2835-v4l2
$ ls /dev/vi*
/dev/video0

ffmpeg 명령 - 이미지 추출

$ ffmpeg -f video4linux2 -i /dev/video0 -r 10 -f image2 camera%03d.jpg
ffmpeg version N-73750-gf8e4d37 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --prefix=/opt/ffmpeg --arch=armel --target-os=linux --enable-gpl --enable-libx264
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 49.101 / 56. 49.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 23.100 /  5. 23.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1437272081.746893, bitrate: 110592 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 110592 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[swscaler @ 0x1ec5f80] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'camera%03d.jpg':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480, q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc
    Metadata:
      encoder         : Lavc56.49.101 mjpeg
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame=   38 fps=4.2 q=24.8 Lsize=N/A time=00:00:03.80 bitrate=N/A dup=0 drop=65    
video:645kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.

확인

$ ls camera*.jpg
camera001.jpg  camera008.jpg  camera015.jpg  camera022.jpg  camera029.jpg  camera036.jpg
camera002.jpg  camera009.jpg  camera016.jpg  camera023.jpg  camera030.jpg  camera037.jpg
camera003.jpg  camera010.jpg  camera017.jpg  camera024.jpg  camera031.jpg  camera038.jpg
camera004.jpg  camera011.jpg  camera018.jpg  camera025.jpg  camera032.jpg
camera005.jpg  camera012.jpg  camera019.jpg  camera026.jpg  camera033.jpg
camera006.jpg  camera013.jpg  camera020.jpg  camera027.jpg  camera034.jpg
camera007.jpg  camera014.jpg  camera021.jpg  camera028.jpg  camera035.jpg

ffmpeg 명령 - flv 포멧으로 동영상 저장

$ ffmpeg -f video4linux2 -i /dev/video0 -f flv out.flv
ffmpeg version N-73750-gf8e4d37 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --prefix=/opt/ffmpeg --arch=armel --target-os=linux --enable-gpl --enable-libx264
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 49.101 / 56. 49.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 23.100 /  5. 23.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1437273926.929734, bitrate: 110592 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 110592 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Output #0, flv, to 'out.flv':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc
    Metadata:
      encoder         : Lavc56.49.101 flv
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> flv1 (flv))
Press [q] to stop, [?] for help
frame=  140 fps= 12 q=10.5 Lsize=     317kB time=00:00:04.80 bitrate= 540.4kbits/s    
video:314kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.761900%
Exiting normally, received signal 2.

ffmpeg 명령 - mp4 파일로 저장

$ ffmpeg -f video4linux2 -i /dev/video0 -f mpeg out.mp4

nginx 설치 전 - PCRE 설치

$ sudo apt-get install libpcre3 libpcre3-dev

nginx 설치 전 - openssl 다운로드

출처 : Raspberry Pi にOpenSSLをインストール

$ cd ~/workspace.ffmpeg
$ wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz
$ tar zxvf openssl-1.0.1e.tar.gz

openssl 설치는 아래의 방법으로 설치할 수 있지만, 
nginx 에서 openssl도 같이 설치하도록 되어 있어 여기서는  설치 하지 않는다.(참고용)

$ cd openssl-1.0.1e
$ ./config --prefix=/usr/local/ssl/.openssl no-shared
$ make
$ make test
$ sudo make install
$ sudo ldconfig

/etc/manpath.config 등록

MANDATORY_MANPATH /usr/local/openssl/man

nginx - 웹서버, HLS 서버 소스다운로드, 컴파일

출처 : Raspberry Pi Camera Live Streaming

$ cd ~/workspace.ffmpeg
$ wget http://nginx.org/download/nginx-1.9.3.tar.gz
$ tar xvf nginx-1.9.3.tar.gz
$ git clone https://github.com/arut/nginx-rtmp-module.git
$ cd  nginx-1.9.3
$ ./configure --sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-openssl=/home/pi/workspace.ffmpeg/openssl-1.0.1e \
--with-http_ssl_module \
--without-http_proxy_module \
--add-module=/home/pi/workspace.ffmpeg/nginx-rtmp-module
$ make
$ sudo make install

nginx 환경 파일 수정 /etc/nginx/nginx.conf

$ sudo vi /etc/nginx/nginx.conf

http {

<생략>

        # root 경로 수정
        location / {
            #root   html;
            root /var/www;
            index  index.html index.htm;
        }

        # hls 경로 추가
        location /hls {
          types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
          }
          root /var/www;
          index index.html;
          add_header Cache-Control no-cache;
        }

        location /dash {
          # Serve DASH fragments
          root /var/www;
          add_header Cache-Control no-cache;
        }
    }
}

# 수신받을 rtmp 추가
rtmp {
    server {
        listen 1935;
        chunk_size 4000;

        application hls {
            live on;
            hls on;
            hls_path /var/www/hls;
            # hls_fragment 3s;
            # hls_playlist_length 10s;
            # hls_sync 200ms;
            # allow publish all;
            # allow play all;
        }

        application dash {
            live on;
            dash on;
            dash_path /var/www/dash;
            wait_key on;
            interleave on;
            publish_notify on;
            sync 10ms;
        }
    }
}

경로 생성

$ sudo mkdir /var/www
$ sudo mkdir /var/www/hls
$ sudo mkdir /var/www/dash

서비스 등록nginx

$ sudo cp nginx /etc/init.d
$ sudo chmod +x /etc/init.d/nginx

서비스 실행

$ sudo /etc/init.d/nginx start

HLS Streaming

HLS는 아이폰에서만 플레이가 가능하고 안드로이드의 경우 플레이가 되지 않고 있음

ffmpeg 명령 - 아이폰만 가능 플레이 중단

$ ffmpeg -f video4linux2 -i /dev/video0 -c:v libx264 -b:v 512k -s 320x240 -f flv -r 30.0 rtmp://localhost:1935/hls/live

ffmpeg 명령 - 아이폰만 가능 플레이 중단

$ ffmpeg -f video4linux2 -i /dev/video0 -vcodec h264 -b:v 1200k -ar 44100 -f flv -r 30.0 rtmp://localhost:1935/hls/live

ffmpeg 명령 - 아이폰만 가능 플레이 지속

$ ffmpeg -f video4linux2 -i /dev/video0 -vcodec h264 -b:v 1200k -ar 44100 -flags +aic+mv4 -strict -2 -s 320x240 -f flv -r 30.0 rtmp://localhost:1935/hls/live

video1.html - HLS 예(nginx에서 아이폰만 가능)

<html>
  <body>
    test
    <video controls="controls" width="1280" height="720" autoplay="autoplay" >
      <source src="hls/live.m3u8" type="application/x-mpegURL" />
    </video>
  </body>
</html>

video2.html - HLS 예 (nginx에서 아이폰만 가능)

<!DOCTYPE>
<html>
<body>
 
<video id="video" 
       autobuffer 
           controls width="340" 
           style="margin-bottom:20px;" 
           >
        <source src="hls/live.m3u8" type="video/mp4">
</video>
 
</body>
</html>

DASH Streaming

출처 : MPEG-DASH live streaming in nginx-rtmp-module

dash 설정

$ cd /var/www
$ sudo git clone https://github.com/arut/dash.js.git
$ cd dash.js
$ sudo git checkout live

파일 수정

$ cat dash.js/baseline.html

ffmpeg 명령

$ ffmpeg -f video4linux2 -i /dev/video0 -vcodec h264 -b:v 1200k -ar 44100 -flags +aic+mv4 -strict -2 -s 320x240 -f flv -r 30.0 rtmp://localhost:1935/dash/live

startVideo 함수의 URL 주소 변경

        function startVideo() {
            var vars = getUrlVars(),
                // url = "http://dash.edgesuite.net/envivio/dashpr/clear/Manifest.mpd",
                url = "http://192.168.0.14:7070/dash/live.mpd",
                video,
                context,
                player;

SpiderLive 사용

$SLIVE_HOME/conf/startup.ini 파일

[streams]
app=live/_definst_ 
type=rtp
name=camera.streampi

$SLIVE_HOME/content/camera.stream 파일

udp://127.0.0.1:10000?pkt_size=1316

ffmpeg 명령 - SpiderLive에 UDP로 송출

$ ffmpeg -f video4linux2 -i /dev/video0 -vcodec libx264  -vb 150000 -g 60 -level 2.1 -vbsf h264_mp4toannexb -strict experimental -f mpegts udp://127.0.0.1:10000?pkt_size=1316

video3.html - SpiderLive 라이브스트리밍 예

<!DOCTYPE>
<html>
<body>

<video id="video" 
       autobuffer 
           controls width="340" 
           style="margin-bottom:20px;">
        <source src="http://192.168.0.14:1935/live/mp4:camera.stream/playlist.m3u8" type="video/mp4">
</video>

</body>
</html>

video4.html - SpiderLive VOD 예

<!DOCTYPE>
<html>
<body>
 
<video id="video" 
       autobuffer 
           controls width="340" 
           style="margin-bottom:20px;">
        <source src="http://192.168.0.14:1935/vod/mp4:sample.mp4/playlist.m3u8" type="video/mp4">
</video>
 
</body>
</html>

ffmpeg - format 목록

$ ffmpeg -formats
ffmpeg version N-73750-gf8e4d37 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --prefix=/opt/ffmpeg --arch=armel --target-os=linux --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-version3 --disable-mmx
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 49.101 / 56. 49.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 23.100 /  5. 23.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
File formats:
 D. = Demuxing supported
 .E = Muxing supported
 --
  E 3g2             3GP2 (3GPP2 file format)
  E 3gp             3GP (3GPP file format)
 D  4xm             4X Technologies
  E a64             a64 - video for Commodore 64
 D  aac             raw ADTS AAC (Advanced Audio Coding)
 DE ac3             raw AC-3
 D  act             ACT Voice file format
 D  adf             Artworx Data Format
 D  adp             ADP
  E adts            ADTS AAC (Advanced Audio Coding)
 DE adx             CRI ADX
 D  aea             MD STUDIO audio
 D  afc             AFC
 DE aiff            Audio IFF
 DE alaw            PCM A-law
 D  alias_pix       Alias/Wavefront PIX image
 DE amr             3GPP AMR
 D  anm             Deluxe Paint Animation
 D  apc             CRYO APC
 D  ape             Monkey's Audio
 DE apng            Animated Portable Network Graphics
 D  aqtitle         AQTitle subtitles
 DE asf             ASF (Advanced / Active Streaming Format)
 D  asf_o           ASF (Advanced / Active Streaming Format)
  E asf_stream      ASF (Advanced / Active Streaming Format)
 DE ass             SSA (SubStation Alpha) subtitle
 DE ast             AST (Audio Stream)
 DE au              Sun AU
 DE avi             AVI (Audio Video Interleaved)
  E avm2            SWF (ShockWave Flash) (AVM2)
 D  avr             AVR (Audio Visual Research)
 D  avs             AVS
 D  bethsoftvid     Bethesda Softworks VID
 D  bfi             Brute Force & Ignorance
 D  bfstm           BFSTM (Binary Cafe Stream)
 D  bin             Binary text
 D  bink            Bink
 DE bit             G.729 BIT file format
 D  bmp_pipe        piped bmp sequence
 D  bmv             Discworld II BMV
 D  boa             Black Ops Audio
 D  brender_pix     BRender PIX image
 D  brstm           BRSTM (Binary Revolution Stream)
 D  c93             Interplay C93
 DE caf             Apple CAF (Core Audio Format)
 DE cavsvideo       raw Chinese AVS (Audio Video Standard) video
 D  cdg             CD Graphics
 D  cdxl            Commodore CDXL video
 D  cine            Phantom Cine
 D  concat          Virtual concatenation script
  E crc             CRC testing
  E dash            DASH Muxer
 DE data            raw data
 DE daud            D-Cinema audio
 D  dds_pipe        piped dds sequence
 D  dfa             Chronomaster DFA
 DE dirac           raw Dirac
 DE dnxhd           raw DNxHD (SMPTE VC-3)
 D  dpx_pipe        piped dpx sequence
 D  dsf             DSD Stream File (DSF)
 D  dsicin          Delphine Software International CIN
 D  dss             Digital Speech Standard (DSS)
 DE dts             raw DTS
 D  dtshd           raw DTS-HD
 DE dv              DV (Digital Video)
 D  dv1394          DV1394 A/V grab
 D  dvbsub          raw dvbsub
  E dvd             MPEG-2 PS (DVD VOB)
 D  dxa             DXA
 D  ea              Electronic Arts Multimedia
 D  ea_cdata        Electronic Arts cdata
 DE eac3            raw E-AC-3
 D  epaf            Ensoniq Paris Audio File
 D  exr_pipe        piped exr sequence
 DE f32be           PCM 32-bit floating-point big-endian
 DE f32le           PCM 32-bit floating-point little-endian
  E f4v             F4V Adobe Flash Video
 DE f64be           PCM 64-bit floating-point big-endian
 DE f64le           PCM 64-bit floating-point little-endian
 DE fbdev           Linux framebuffer
 DE ffm             FFM (FFserver live feed)
 DE ffmetadata      FFmpeg metadata in text
 D  film_cpk        Sega FILM / CPK
 DE filmstrip       Adobe Filmstrip
 DE flac            raw FLAC
 D  flic            FLI/FLC/FLX animation
 DE flv             FLV (Flash Video)
  E framecrc        framecrc testing
  E framemd5        Per-frame MD5 testing
 D  frm             Megalux Frame
 DE g722            raw G.722
 DE g723_1          raw G.723.1
 D  g729            G.729 raw format demuxer
 DE gif             GIF Animation
 D  gsm             raw GSM
 DE gxf             GXF (General eXchange Format)
 DE h261            raw H.261
 DE h263            raw H.263
 DE h264            raw H.264 video
  E hds             HDS Muxer
 DE hevc            raw HEVC video
  E hls             Apple HTTP Live Streaming
 D  hls,applehttp   Apple HTTP Live Streaming
 D  hnm             Cryo HNM v4
 DE ico             Microsoft Windows ICO
 D  idcin           id Cinematic
 D  idf             iCE Draw File
 D  iff             IFF (Interchange File Format)
 DE ilbc            iLBC storage
 DE image2          image2 sequence
 DE image2pipe      piped image2 sequence
 D  ingenient       raw Ingenient MJPEG
 D  ipmovie         Interplay MVE
  E ipod            iPod H.264 MP4 (MPEG-4 Part 14)
 DE ircam           Berkeley/IRCAM/CARL Sound Format
  E ismv            ISMV/ISMA (Smooth Streaming)
 D  iss             Funcom ISS
 D  iv8             IndigoVision 8000 video
 DE ivf             On2 IVF
 D  j2k_pipe        piped j2k sequence
 DE jacosub         JACOsub subtitle format
 D  jpeg_pipe       piped jpeg sequence
 D  jpegls_pipe     piped jpegls sequence
 D  jv              Bitmap Brothers JV
 DE latm            LOAS/LATM
 D  lavfi           Libavfilter virtual input device
 D  live_flv        live RTMP FLV (Flash Video)
 D  lmlm4           raw lmlm4
 D  loas            LOAS AudioSyncStream
 DE lrc             LRC lyrics
 D  lvf             LVF
 D  lxf             VR native stream (LXF)
 DE m4v             raw MPEG-4 video
  E matroska        Matroska
 D  matroska,webm   Matroska / WebM
  E md5             MD5 testing
 D  mgsts           Metal Gear Solid: The Twin Snakes
 DE microdvd        MicroDVD subtitle format
 DE mjpeg           raw MJPEG video
  E mkvtimestamp_v2 extract pts as timecode v2 format, as defined by mkvtoolnix
 DE mlp             raw MLP
 D  mlv             Magic Lantern Video (MLV)
 D  mm              American Laser Games MM
 DE mmf             Yamaha SMAF
  E mov             QuickTime / MOV
 D  mov,mp4,m4a,3gp,3g2,mj2 QuickTime / MOV
  E mp2             MP2 (MPEG audio layer 2)
 DE mp3             MP3 (MPEG audio layer 3)
  E mp4             MP4 (MPEG-4 Part 14)
 D  mpc             Musepack
 D  mpc8            Musepack SV8
 DE mpeg            MPEG-1 Systems / MPEG program stream
  E mpeg1video      raw MPEG-1 video
  E mpeg2video      raw MPEG-2 video
 DE mpegts          MPEG-TS (MPEG-2 Transport Stream)
 D  mpegtsraw       raw MPEG-TS (MPEG-2 Transport Stream)
 D  mpegvideo       raw MPEG video
 DE mpjpeg          MIME multipart JPEG
 D  mpl2            MPL2 subtitles
 D  mpsub           MPlayer subtitles
 D  msnwctcp        MSN TCP Webcam stream
 D  mtv             MTV
 DE mulaw           PCM mu-law
 D  mv              Silicon Graphics Movie
 D  mvi             Motion Pixels MVI
 DE mxf             MXF (Material eXchange Format)
  E mxf_d10         MXF (Material eXchange Format) D-10 Mapping
  E mxf_opatom      MXF (Material eXchange Format) Operational Pattern Atom
 D  mxg             MxPEG clip
 D  nc              NC camera feed
 D  nistsphere      NIST SPeech HEader REsources
 D  nsv             Nullsoft Streaming Video
  E null            raw null video
 DE nut             NUT
 D  nuv             NuppelVideo
  E oga             Ogg Audio
 DE ogg             Ogg
 DE oma             Sony OpenMG audio
  E opus            Ogg Opus
 DE oss             OSS (Open Sound System) playback
 D  paf             Amazing Studio Packed Animation File
 D  pictor_pipe     piped pictor sequence
 D  pjs             PJS (Phoenix Japanimation Society) subtitles
 D  pmp             Playstation Portable PMP
 D  png_pipe        piped png sequence
  E psp             PSP MP4 (MPEG-4 Part 14)
 D  psxstr          Sony Playstation STR
 D  pva             TechnoTrend PVA
 D  pvf             PVF (Portable Voice Format)
 D  qcp             QCP
 D  qdraw_pipe      piped qdraw sequence
 D  r3d             REDCODE R3D
 DE rawvideo        raw video
 D  realtext        RealText subtitle format
 D  redspark        RedSpark
 D  rl2             RL2
 DE rm              RealMedia
 DE roq             raw id RoQ
 D  rpl             RPL / ARMovie
 D  rsd             GameCube RSD
 DE rso             Lego Mindstorms RSO
 DE rtp             RTP output
  E rtp_mpegts      RTP/mpegts output format
 DE rtsp            RTSP output
 DE s16be           PCM signed 16-bit big-endian
 DE s16le           PCM signed 16-bit little-endian
 DE s24be           PCM signed 24-bit big-endian
 DE s24le           PCM signed 24-bit little-endian
 DE s32be           PCM signed 32-bit big-endian
 DE s32le           PCM signed 32-bit little-endian
 DE s8              PCM signed 8-bit
 D  sami            SAMI subtitle format
 DE sap             SAP output
 D  sbg             SBaGen binaural beats script
 D  sdp             SDP
 D  sdr2            SDR2
  E segment         segment
 D  sgi_pipe        piped sgi sequence
 D  shn             raw Shorten
 D  siff            Beam Software SIFF
  E singlejpeg      JPEG single image
 D  sln             Asterisk raw pcm
 DE smjpeg          Loki SDL MJPEG
 D  smk             Smacker
  E smoothstreaming Smooth Streaming Muxer
 D  smush           LucasArts Smush
 D  sol             Sierra SOL
 DE sox             SoX native
 DE spdif           IEC 61937 (used on S/PDIF - IEC958)
  E spx             Ogg Speex
 DE srt             SubRip subtitle
 D  stl             Spruce subtitle format
  E stream_segment,ssegment streaming segment muxer
 D  subviewer       SubViewer subtitle format
 D  subviewer1      SubViewer v1 subtitle format
 D  sunrast_pipe    piped sunrast sequence
 D  sup             raw HDMV Presentation Graphic Stream subtitles
  E svcd            MPEG-2 PS (SVCD)
 DE swf             SWF (ShockWave Flash)
 D  tak             raw TAK
 D  tedcaptions     TED Talks captions
  E tee             Multiple muxer tee
 D  thp             THP
 D  tiertexseq      Tiertex Limited SEQ
 D  tiff_pipe       piped tiff sequence
 D  tmv             8088flex TMV
 DE truehd          raw TrueHD
 D  tta             TTA (True Audio)
 D  tty             Tele-typewriter
 D  txd             Renderware TeXture Dictionary
 DE u16be           PCM unsigned 16-bit big-endian
 DE u16le           PCM unsigned 16-bit little-endian
 DE u24be           PCM unsigned 24-bit big-endian
 DE u24le           PCM unsigned 24-bit little-endian
 DE u32be           PCM unsigned 32-bit big-endian
 DE u32le           PCM unsigned 32-bit little-endian
 DE u8              PCM unsigned 8-bit
  E uncodedframecrc uncoded framecrc testing
  E v4l2            Video4Linux2 output device
 DE vc1             raw VC-1 video
 DE vc1test         VC-1 test bitstream
  E vcd             MPEG-1 Systems / MPEG program stream (VCD)
 D  video4linux2,v4l2 Video4Linux2 device grab
 D  vivo            Vivo
 D  vmd             Sierra VMD
  E vob             MPEG-2 PS (VOB)
 D  vobsub          VobSub subtitle format
 DE voc             Creative Voice
 D  vplayer         VPlayer subtitles
 D  vqf             Nippon Telegraph and Telephone Corporation (NTT) TwinVQ
 DE w64             Sony Wave64
 DE wav             WAV / WAVE (Waveform Audio)
 D  wc3movie        Wing Commander III movie
  E webm            WebM
  E webm_chunk      WebM Chunk Muxer
 DE webm_dash_manifest WebM DASH Manifest
  E webp            WebP
 D  webp_pipe       piped webp sequence
 DE webvtt          WebVTT subtitle
 D  wsaud           Westwood Studios audio
 D  wsvqa           Westwood Studios VQA
 DE wtv             Windows Television (WTV)
 DE wv              raw WavPack
 D  xa              Maxis XA
 D  xbin            eXtended BINary text (XBIN)
 D  xmv             Microsoft XMV
 D  xwma            Microsoft xWMA
 D  yop             Psygnosis YOP
 DE yuv4mpegpipe    YUV4MPEG pipe

ffmpeg - codec 목록

$ ffmpeg -codecs
ffmpeg version N-73750-gf8e4d37 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6 (Debian 4.6.3-14+rpi1)
  configuration: --prefix=/opt/ffmpeg --arch=armel --target-os=linux --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-version3 --disable-mmx
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 49.101 / 56. 49.101
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 23.100 /  5. 23.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Codecs:
 D..... = Decoding supported
 .E.... = Encoding supported
 ..V... = Video codec
 ..A... = Audio codec
 ..S... = Subtitle codec
 ...I.. = Intra frame-only codec
 ....L. = Lossy compression
 .....S = Lossless compression
 -------
 D.VI.. 012v                 Uncompressed 4:2:2 10-bit
 D.V.L. 4xm                  4X Movie
 D.VI.S 8bps                 QuickTime 8BPS video
 .EVIL. a64_multi            Multicolor charset for Commodore 64 (encoders: a64multi )
 .EVIL. a64_multi5           Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5 )
 D.V..S aasc                 Autodesk RLE
 D.VIL. aic                  Apple Intermediate Codec
 DEVI.S alias_pix            Alias/Wavefront PIX image
 DEVIL. amv                  AMV Video
 D.V.L. anm                  Deluxe Paint Animation
 D.V.L. ansi                 ASCII/ANSI art
 DEV..S apng                 APNG (Animated Portable Network Graphics) image
 DEVIL. asv1                 ASUS V1
 DEVIL. asv2                 ASUS V2
 D.VIL. aura                 Auravision AURA
 D.VIL. aura2                Auravision Aura 2
 D.V... avrn                 Avid AVI Codec
 DEVI.. avrp                 Avid 1:1 10-bit RGB Packer
 D.V.L. avs                  AVS (Audio Video Standard) video
 DEVI.. avui                 Avid Meridien Uncompressed
 DEVI.. ayuv                 Uncompressed packed MS 4:4:4:4
 D.V.L. bethsoftvid          Bethesda VID video
 D.V.L. bfi                  Brute Force & Ignorance
 D.V.L. binkvideo            Bink video
 D.VI.. bintext              Binary text
 DEVI.S bmp                  BMP (Windows and OS/2 bitmap)
 D.V..S bmv_video            Discworld II BMV video
 D.VI.S brender_pix          BRender PIX image
 D.V.L. c93                  Interplay C93
 D.V.L. cavs                 Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)
 D.V.L. cdgraphics           CD Graphics video
 D.VIL. cdxl                 Commodore CDXL video
 DEV.L. cinepak              Cinepak
 DEVIL. cljr                 Cirrus Logic AccuPak
 D.VI.S cllc                 Canopus Lossless Codec
 D.V.L. cmv                  Electronic Arts CMV video (decoders: eacmv )
 D.V... cpia                 CPiA video format
 D.V..S cscd                 CamStudio (decoders: camstudio )
 D.VIL. cyuv                 Creative YUV (CYUV)
 D.VILS dds                  DirectDraw Surface image decoder
 D.V.L. dfa                  Chronomaster DFA
 D.V.LS dirac                Dirac
 DEVIL. dnxhd                VC3/DNxHD
 DEVI.S dpx                  DPX (Digital Picture Exchange) image
 D.V.L. dsicinvideo          Delphine Software International CIN video
 DEVIL. dvvideo              DV (Digital Video)
 D.V..S dxa                  Feeble Files/ScummVM DXA
 D.VI.S dxtory               Dxtory
 D.V.L. escape124            Escape 124
 D.V.L. escape130            Escape 130
 D.VILS exr                  OpenEXR image
 DEV..S ffv1                 FFmpeg video codec #1
 DEVI.S ffvhuff              Huffyuv FFmpeg variant
 D.V.L. fic                  Mirillis FIC
 DEV..S flashsv              Flash Screen Video v1
 DEV.L. flashsv2             Flash Screen Video v2
 D.V..S flic                 Autodesk Animator Flic video
 DEV.L. flv1                 FLV / Sorenson Spark / Sorenson H.263 (Flash Video) (decoders: flv ) (encoders: flv )
 D.V..S fraps                Fraps
 D.VI.S frwu                 Forward Uncompressed
 D.V.L. g2m                  Go2Meeting
 DEV..S gif                  GIF (Graphics Interchange Format)
 DEV.L. h261                 H.261
 DEV.L. h263                 H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2
 D.V.L. h263i                Intel H.263
 DEV.L. h263p                H.263+ / H.263-1998 / H.263 version 2
 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (encoders: libx264 libx264rgb )
 D.VIL. hap                  Vidvox Hap decoder
 D.V.L. hevc                 H.265 / HEVC (High Efficiency Video Coding)
 D.V.L. hnm4video            HNM 4 video
 D.VIL. hq_hqa               Canopus HQ/HQA
 D.VIL. hqx                  Canopus HQX
 DEVI.S huffyuv              HuffYUV
 D.V.L. idcin                id Quake II CIN video (decoders: idcinvideo )
 D.VI.. idf                  iCEDraw text
 D.V.L. iff_byterun1         IFF ByteRun1 (decoders: iff )
 D.V.L. iff_ilbm             IFF ILBM (decoders: iff )
 D.V.L. indeo2               Intel Indeo 2
 D.V.L. indeo3               Intel Indeo 3
 D.V.L. indeo4               Intel Indeo Video Interactive 4
 D.V.L. indeo5               Intel Indeo Video Interactive 5
 D.V.L. interplayvideo       Interplay MVE video
 DEVILS jpeg2000             JPEG 2000
 DEVILS jpegls               JPEG-LS
 D.VIL. jv                   Bitmap Brothers JV video
 D.V.L. kgv1                 Kega Game Video
 D.V.L. kmvc                 Karl Morton's video codec
 D.VI.S lagarith             Lagarith lossless
 .EVI.S ljpeg                Lossless JPEG
 D.VI.S loco                 LOCO
 D.V.L. mad                  Electronic Arts Madcow Video (decoders: eamad )
 D.VIL. mdec                 Sony PlayStation MDEC (Motion DECoder)
 D.V.L. mimic                Mimic
 DEVIL. mjpeg                Motion JPEG
 D.VIL. mjpegb               Apple MJPEG-B
 D.V.L. mmvideo              American Laser Games MM Video
 D.V.L. motionpixels         Motion Pixels video
 DEV.L. mpeg1video           MPEG-1 video
 DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo )
 DEV.L. mpeg4                MPEG-4 part 2
 ..V.L. mpegvideo_xvmc       MPEG-1/2 video XvMC (X-Video Motion Compensation)
 D.V.L. msa1                 MS ATC Screen
 D.V.L. msmpeg4v1            MPEG-4 part 2 Microsoft variant version 1
 DEV.L. msmpeg4v2            MPEG-4 part 2 Microsoft variant version 2
 DEV.L. msmpeg4v3            MPEG-4 part 2 Microsoft variant version 3 (decoders: msmpeg4 ) (encoders: msmpeg4 )
 D.V..S msrle                Microsoft RLE
 D.V.L. mss1                 MS Screen 1
 D.VIL. mss2                 MS Windows Media Video V9 Screen
 DEV.L. msvideo1             Microsoft Video 1
 D.VI.S mszh                 LCL (LossLess Codec Library) MSZH
 D.V.L. mts2                 MS Expression Encoder Screen
 D.VIL. mvc1                 Silicon Graphics Motion Video Compressor 1
 D.VIL. mvc2                 Silicon Graphics Motion Video Compressor 2
 D.V.L. mxpeg                Mobotix MxPEG video
 D.V.L. nuv                  NuppelVideo/RTJPEG
 D.V.L. paf_video            Amazing Studio Packed Animation File Video
 DEVI.S pam                  PAM (Portable AnyMap) image
 DEVI.S pbm                  PBM (Portable BitMap) image
 DEVI.S pcx                  PC Paintbrush PCX image
 DEVI.S pgm                  PGM (Portable GrayMap) image
 DEVI.S pgmyuv               PGMYUV (Portable GrayMap YUV) image
 D.VIL. pictor               Pictor/PC Paint
 DEV..S png                  PNG (Portable Network Graphics) image
 DEVI.S ppm                  PPM (Portable PixelMap) image
 DEVIL. prores               Apple ProRes (iCodec Pro) (decoders: prores prores_lgpl ) (encoders: prores prores_aw prores_ks )
 D.VIL. ptx                  V.Flash PTX image
 D.VI.S qdraw                Apple QuickDraw
 D.V.L. qpeg                 Q-team QPEG
 DEV..S qtrle                QuickTime Animation (RLE) video
 DEVI.S r10k                 AJA Kona 10-bit RGB Codec
 DEVI.S r210                 Uncompressed RGB 10-bit
 DEVI.S rawvideo             raw video
 D.VIL. rl2                  RL2 video
 DEV.L. roq                  id RoQ video (decoders: roqvideo ) (encoders: roqvideo )
 D.V.L. rpza                 QuickTime video (RPZA)
 DEV.L. rv10                 RealVideo 1.0
 DEV.L. rv20                 RealVideo 2.0
 D.V.L. rv30                 RealVideo 3.0
 D.V.L. rv40                 RealVideo 4.0
 D.V.L. sanm                 LucasArts SANM/SMUSH video
 DEVI.S sgi                  SGI image
 D.VI.S sgirle               SGI RLE 8-bit
 D.V.L. smackvideo           Smacker video (decoders: smackvid )
 D.V.L. smc                  QuickTime Graphics (SMC)
 D.V... smvjpeg              Sigmatel Motion Video
 DEV.LS snow                 Snow
 D.VIL. sp5x                 Sunplus JPEG (SP5X)
 DEVI.S sunrast              Sun Rasterfile image
 DEV.L. svq1                 Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1
 D.V.L. svq3                 Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3
 DEVI.S targa                Truevision Targa image
 D.VI.. targa_y216           Pinnacle TARGA CineWave YUV16
 D.V.L. tdsc                 TDSC
 D.V.L. tgq                  Electronic Arts TGQ video (decoders: eatgq )
 D.V.L. tgv                  Electronic Arts TGV video (decoders: eatgv )
 D.V.L. theora               Theora
 D.VIL. thp                  Nintendo Gamecube THP video
 D.V.L. tiertexseqvideo      Tiertex Limited SEQ video
 DEVI.S tiff                 TIFF image
 D.VIL. tmv                  8088flex TMV
 D.V.L. tqi                  Electronic Arts TQI video (decoders: eatqi )
 D.V.L. truemotion1          Duck TrueMotion 1.0
 D.V.L. truemotion2          Duck TrueMotion 2.0
 D.V..S tscc                 TechSmith Screen Capture Codec (decoders: camtasia )
 D.V.L. tscc2                TechSmith Screen Codec 2
 D.VIL. txd                  Renderware TXD (TeXture Dictionary) image
 D.V.L. ulti                 IBM UltiMotion (decoders: ultimotion )
 DEVI.S utvideo              Ut Video
 DEVI.S v210                 Uncompressed 4:2:2 10-bit
 D.VI.S v210x                Uncompressed 4:2:2 10-bit
 DEVI.. v308                 Uncompressed packed 4:4:4
 DEVI.. v408                 Uncompressed packed QT 4:4:4:4
 DEVI.S v410                 Uncompressed 4:4:4 10-bit
 D.V.L. vb                   Beam Software VB
 D.VI.S vble                 VBLE Lossless Codec
 D.V.L. vc1                  SMPTE VC-1
 D.V.L. vc1image             Windows Media Video 9 Image v2
 D.VIL. vcr1                 ATI VCR1
 D.VIL. vixl                 Miro VideoXL (decoders: xl )
 D.V.L. vmdvideo             Sierra VMD video
 D.V..S vmnc                 VMware Screen Codec / VMware Video
 D.V.L. vp3                  On2 VP3
 D.V.L. vp5                  On2 VP5
 D.V.L. vp6                  On2 VP6
 D.V.L. vp6a                 On2 VP6 (Flash version, with alpha channel)
 D.V.L. vp6f                 On2 VP6 (Flash version)
 D.V.L. vp7                  On2 VP7
 D.V.L. vp8                  On2 VP8
 D.V.L. vp9                  Google VP9
 D.VILS webp                 WebP
 DEV.L. wmv1                 Windows Media Video 7
 DEV.L. wmv2                 Windows Media Video 8
 D.V.L. wmv3                 Windows Media Video 9
 D.V.L. wmv3image            Windows Media Video 9 Image
 D.VIL. wnv1                 Winnov WNV1
 D.V.L. ws_vqa               Westwood Studios VQA (Vector Quantized Animation) video (decoders: vqavideo )
 D.V.L. xan_wc3              Wing Commander III / Xan
 D.V.L. xan_wc4              Wing Commander IV / Xxan
 D.VI.. xbin                 eXtended BINary text
 DEVI.S xbm                  XBM (X BitMap) image
 DEVIL. xface                X-face image
 DEVI.S xwd                  XWD (X Window Dump) image
 DEVI.. y41p                 Uncompressed YUV 4:1:1 12-bit
 D.V.L. yop                  Psygnosis YOP Video
 DEVI.. yuv4                 Uncompressed packed 4:2:0
 D.V..S zerocodec            ZeroCodec Lossless Video
 DEVI.S zlib                 LCL (LossLess Codec Library) ZLIB
 DEV..S zmbv                 Zip Motion Blocks Video
 ..A.L. 4gv                  4GV (Fourth Generation Vocoder)
 D.A.L. 8svx_exp             8SVX exponential
 D.A.L. 8svx_fib             8SVX fibonacci
 DEA.L. aac                  AAC (Advanced Audio Coding) (decoders: aac aac_fixed ) (encoders: aac libfaac )
 D.A.L. aac_latm             AAC LATM (Advanced Audio Coding LATM syntax)
 DEA.L. ac3                  ATSC A/52A (AC-3) (decoders: ac3 ac3_fixed ) (encoders: ac3 ac3_fixed )
 D.A.L. adpcm_4xm            ADPCM 4X Movie
 DEA.L. adpcm_adx            SEGA CRI ADX ADPCM
 D.A.L. adpcm_afc            ADPCM Nintendo Gamecube AFC
 D.A.L. adpcm_ct             ADPCM Creative Technology
 D.A.L. adpcm_dtk            ADPCM Nintendo Gamecube DTK
 D.A.L. adpcm_ea             ADPCM Electronic Arts
 D.A.L. adpcm_ea_maxis_xa    ADPCM Electronic Arts Maxis CDROM XA
 D.A.L. adpcm_ea_r1          ADPCM Electronic Arts R1
 D.A.L. adpcm_ea_r2          ADPCM Electronic Arts R2
 D.A.L. adpcm_ea_r3          ADPCM Electronic Arts R3
 D.A.L. adpcm_ea_xas         ADPCM Electronic Arts XAS
 DEA.L. adpcm_g722           G.722 ADPCM (decoders: g722 ) (encoders: g722 )
 DEA.L. adpcm_g726           G.726 ADPCM (decoders: g726 ) (encoders: g726 )
 D.A.L. adpcm_g726le         G.726 ADPCM little-endian (decoders: g726le )
 D.A.L. adpcm_ima_amv        ADPCM IMA AMV
 D.A.L. adpcm_ima_apc        ADPCM IMA CRYO APC
 D.A.L. adpcm_ima_dk3        ADPCM IMA Duck DK3
 D.A.L. adpcm_ima_dk4        ADPCM IMA Duck DK4
 D.A.L. adpcm_ima_ea_eacs    ADPCM IMA Electronic Arts EACS
 D.A.L. adpcm_ima_ea_sead    ADPCM IMA Electronic Arts SEAD
 D.A.L. adpcm_ima_iss        ADPCM IMA Funcom ISS
 D.A.L. adpcm_ima_oki        ADPCM IMA Dialogic OKI
 DEA.L. adpcm_ima_qt         ADPCM IMA QuickTime
 D.A.L. adpcm_ima_rad        ADPCM IMA Radical
 D.A.L. adpcm_ima_smjpeg     ADPCM IMA Loki SDL MJPEG
 DEA.L. adpcm_ima_wav        ADPCM IMA WAV
 D.A.L. adpcm_ima_ws         ADPCM IMA Westwood
 DEA.L. adpcm_ms             ADPCM Microsoft
 D.A.L. adpcm_sbpro_2        ADPCM Sound Blaster Pro 2-bit
 D.A.L. adpcm_sbpro_3        ADPCM Sound Blaster Pro 2.6-bit
 D.A.L. adpcm_sbpro_4        ADPCM Sound Blaster Pro 4-bit
 DEA.L. adpcm_swf            ADPCM Shockwave Flash
 D.A.L. adpcm_thp            ADPCM Nintendo THP
 D.A.L. adpcm_thp_le         ADPCM Nintendo THP (Little-Endian)
 D.A.L. adpcm_vima           LucasArts VIMA audio (decoders: adpcm_vima vima )
 D.A.L. adpcm_xa             ADPCM CDROM XA
 DEA.L. adpcm_yamaha         ADPCM Yamaha
 DEA..S alac                 ALAC (Apple Lossless Audio Codec)
 D.A.L. amr_nb               AMR-NB (Adaptive Multi-Rate NarrowBand) (decoders: amrnb )
 D.A.L. amr_wb               AMR-WB (Adaptive Multi-Rate WideBand) (decoders: amrwb )
 D.A..S ape                  Monkey's Audio
 D.A.L. atrac1               ATRAC1 (Adaptive TRansform Acoustic Coding)
 D.A.L. atrac3               ATRAC3 (Adaptive TRansform Acoustic Coding 3)
 D.A.L. atrac3p              ATRAC3+ (Adaptive TRansform Acoustic Coding 3+) (decoders: atrac3plus )
 D.A.L. avc                  On2 Audio for Video Codec (decoders: on2avc )
 D.A.L. binkaudio_dct        Bink Audio (DCT)
 D.A.L. binkaudio_rdft       Bink Audio (RDFT)
 D.A.L. bmv_audio            Discworld II BMV audio
 ..A.L. celt                 Constrained Energy Lapped Transform (CELT)
 DEA.L. comfortnoise         RFC 3389 Comfort Noise
 D.A.L. cook                 Cook / Cooker / Gecko (RealAudio G2)
 D.A.L. dsd_lsbf             DSD (Direct Stream Digital), least significant bit first
 D.A.L. dsd_lsbf_planar      DSD (Direct Stream Digital), least significant bit first, planar
 D.A.L. dsd_msbf             DSD (Direct Stream Digital), most significant bit first
 D.A.L. dsd_msbf_planar      DSD (Direct Stream Digital), most significant bit first, planar
 D.A.L. dsicinaudio          Delphine Software International CIN audio
 D.A.L. dss_sp               Digital Speech Standard - Standard Play mode (DSS SP)
 DEA.LS dts                  DCA (DTS Coherent Acoustics) (decoders: dca ) (encoders: dca )
 ..A.L. dvaudio              DV audio
 DEA.L. eac3                 ATSC A/52B (AC-3, E-AC-3)
 D.A.L. evrc                 EVRC (Enhanced Variable Rate Codec)
 DEA..S flac                 FLAC (Free Lossless Audio Codec)
 DEA.L. g723_1               G.723.1
 D.A.L. g729                 G.729
 D.A.L. gsm                  GSM
 D.A.L. gsm_ms               GSM Microsoft variant
 D.A.L. iac                  IAC (Indeo Audio Coder)
 ..A.L. ilbc                 iLBC (Internet Low Bitrate Codec)
 D.A.L. imc                  IMC (Intel Music Coder)
 D.A.L. interplay_dpcm       DPCM Interplay
 D.A.L. mace3                MACE (Macintosh Audio Compression/Expansion) 3:1
 D.A.L. mace6                MACE (Macintosh Audio Compression/Expansion) 6:1
 D.A.L. metasound            Voxware MetaSound
 D.A..S mlp                  MLP (Meridian Lossless Packing)
 D.A.L. mp1                  MP1 (MPEG audio layer 1) (decoders: mp1 mp1float )
 DEA.L. mp2                  MP2 (MPEG audio layer 2) (decoders: mp2 mp2float ) (encoders: mp2 mp2fixed )
 DEA.L. mp3                  MP3 (MPEG audio layer 3) (decoders: mp3 mp3float ) (encoders: libmp3lame )
 D.A.L. mp3adu               ADU (Application Data Unit) MP3 (MPEG audio layer 3) (decoders: mp3adu mp3adufloat )
 D.A.L. mp3on4               MP3onMP4 (decoders: mp3on4 mp3on4float )
 D.A..S mp4als               MPEG-4 Audio Lossless Coding (ALS) (decoders: als )
 D.A.L. musepack7            Musepack SV7 (decoders: mpc7 )
 D.A.L. musepack8            Musepack SV8 (decoders: mpc8 )
 DEA.L. nellymoser           Nellymoser Asao
 D.A.L. opus                 Opus (Opus Interactive Audio Codec)
 D.A.L. paf_audio            Amazing Studio Packed Animation File Audio
 DEA.L. pcm_alaw             PCM A-law / G.711 A-law
 D.A..S pcm_bluray           PCM signed 16|20|24-bit big-endian for Blu-ray media
 D.A..S pcm_dvd              PCM signed 20|24-bit big-endian
 DEA..S pcm_f32be            PCM 32-bit floating point big-endian
 DEA..S pcm_f32le            PCM 32-bit floating point little-endian
 DEA..S pcm_f64be            PCM 64-bit floating point big-endian
 DEA..S pcm_f64le            PCM 64-bit floating point little-endian
 D.A..S pcm_lxf              PCM signed 20-bit little-endian planar
 DEA.L. pcm_mulaw            PCM mu-law / G.711 mu-law
 DEA..S pcm_s16be            PCM signed 16-bit big-endian
 DEA..S pcm_s16be_planar     PCM signed 16-bit big-endian planar
 DEA..S pcm_s16le            PCM signed 16-bit little-endian
 DEA..S pcm_s16le_planar     PCM signed 16-bit little-endian planar
 DEA..S pcm_s24be            PCM signed 24-bit big-endian
 DEA..S pcm_s24daud          PCM D-Cinema audio signed 24-bit
 DEA..S pcm_s24le            PCM signed 24-bit little-endian
 DEA..S pcm_s24le_planar     PCM signed 24-bit little-endian planar
 DEA..S pcm_s32be            PCM signed 32-bit big-endian
 DEA..S pcm_s32le            PCM signed 32-bit little-endian
 DEA..S pcm_s32le_planar     PCM signed 32-bit little-endian planar
 DEA..S pcm_s8               PCM signed 8-bit
 DEA..S pcm_s8_planar        PCM signed 8-bit planar
 DEA..S pcm_u16be            PCM unsigned 16-bit big-endian
 DEA..S pcm_u16le            PCM unsigned 16-bit little-endian
 DEA..S pcm_u24be            PCM unsigned 24-bit big-endian
 DEA..S pcm_u24le            PCM unsigned 24-bit little-endian
 DEA..S pcm_u32be            PCM unsigned 32-bit big-endian
 DEA..S pcm_u32le            PCM unsigned 32-bit little-endian
 DEA..S pcm_u8               PCM unsigned 8-bit
 D.A.L. pcm_zork             PCM Zork
 D.A.L. qcelp                QCELP / PureVoice
 D.A.L. qdm2                 QDesign Music Codec 2
 ..A.L. qdmc                 QDesign Music
 DEA.L. ra_144               RealAudio 1.0 (14.4K) (decoders: real_144 ) (encoders: real_144 )
 D.A.L. ra_288               RealAudio 2.0 (28.8K) (decoders: real_288 )
 D.A..S ralf                 RealAudio Lossless
 DEA.L. roq_dpcm             DPCM id RoQ
 DEA..S s302m                SMPTE 302M
 D.A..S shorten              Shorten
 D.A.L. sipr                 RealAudio SIPR / ACELP.NET
 D.A.L. smackaudio           Smacker audio (decoders: smackaud )
 ..A.L. smv                  SMV (Selectable Mode Vocoder)
 D.A.L. sol_dpcm             DPCM Sol
 DEA... sonic                Sonic
 .EA... sonicls              Sonic lossless
 ..A.L. speex                Speex
 D.A..S tak                  TAK (Tom's lossless Audio Kompressor)
 D.A..S truehd               TrueHD
 D.A.L. truespeech           DSP Group TrueSpeech
 DEA..S tta                  TTA (True Audio)
 D.A.L. twinvq               VQF TwinVQ
 D.A.L. vima                 LucasArts VIMA audio (deprecated id) (decoders: adpcm_vima vima )
 D.A.L. vmdaudio             Sierra VMD audio
 DEA.L. vorbis               Vorbis
 ..A.L. voxware              Voxware RT29 Metasound
 D.A... wavesynth            Wave synthesis pseudo-codec
 DEA.LS wavpack              WavPack
 D.A.L. westwood_snd1        Westwood Audio (SND1) (decoders: ws_snd1 )
 D.A..S wmalossless          Windows Media Audio Lossless
 D.A.L. wmapro               Windows Media Audio 9 Professional
 DEA.L. wmav1                Windows Media Audio 1
 DEA.L. wmav2                Windows Media Audio 2
 D.A.L. wmavoice             Windows Media Audio Voice
 D.A.L. xan_dpcm             DPCM Xan
 ..D... bin_data             binary data
 ..D... dvd_nav_packet       DVD Nav packet
 ..D... klv                  SMPTE 336M Key-Length-Value (KLV) metadata
 ..D... otf                  OpenType font
 ..D... timed_id3            timed ID3 metadata
 ..D... ttf                  TrueType font
 DES... ass                  ASS (Advanced SSA) subtitle
 DES... dvb_subtitle         DVB subtitles (decoders: dvbsub ) (encoders: dvbsub )
 ..S... dvb_teletext         DVB teletext
 DES... dvd_subtitle         DVD subtitles (decoders: dvdsub ) (encoders: dvdsub )
 D.S... eia_608              EIA-608 closed captions (decoders: cc_dec )
 D.S... hdmv_pgs_subtitle    HDMV Presentation Graphic Stream subtitles (decoders: pgssub )
 D.S... jacosub              JACOsub subtitle
 D.S... microdvd             MicroDVD subtitle
 DES... mov_text             MOV text
 D.S... mpl2                 MPL2 subtitle
 D.S... pjs                  PJS (Phoenix Japanimation Society) subtitle
 D.S... realtext             RealText subtitle
 D.S... sami                 SAMI subtitle
 ..S... srt                  SubRip subtitle with embedded timing
 DES... ssa                  SSA (SubStation Alpha) subtitle
 D.S... stl                  Spruce subtitle format
 DES... subrip               SubRip subtitle (decoders: srt subrip ) (encoders: srt subrip )
 D.S... subviewer            SubViewer subtitle
 D.S... subviewer1           SubViewer v1 subtitle
 D.S... text                 raw UTF-8 text
 D.S... vplayer              VPlayer subtitle
 DES... webvtt               WebVTT subtitle
 DES... xsub                 XSUB

vlc rtsp 스트리밍

$ cvlc v4l2:///dev/video0 --v4l2-width 640 --v4l2-height 480 --v4l2-chroma h264 --sout '#rtp{sdp=rtsp://:8554/}'
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x116b860] dummy interface: using the dummy interface module...

vlc 클라이언트

728x90
728x90

출처 : 라즈베리파이 활용 강좌 : 라즈베리 파이로 원격 데스크탑 사용하기
파이카메라 활용강좌 : V4L2(Video4Linux) 와 VLC 를 이용한 RTSP Streaming

Raspberry PI OS 설치

출처 : 라즈베리 파이 시작하기_OS설치

1. SD Format

SD Formatter for Windows용을 받아서 포맷한다.

2. OS 받기

NOOBS 받기

3. 앞축을 풀고 파일 복사

4. 부팅

SSH 데몬 실행

$ sudo raspi-config

키 생성 오류가 있으면 아래처러 키를 삭제하고 다시 SSH 모둘 확설화를 해본다.

$ sudo rm /etc/ssh/ssh_host*
$ sudo ssh-keygen -A

LCD 설정

출처 : [버섯] 라즈베리 파이용 2.8인치 액정 쉴드(TFT LCD)
Waveshare 3.2/3.5/4 인치 TFT LCD 설정 방법
WaveShare SpotPear 3.2" and 3.5/4.0" TFT LCD overlays for the Raspberry PI and PI 2
waveshare 3.2inch tft-lcd setup - LCD에 Xwindow 띄우기

펌웨어 업그레이드

$ sudo apt-get update
$ sudo apt-get upgrade

SPI 모둘 활성화

$ sudo raspi-config

FBTFT 드라이버들을 파일 시스템의 모듈 설치 디렉토리에 설치하고 다시 재부팅

$ sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Remove old firmware backup
 *** Backing up firmware
 *** Remove old modules backup
 *** Backing up modules 3.18.11+
 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   167    0   167    0     0    156      0 --:--:--  0:00:01 --:--:--   224
100 47.9M  100 47.9M    0     0   821k      0  0:00:59  0:00:59 --:--:-- 1064k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 4.0.7+
 *** depmod 4.0.7-v7+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to b2f5782d2a61cdfa1967942d34eae48900266ae1
 *** A reboot is needed to activate the new firmware
$ sudo reboot

WaveShare TFT LCD 용으로 만들어진 Device Tree 파일 (dtb) 을 다운로드

$ git clone https://github.com/swkim01/waveshare-dtoverlays.git

TFT LCD 의 종류에 따라 해당하는 dtb 파일을 /boot/overlays/ 디렉토리에 복사

$ sudo cp waveshare-dtoverlays/waveshare32b-overlay.dtb /boot/overlays/

/boot/config.txt 파일을 수정하여 커널 초기화 시에 TFT LCD 모듈을 적재하는 코드를 추가

$ sudo vi /boot/config.txt

3.2인치

dtparam=spi=on
dtoverlay=waveshare32b

참고로 화면을 회전시키는 등의 매개변수를 설정하려면 다음 예와 같이 하면 됩니다.

dtoverlay=waveshare32b:rotate=270

HDMI에서 TFT-LCD로 출력 바꾸기

$ vi /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Option "fbdev" "/dev/fb1" -- fb1이면 TFT-LCD / fb0이면 HDMI

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"

        Option          "SwapbuffersWait" "true"
EndSection

Force X windows to Load to PiScreen Automatically on boot

출처 : Enable X windows on PiScreen

자동 로그인

$ sudo vi /etc/inittab

수정전

1:2345:respawn:/sbin/getty --noclear 38400 tty1

수정후

#1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

부팅시 X windows 시작

/etc/rc.local 파일의 exit 구문 위에 내용추가

$ sudo vi /etc/rc.local

su -l pi -c "env FRAMEBUFFER=/dev/fb1 startx &"

RDP 서버 데몬 실행

$ sudo apt-get install xrdp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  tightvncserver xfonts-base
Suggested packages:
  tightvnc-java
The following NEW packages will be installed:
  tightvncserver xfonts-base xrdp
0 upgraded, 3 newly installed, 0 to remove and 38 not upgraded.
Need to get 7,219 kB of archives.
After this operation, 11.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main tightvncserver armhf 1.3.9-6.4 [786 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main xfonts-base all 1:1.0.3 [6,181 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main xrdp armhf 0.5.0-2 [252 kB]
Fetched 7,219 kB in 11s (605 kB/s)                                             
Selecting previously unselected package tightvncserver.
(Reading database ... 77911 files and directories currently installed.)
Unpacking tightvncserver (from .../tightvncserver_1.3.9-6.4_armhf.deb) ...
Selecting previously unselected package xfonts-base.
Unpacking xfonts-base (from .../xfonts-base_1%3a1.0.3_all.deb) ...
Selecting previously unselected package xrdp.
Unpacking xrdp (from .../xrdp_0.5.0-2_armhf.deb) ...
Processing triggers for man-db ...
Processing triggers for fontconfig ...
Setting up tightvncserver (1.3.9-6.4) ...
update-alternatives: using /usr/bin/tightvncserver to provide /usr/bin/vncserver (vncserver) in auto mode
update-alternatives: using /usr/bin/Xtightvnc to provide /usr/bin/Xvnc (Xvnc) in auto mode
update-alternatives: using /usr/bin/tightvncpasswd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode
Setting up xfonts-base (1:1.0.3) ...
Setting up xrdp (0.5.0-2) ...
Generating xrdp RSA keys......
Generating 512 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

done (done).
Starting Remote Desktop Protocol server : xrdp sesman.

원격 데스크톱 연결

Raspberry PI 무선랜 설정

츨처 : wpa_supplicant를 사용한 무선랜 사용 ( WPAPSK 무선 보안 방식 / AES 암호화 )

USB 연결 상태 확인

$ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 005: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
Bus 001 Device 004: ID 24ae:2000

/etc/network/interfaces 확인

$ cat /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Wifi SSID 조회

$ sudo iwlist wlan0 scan | grep SSID
                    ESSID:"kuksu"
                    ESSID:"LUSSOSO_WIFI"
                    ESSID:"netis 2G"
                    ESSID:"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                    ESSID:"hak"
                    ESSID:"sung"
                    ESSID:"asran"
                    ESSID:"iptime-g"
                    ESSID:"U+Net3823"
                    ESSID:"U+zone"
                    ESSID:"\x00"
                    ESSID:""
                    ESSID:"smhouse"
                    ESSID:"\x00"

wpa_passphrase

$ wpa_passphrase "netis 2G" "aaaaaaaa"
network={
        ssid="netis 2G"
        #psk="aaaaaaaa"
        psk=47277e223f0edfc12e24b9d690c7231863048a7fbb11ae3fecc6c7c360b4067b
}

/etc/network/interfaces 수정

$ cat /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
wpa-ssid "netis 2G"
wpa-psk "aaaaaaaa"

-

$ iwconfig
wlan0     IEEE 802.11bgn  ESSID:"netis 2G"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 04:8D:38:17:96:00   
          Bit Rate=121.5 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-29 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:51   Missed beacon:0

lo        no wireless extensions.

eth0      no wireless extensions.

PI Camera 설정

출처 : 라즈베리파이에 카메라 입출력을 받아보자. V4L2(Video4Linux2)설치
파이카메라 활용강좌 : 라즈베리파이 Pi-cam V4L2(Video4Linux2) 설치
라즈베리파이 카메라 성능 테스트
How to install or upgrade UV4L on Raspbian (for the Raspberry Pi)

GPU, Kernel 업데이트 (옵션)

$ sudo apt-get update
$ sudo apt-get upgrade

Pi-Camera 장치 활성화

$ sudo raspi-config

Pi-Camera 캡쳐

$ raspistill -v -o test.jpg

raspistill Camera App v1.3.8

Width 2592, Height 1944, quality 85, filename test.jpg
Time delay 5000, Raw no
Thumbnail enabled Yes, width 64, height 48, quality 35
Link to latest frame enabled  no
Full resolution preview No
Capture method : Single capture

Preview Yes, Full screen Yes
Preview window 0,0,1024,768
Opacity 255
Sharpness 0, Contrast 0, Brightness 50
Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
Rotation 0, hflip No, vflip No
ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
Camera component done
Encoder component done
Starting component connection stage
Connecting camera preview port to video render.
Connecting camera stills port to encoder input port
Opening output file test.jpg
Enabling encoder output port
Starting capture 0
Finished capture 0
Closing down
Close down completed, all components disconnected, disabled and destroyed

V4L2(Video4Linux2) 드라이버 활성화

$ ls /dev/vi*
ls: cannot access /dev/vi*: No such file or directory
$ sudo modprobe bcm2835-v4l2
$  ls /dev/vi*
/dev/video0

V4L2(Video4Linux2) 부팅시 활성화 시키기

$ sudo vi /etc/modules

아래 내용 추가

bcm2835-v4l2

V4L2(Video4Linux2) 인증키 설치

$  wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc
--2015-07-17 10:54:30--  http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc
Resolving www.linux-projects.org (www.linux-projects.org)... 62.149.140.25
Connecting to www.linux-projects.org (www.linux-projects.org)|62.149.140.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1337 (1.3K) [application/pgp-signature]
Saving to: `lrkey.asc'

100%[======================================>] 1,337       --.-K/s   in 0s      

2015-07-17 10:54:31 (14.2 MB/s) - `lrkey.asc' saved [1337/1337]

OK

소스리스트 추가 및 업데이트(apt-get update시 같이 업데이트 됨)

$ echo "deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main " | sudo tee -a /etc/apt/sources.list
$ sudo apt-get update -y

UV4L및 Pi-Camera 드라이버 설치

$ sudo apt-get install uv4l uv4l-raspicam
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  uv4l uv4l-raspicam
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,937 kB of archives.
After this operation, 5,538 kB of additional disk space will be used.
Get:1 http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy/main uv4l armhf 1.9.5-1 [559 kB]
Get:2 http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy/main uv4l-raspicam armhf 1.9.27 [1,377 kB]                              
Fetched 1,937 kB in 3min 31s (9,144 B/s)                                                                                                       
Selecting previously unselected package uv4l.
(Reading database ... 78363 files and directories currently installed.)
Unpacking uv4l (from .../uv4l_1.9.5-1_armhf.deb) ...
Selecting previously unselected package uv4l-raspicam.
Unpacking uv4l-raspicam (from .../uv4l-raspicam_1.9.27_armhf.deb) ...
Processing triggers for man-db ...
Setting up uv4l (1.9.5-1) ...
Setting up uv4l-raspicam (1.9.27) ...

V4L2 장치활성화

$ uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --encoding jpeg --frame-time 0
 [core] Trying driver 'raspicam' from built-in drivers...
 [core] Driver 'raspicam' not found
 [core] Trying driver 'raspicam' from external plug-in's...
 [driver] Dual Raspicam Video4Linux2 Driver v1.9.27 built Feb 21 2015
 [driver] Selected format: 640x480, encoding: jpeg, JPEG Still Capture
 [driver] Framerate max. 30 fps
 [driver] ROI: 0, 0, 1, 1
 [core] Device detected!
 [core] Cannot create /dev/video0 because file already exists
 [core] Registering device node /dev/video1

사진촬영 테스트

$ dd if=/dev/video0 of=snapshot.jpeg bs=11M count=1
0+1 records in
0+1 records out
238909 bytes (239 kB) copied, 1.13632 s, 210 kB/s

Raspberry PI 부팅시 UV4L 드라이버가 로딩되게 하려면 추가 패키지를 설치 (옵션)

$ sudo apt-get install uv4l-raspicam-extras

Camera 사용하고 잇는 프로세스 중지

$ fuser /dev/video0
/dev/video0:          2593m
$ ps axl | grep 2593
0  1000  2593  2560  20   0 152888 64416 futex_ Sl+  pts/1      4:00 vlc
0  1000  2775  2604  20   0   5380  3008 pipe_w S+   pts/2      0:00 grep --color=auto 2593
$ kill -9 2593

Tomcat 설치

$ sudo wget http://mirror.apache-kr.org/tomcat/tomcat-7/v7.0.63/bin/apache-tomcat-7.0.63.tar.gz
$ sudo tar xvfz apache-tomcat-7.0.63.tar.gz

한글사용

라즈베리파이 기초강좌 : GUI 환경에서 한글 사용하기

$ sudo apt-get install ibus ibus-hangul ttf-unfonts-core

728x90
728x90

설치 확인

$ dpkg -l | grep transmission
ii  transmission-common                                   2.82-1.1ubuntu3.1                                   all          lightweight BitTorrent client (common files)
ii  transmission-gtk                                      2.82-1.1ubuntu3.1                                   amd64        lightweight BitTorrent client (GTK+ interface)

설치

$ sudo apt-get install transmission-daemon

환경 설정 (/etc/transmission-daemon/settings.json)

mycom - sudo vi /etc/transmission-daemon/settings.json

서비스가 종료된 경우만 수정 가능

IP filter 설정

"blocklist-enabled": true,
"blocklist-url": "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz"

외부 웹 접속 설정

"rpc-authentication-required": true, 
"rpc-url": "/transmission/", 
"rpc-username": "admin",
"rpc-enabled": true, 
"rpc-password": "admin12", 
"rpc-port": 9091, 
"rpc-whitelist": "127.0.0.1", 
"rpc-whitelist-enabled": false, 

최대 다운로드, 최대 업로드 관련 설정

"speed-limit-down-enabled": true 일 경우에만 speed-limit-down 가 적용
"speed-limit-up-enabled": true 일 경우에만 speed-limit-up 가 적용

"speed-limit-down": 100, 
"speed-limit-down-enabled": false, 
"speed-limit-up": 100, 
"speed-limit-up-enabled": false, 

다운로드 경로 설정

"download-dir": "/bluesanta/torrent/torrent.download", 
"incomplete-dir": "/bluesanta/torrent/torrent.temp", 
"incomplete-dir-enabled": true, 

자동 불러오기

"trash-original-torrent-files": true,
"watch-dir": "/bluesanta/torrent/torrent.auto", 
"watch-dir-enabled": true

서비스 시작

$ sudo service transmission-daemon start
transmission-daemon start/running, process 6479

서비스 종료

$ sudo service transmission-daemon stop
transmission-daemon stop/waiting


728x90

+ Recent posts