HOWTO+-+Use+FFMPEG+latest+versions+with+OpenMediaVault+to+transcode+audio-video

=Install FFMPEG Latest Static Build= To easily install the latest ffmpeg version (this is very important to avoid nasty bugs and improve the performance more than 100%) in OpenMediaVault without worrying about dependencies and additional repositories, download the latest static build here: http://ffmpeg.org/download.html#LinuxBuilds

At the time of writing I used this commands to download and extract: code format="bash" apt-get install bzip2; apt-get clean cd /root wget http://johnvansickle.com/ffmpeg/releases/ffmpeg-2.0.1-64bit-static.tar.bz2 tar xjvf ffmpeg-2.0.1-64bit-static.tar.bz2 ln -s ffmpeg-2.0.1-64bit-static ffmpeg code

=Example usage=

Convert audio from AAC to AC3
This is something you will need to achieve maximum compatibility with hardware players as stated in following ffmpeg wiki page https://trac.ffmpeg.org/wiki/GuidelinesHighQualityAudio: //When compatibility with hardware players does matter then use libmp3lame or ac3 in a MP4/MKV container rather than libfaac when libfdk_aac isn't available//

The compatibility issues is something I noticed myself as well.. My Samsung Smart TV cannot stream synced video/audio content, when audio is encoded using the AAC format)

The following movie contains 1 video track, 1 audio (AAC) track and 1 subtitle track code format="bash" ffprobe version 2.0.1 Copyright (c) 2007-2013 the FFmpeg developers built on Sep 24 2013 05:31:18 with gcc 4.8 (Debian 4.8.1-10) configuration: --extra-cflags=-I../static/include --extra-ldflags='-L../static/lib -static' --enable-gpl --enable-version3 --enable-static --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --disable-ffserver libavutil     52. 38.100 / 52. 38.100 libavcodec     55. 18.102 / 55. 18.102 libavformat    55. 12.100 / 55. 12.100 libavdevice    55. 3.100 / 55. 3.100  libavfilter     3. 79.101 / 3. 79.101  libswscale      2. 3.100 / 2.  3.100  libswresample   0. 17.102 / 0. 17.102  libpostproc    52. 3.100 / 52. 3.100 Input #0, matroska,webm, from 'TLOTR The Two Towers (2002) - 1080p.mkv': Metadata: creation_time  : 2011-07-12 17:47:16 Duration: 03:55:27.82, start: 0.000000, bitrate: 4801 kb/s Stream #0:0(eng): Video: h264 (High), yuv420p, 1906x798, SAR 1:1 DAR 953:399, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Stream #0:1(eng): Audio: aac, 48000 Hz, 5.1, fltp (default) Stream #0:2(eng): Subtitle: subrip (default) code
 * 1) /root/ffmpeg/ffprobe TLOTR\ The\ Two\ Towers\ \(2002\)\ -\ 1080p.mkv

With the following command ffmpeg transcodes the audio tracks to AC3 448kbps 48000Hz and copies the video and subtitle tracks intact to the output mkv. code format="bash" ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 24 2013 05:31:18 with gcc 4.8 (Debian 4.8.1-10) configuration: --extra-cflags=-I../static/include --extra-ldflags='-L../static/lib -static' --enable-gpl --enable-version3 --enable-static --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --disable-ffserver libavutil     52. 38.100 / 52. 38.100 libavcodec     55. 18.102 / 55. 18.102 libavformat    55. 12.100 / 55. 12.100 libavdevice    55. 3.100 / 55. 3.100  libavfilter     3. 79.101 / 3. 79.101  libswscale      2. 3.100 / 2.  3.100  libswresample   0. 17.102 / 0. 17.102  libpostproc    52. 3.100 / 52. 3.100 Input #0, matroska,webm, from 'TLOTR The Two Towers (2002) - 1080p.mkv': Metadata: creation_time  : 2011-07-12 17:47:16 Duration: 03:55:27.82, start: 0.000000, bitrate: 4801 kb/s Stream #0:0(eng): Video: h264 (High), yuv420p, 1906x798, SAR 1:1 DAR 953:399, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Stream #0:1(eng): Audio: aac, 48000 Hz, 5.1, fltp (default) Stream #0:2(eng): Subtitle: subrip (default) File 'TLOTR The Two Towers (2002) - 1080p-ac3.mkv' already exists. Overwrite ? [y/N] y Output #0, matroska, to 'TLOTR The Two Towers (2002) - 1080p-ac3.mkv': Metadata: encoder        : Lavf55.12.100 Stream #0:0(eng): Video: h264 (H264 / 0x34363248), yuv420p, 1906x798 [SAR 1:1 DAR 953:399], q=2-31, 23.98 fps, 1k tbn, 1k tbc (default) Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1, fltp, 448 kb/s (default) Stream #0:2(eng): Subtitle: subrip (default) Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (aac -> ac3) Stream #0:2 -> #0:2 (copy) Press [q] to stop, [?] for help frame=338638 fps=1672 q=-1.0 Lsize= 8507593kB time=03:55:25.82 bitrate=4933.8kbits/s video:7729376kB audio:772460kB subtitle:60 global headers:0kB muxing overhead 0.067002% code
 * 1) /root/ffmpeg/ffmpeg -i TLOTR\ The\ Two\ Towers\ \(2002\)\ -\ 1080p.mkv -c:v copy -c:a ac3 -b:a:0 448k -r:a:0 48000 -c:s copy TLOTR\ The\ Two\ Towers\ \(2002\)\ -\ 1080p-ac3.mkv

Removing Streams from MKV
The following movie contains Russian audio and subtitles which is not needed and simply consumes more space

code format="bash" ffprobe Serpico.1973.Blu-Ray.x264.1080p.Japhson.Rus.Eng.mkv FFprobe version SVN-r92, Copyright (c) 2007-2009 Stefano Sabatini libavutil    49.15. 0 / 49.15. 0 libavcodec    52.20. 0 / 52.20. 1 libavformat   52.31. 0 / 52.31. 0 built on Jan 30 2010 11:08:30, gcc: 4.4.3 Input #0, matroska, from 'Serpico.1973.Blu-Ray.x264.1080p.Japhson.Rus.Eng.mkv': Duration: 02:10:06.84, start: 0.000000, bitrate: N/A Stream #0.0(eng): Video: h264, yuv420p, 1920x1040, PAR 1:1 DAR 24:13, 23.98 tbr, 1k tbn, 47.95 tbc Stream #0.1(rus): Audio: ac3, 48000 Hz, 5.1, s16 Stream #0.2(eng): Audio: dca, 48000 Hz, stereo, s16 Stream #0.3(rus): Subtitle: 0x0000 Stream #0.4(eng): Subtitle: 0x0000 code

To remove it, select only the English streams and create a new mkv file with the following command:

code format="bash" ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 24 2013 05:31:18 with gcc 4.8 (Debian 4.8.1-10) configuration: --extra-cflags=-I../static/include --extra-ldflags='-L../static/lib -static' --enable-gpl --enable-version3 --enable-static --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --disable-ffserver libavutil     52. 38.100 / 52. 38.100 libavcodec     55. 18.102 / 55. 18.102 libavformat    55. 12.100 / 55. 12.100 libavdevice    55. 3.100 / 55. 3.100  libavfilter     3. 79.101 / 3. 79.101  libswscale      2. 3.100 / 2.  3.100  libswresample   0. 17.102 / 0. 17.102  libpostproc    52. 3.100 / 52. 3.100 Input #0, matroska,webm, from 'Serpico.1973.Blu-Ray.x264.1080p.Japhson.Rus.Eng.mkv': Metadata: creation_time  : 2010-05-17 00:14:10 Duration: 02:10:06.84, start: 0.000000, bitrate: 10070 kb/s Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) (forced) Stream #0:1(rus): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default) (forced) Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, stereo, fltp, 1536 kb/s Stream #0:3(rus): Subtitle: subrip (default) (forced) Stream #0:4(eng): Subtitle: subrip Output #0, matroska, to 'Serpico.1973.Blu-Ray.x264.1080p.Japhson.Eng.mkv': Metadata: encoder        : Lavf55.12.100 Stream #0:0(eng): Video: h264 (H264 / 0x34363248), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], q=2-31, 23.98 fps, 1k tbn, 1k tbc (default) (forced) Stream #0:1(eng): Audio: dts ([1] [0][0] / 0x2001), 48000 Hz, stereo, 1536 kb/s Stream #0:2(eng): Subtitle: subrip Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:2 -> #0:1 (copy) Stream #0:4 -> #0:2 (copy) code
 * 1) /root/ffmpeg/ffmpeg -i Serpico.1973.Blu-Ray.x264.1080p.Japhson.Rus.Eng.mkv -map 0:0 -map 0:2 -map 0:4 -c:v copy -c:a copy -c:s copy Serpico.1973.Blu-Ray.x264.1080p.Japhson.Eng.mkv

code format="bash" FFprobe version SVN-r92, Copyright (c) 2007-2009 Stefano Sabatini libavutil    49.15. 0 / 49.15. 0 libavcodec    52.20. 0 / 52.20. 1 libavformat   52.31. 0 / 52.31. 0 built on Jan 30 2010 11:08:30, gcc: 4.4.3 Input #0, matroska, from 'Serpico.1973.Blu-Ray.x264.1080p.Japhson.Eng.mkv': Duration: 02:10:06.92, start: 0.000000, bitrate: N/A Stream #0.0(eng): Video: h264, yuv420p, 1920x1040, PAR 1:1 DAR 24:13, 23.98 tbr, 1k tbn, 47.95 tbc Stream #0.1(eng): Audio: dca, 48000 Hz, stereo, s16 Stream #0.2(eng): Subtitle: 0x0000 Unsupported codec (id=94210) for input stream 2 code
 * 1) ffprobe Serpico.1973.Blu-Ray.x264.1080p.Japhson.Eng.mkv

Read more in the following links if you need to handle more audio/subtitle tracks: https://trac.ffmpeg.org/wiki/How%20to%20use%20-map%20option http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options