Streaming audio from Ubuntu Linux to a DLNA player without Rygel

Recently, I became the proud owner of Onkyo TX-NR515 receiver. This device is DLNA MediaRenderer as upnp-inspector says. The A/V receiver is from the 2012 devices family (TX-NR414/TX-NR515/TX-NR616).

Streaming the sound from PC to my DLNA device over wlan was a tough task, but I managed to solve it the way I’ll describe below. The main idea is to pass the alsa/pulseaudio output stream over LAN to DLNA device. There are 2 ways of doing it: with DLNA server or without.

Continue reading

Convert Video to HTML5 in Ubuntu

I wanted an easy way to convert videos to HTML5 formats (mp4/ogg/webm). With Linux, I could easily create a bash script to do all three and even create a screencap for the poster attribute.

The install process is a bit tedious and time consuming, but after it’s all installed you’re good to run the script for all your videos. The script uses ffmpeg to convert to all 3 formats, and it supports most any video format. The script also uses ffmpeg to generate a random screenshot, and even writes the HTML5 code for you.


For the most part, this portion of the tutorial was derived from the Ubuntu Forums.

  1. Uninstall Old Versions
  2. sudo apt-get remove ffmpeg x264 libx264-dev yasm
  3. Install Dependencies and Install Tools
  4. sudo apt-get update
    sudo apt-get install build-essential git-core checkinstall texi2html libfaac-dev \
        libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev \
        libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev
  5. Install Yasm
  6. cd ~/Downloads
    tar xzvf yasm-1.2.0.tar.gz
    cd yasm-1.2.0
    sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no --deldoc=yes --default
  7. Install x264
  8. cd ~/Downloads
    git clone git://
    cd x264
    ./configure --enable-static
    sudo mkdir /usr/local/lib/pkgconfig
    sudo checkinstall --pkgname=x264 --default --pkgversion="3:$(./ | \
        awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes
  9. Install LAME
  10. sudo apt-get remove libmp3lame-dev
    sudo apt-get install nasm
    cd ~/Downloads
    tar xzvf lame-3.99.tar.gz
    cd lame-3.99
    ./configure --enable-nasm --disable-shared
    sudo mkdir /usr/local/share/doc
    sudo mkdir /usr/local/share/doc/lame
    sudo checkinstall --pkgname=lame-ffmpeg --pkgversion="3.99" --backup=no --default \
  11. Install libvpx
  12. cd ~/Downloads
    git clone
    cd libvpx
    sudo checkinstall --pkgname=libvpx --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
        --default --deldoc=yes
  13. Install ffmpeg
  14. cd ~/Downloads
    git clone --depth 1 git://
    cd ffmpeg
    ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
        --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx \
        --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
    sudo checkinstall --pkgname=ffmpeg --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
        --deldoc=yes --default

    The part that will take the longest is the ffmpeg, so be prepared to wait.

    The Script


    ./convertHTML5 video-file.ext

    The script will output “video-file.ogv”, “video-file.webm”, “video-file.mp4″, and “video-file.html” while keeping the original video intact. The HTML document just has the plain <video> code with nothing else, easily copied and pasted.

    if [[ $1 ]]
        filename=$(basename "$1")
        directory=$(dirname "$1")
        duration=$(ffmpeg -i "$1" 2>&1 | grep Duration | awk '{print $2}' | tr -d ,)
        total=$(expr $hours + $minutes + $seconds)
        let "number %= $total"
        echo "Generating thumbnail"
        ffmpeg -i "$1" -deinterlace -an -ss $number -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg "$directory/$filename.jpg" 2>&1
        echo "Converting $filename to ogv"
        ffmpeg -i "$1" -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k "$directory/$filename.ogv"
        echo "Finished ogv"
        echo "Converting $filename to webm"
        ffmpeg -i "$1" -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k "$directory/$filename.webm"
        echo "Finished webm"
        echo "Converting $filename to h264"
        ffmpeg -i "$1" -acodec libfaac -ab 96k -vcodec libx264 -level 21 -refs 2 -b 345k -bt 345k -threads 0 "$directory/$filename.mp4"
        echo "Finished h264"
        echo "Writing HTML..."
        echo "</pre>
    <video width="320" height="240" controls="controls" poster="\&quot;$filename.jpg\&quot;" preload=""><source src="\&quot;$filename.ogv\&quot;" type="\&quot;video/ogg\&quot;" /><source src="\&quot;$filename.webm\&quot;" type="\&quot;video/webm\&quot;" /><source src="\&quot;$filename.mp4\&quot;" type="\&quot;video/mp4\&quot;" />" > "$directory/$filename.html"
     echo " " >> "$directory/$filename.html"
     echo " " >> "$directory/$filename.html"
     echo " " >> "$directory/$filename.html"
     echo " Sorry, your browser does not support HTML5 video" >> "$directory/$filename.html"
     echo "</video>
    <pre>" >> "$directory/$filename.html"
        echo "All Done!"
        echo "Usage: [filename]"

    Credits: McSwindler

FFmpeg: Объединение нескольких avi файлов

Некоторые мультимедиа контейнеры (MPEG-1, MPEG-2 PS, DV) позволяют объединять несколько видеофайлов обыкновенной конкатенацией.

Таким образом, объединить мультимедиа файлы можно с помощью первичного транскодирования видео в привеллигированные форматы, затем используя команду cat (или copy в Windows) и конечного транскодирования видеоматериалов в любой формат на ваш выбор.

ffmpeg -i input1.avi -sameq intermediate1.mpg
ffmpeg -i input2.avi -sameq intermediate2.mpg
cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg
ffmpeg -i intermediate_all.mpg -sameq output.avi

Команда -sameq позволяет сохранять битрейт в процессе обработки для исключения деградации качества видео.

Также, использование pipes в вашей операционной системе позволяет избежать создание промежуточных файлов:

mkfifo intermediate1.mpg
mkfifo intermediate2.mpg
ffmpeg -i input1.avi -sameq -y intermediate1.mpg < /dev/null &
ffmpeg -i input2.avi -sameq -y intermediate2.mpg < /dev/null &
cat intermediate1.mpg intermediate2.mpg |\
ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame output.avi

Источник: FAQ по FFmpeg