jeudi 25 août 2016

Streaming SONY CX900 video via ustream

Tech requirements

-Blackmagick Decklink Minirecorder or other acquisition card + software
-FFMPEG compiled with blackmagick support :

./configure --enable-decklink --enable-shared --extra-cflags="-I/usr/include/blackmagic" –enable-libx264 --enable-libvpx --enable-libvorbis --enable-gpl
put your camera on and connect it to the decklink card through the hdmi cable
verify your settings are ok with media express.
The you can launch the FFmpeg command

ffmpeg -thread_queue_size 4096 -f decklink -i 'DeckLink Mini Recorder@11' -vf scale=1280:720 -r 10 -f flv -an -vcodec libx264 -threads 4 -preset fast -b:v 700k -pix_fmt yuv420p -y rtmp://<your url...>/<Your key...>
your url and key are given in the brodcast settings of the your ustream dashboard

 
Here I use 10 frame/second to broadcast good image quality at a quite low bitrate. You can adjust your settings size bitrate etc... according to your specific needs and bandwidth
https://support.ustream.tv/hc/en-us/articles/207852117-Internet-connection-and-recommended-encoding-settings

To view the stream a link is provided by ustream when you created your tv channel.
You can watch whatever I try to stream here http://ustre.am/1xdhZ Septembre 10 between 20:00 and 23:00 Paris time.

vendredi 6 mars 2015

ffmpeg blackmagic

we assume the blackmagic module and SDK are properly installed

1-download the ffmpeg source from http://www.ffmpeg.org/download.html
2-configure for blackmagic and h264

./configure --enable-decklink --enable-shared \
--extra-cflags="-I/usr/include/blackmagic" \
–-extra-ldflags="-L/usr/include/blackmagic" \
--enable-libx264 –enable-gpl

make
sudo make install

export LD_LIBRARY_PATH=/usr/local/lib

To check the name of your device
ffmpeg -f decklink -list_devices 1 -i dummy


you  get something like
[decklink @ 0x260d3c0] Blackmagic DeckLink devices:
[decklink @ 0x260d3c0]     'DeckLink Mini Recorder'
Then

you can read and stream your camera e.g.

ffmpeg  -f decklink -i 'DeckLink Mini Recorder@11' -threads 4 -vcodec libx264  -preset ultrafast -pix_fmt yuv420p  -b 20000k  -tune zerolatency -an -f rtp rtp://10.10.0.2:1234/


There will be minimal latency (~1s in my case) using a wifi-n connection and rtp
as expected, udp gives more latency several seconds


https://www.ffmpeg.org/ffmpeg-devices.html#Examples-6


vendredi 5 septembre 2014

duplicate standard output

To duplicate std output of a program (here my_prog) in bash

./my_prog | tee logfile.txt

lundi 28 juillet 2014

Script to test if ethernet interface eth3 is up

#!/bin/bash
var="down"
while [[ $var != "up" ]]
do
    var=$(</sys/class/net/eth3/operstate )
    echo $var
done

mercredi 26 février 2014

Downloading big files from camera

On Mint downloading files from a camera using the gphoto2 automount and caja can be very slow on big files. An efficient alternative is to use gphotofs.

First create a directory for further mounting of the camera


sudo mkdir /media/mtp 
sudo chmod 777 -R /media/mtp

Then  unmount the device automatically mounted by gphoto2 and then you can mount your camera as follows

sudo gphotofs /media/mtp -o allow_other

To unmount

sudo fusermount -u /media/mtp

Then you can use a terminal and copy files, e.g.

cd /media/mtp/*
cp */*.MOV~/Images

This process is much faster than with caja

lundi 24 février 2014

swap blue and red

to exchange red and blue channel in an image file with imagemagick, I found this command

convert salle_test3.png -separate -swap 0,2 -set colorspace RGB -combine -set colorspace sRGB salle_test.png



The reason for specifying the colors pace is not clear to me. Not doing so however clearly changes the lightness of the image.

mercredi 19 février 2014

webcam libav

I tried to read from a webcam using the libav library or the ffmpeg equivalent, which are obviously not well documented w.r.t. this specific matter. I realized that the following call is required at the beginning of the program :

avdevice_register_all();

not to mention
av_register_all();

To install  ffmpeg and the corresponding original libraries  on Mint, the following tutorial works well:
http://trac.ffmpeg.org/wiki/UbuntuCompilationGuide

A working code example
https://github.com/j0sh/thesis/blob/master/capture.c