Agenda
https://www.nginx.com/wp-content/uploads/2018/12/NGINX-Conf-2018-slides_Choi-streaming.pdf
– Introduction to streaming
– Turn NGINX into a streaming server
– HLS/DASH VOD by NGINX – How?
– Supporting HLS 7
– Encrypting HLS
– High-bitrate streaming (4K/8K UHD) by NGINX
– Low-latency live by NGINX
Tag Archives: ffmpeg
ffmpeg – file name too long
-filter_complex “[1]lut=a=val*0.5[a];[0][a]overlay=main_w-overlay_w-10:main_h-overlay_h-10“ -codec:v libx264 -r 29 -pix_fmt yuv420p -profile:v baseline -level 3 -b:v 3500k -s 320×240 -codec:a aac -strict experimental -ac 2 -b:a 64k
A few videos were being stucked on queue list… and I wasn’t finding the problem.
Looks like ffmpeg acts a little weird with “.
I’v replaced the ” with ‘ and the problem was fixed.
ffmpeg, convert to mp4, ogv and webm
ffmpeg -i source_path/movie.mpg -c:v libx264 -vsync 2 -strict -2 dest_path/movie.mp4
ffmpeg -i source_path/movie.mpg -vcodec libtheora -q:v 10 -codec:a libvorbis -q:a 5 -vsync 2 -threads 0 dest_path/movie.ogv
ffmpeg -i source_/movie.mpg -acodec libvorbis -aq 5 -ac 2 -qmax 25 -threads 2 dest_path/movie.webm
MPEG-DASH – Dynamic Adaptive Streaming over HTTP
Some references to MPEG-DASH.
Dynamic Adaptive Streaming over HTTP (DASH), also known as MPEG-DASH
In Wikipédia
MPEG-DASH — technology of the new generation, allow to broadcast the adaptive video stream. The data broke into fragments and are transfer to the client on the protocol of HTTP. It allowed to transfer reliably video through exist HTTP инфрастуктуру, to overcome the proxy server, and also without serious consequences to transfer problems with a network, changes of network addresses itd.
DASH — Dynamic Adaptive Streaming over HTTP. The standard of DASH ISO/IEC 23009-1:2012 were develop by group of MPEG in 2011The technology of MPEG-DASH as a whole are similarto other known technology of HLS (HTTP Live Streaming) which is develop by the company of Apple and widely us on mobile devices with iOS and Android. The flow are present in the form of small fragments on duration and the playlist (manifesto) contain meta data of a flow and the reference to fragments.
In MPEG-DASH in nginx-rtmp-module: live video in the browser without flesh
Some links
Install FFMPEG on Centos / CPanel FFmpeg Static Builds
Download the latest FFmpeg Static Builds from http://johnvansickle.com/ffmpeg/.
How to know if we need to download the 32 or 64 bits?
Lets run:
cat /etc/*release*
CentOS release 6.6 (Final) LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Or using uname (more reliable)
uname -m
I’v download it do a specific folder
wget http://johnvansickle.com/ffmpeg/builds/ffmpeg-git-64bit-static.tar.xz
And the run the following command to uncompress it:
tar xf ffmpeg-git-64bit-static.tar.xz
To run ffmpeg or ffprobe we need to give the full path to them!
It worked!
With the lastest versions!
FFMPEG & FFPROBE
ROCK!
SOME PROBLEMS ON OLD MACHINES
-bash-3.2$ tar -xf ffmpeg-git-64bit-static.tar.xz tar: This does not look like a tar archive tar: Skipping to next header tar: Archive contains obsolescent base-64 headers tar: Read 5668 bytes from ffmpeg-git-64bit-static.tar.xz tar: Error exit delayed from previous errors
tar version (fuckz!)
tar (GNU tar) 1.15.1
Well, this machine, where I got this error, is a managed server…
I didn’t bored to ask support to upgrade TAR or install XZ… but if you want, you can install XZ and then…
xz -d archive.tar.xz tar xvf archive.tar
It might work! 🙂
Btw! On old machines kernel might not be compatible…
ffmpeg – watermark positions
This are the command lines that I use to add the watermark picture named watermark.png on the video named source.avi and export to output.flv.
Tested on a DigitalOcean Virtual server! 😉
The 10 values are the paddings!
Top left
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:10 [out]" output.flv
Top right
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" output.flv
Bottom left
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" output.flv
Bottom right
ffmpeg –i source.avi -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" output.flv
Center?
ffmpeg –i source.avi -vf “movie=watermark.png [watermark]; [in][watermark] overlay=main_w/2-overlay_w/2:main_h/2-overlay_h/2 [out]” output.flv
UPDATE
If you get this error…
[NULL @ 0x45fd680] Unable to find a suitable output format for '–i' –i: Invalid argument
try something like…
ffmpeg -i 'video-source.mp4' -i /watermark/path/image.png -filter_complex "overlay=main_w-overlay_w-10:main_h-overlay_h-10" -c:v libx264 -vsync 2 -strict -2 /output/video.mp4
ffmpeg image thumbnail every minute, seconds… the math!
This will create one thumbnail image every minute, named img001.jpg, img002.jpg, img003.jpg, … (%03d means that ordinal number of each thumbnail image should be formatted using 3 digits)
ffmpeg -i myvideo.avi -f image2 -vf fps=fps=1/60 img%03d.jpgThis will create one thumbnail image every 10 minutes, named thumb0001.bmp, thumb0002.bmp, thumb0003.bmp, …
ffmpeg -i test.flv -f image2 -vf fps=fps=1/600 thumb%04d.bmpThis will create one thumbnail image every I-frame, named thumb0001.bmp, thumb0002.bmp, thumb0003.bmp, …
https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
So, we can use some logical/math to make some conclusions…
1/60 stands for 1 thumb at each 60 seconds, the same as say each minute…
1/600 stands for 1 thumb at each 60 seconds * 10, the same as say each 10 minutes…
if we want a thumb at each 2 minutes we should multiply the 60 per 2, that will gives us 1/120… this way we can also assume that if we want a thumb at each 4 seconds, we can use 1/4.
Useful link
https://trac.ffmpeg.org/wiki/Create%20a%20thumbnail%20image%20every%20X%20seconds%20of%20the%20video
pre-configurated of output dimensions on ffmpeg
Some pre-configurations of output dimensions on ffmpeg.
ffmpeg -i source.ext -r 1 -s 4cif -f image2 img%5d.jpg
This will produce you pictures with 704 width * 576 height
sqcif | 128×96 | qcif | 176×144 | cif | 352×288 |
4cif | 704×576 | qqvga | 160×120 | qvga | 320×240 |
vga | 640×480 | svga | 800×600 | xga | 1024×768 |
uxga | 1600×1200 | qxga | 2048×1536 | sxga | 1280×1024 |
qsxga | 2560×2048 | hsxga | 5120×4096 | wvga | 852×480 |
wxga | 1366×768 | wsxga | 1600×1024 | wuxga | 1920×1200 |
woxga | 2560×1600 | wqsxga | 3200×2048 | wquxga | 3840×2400 |
whsxga | 6400×4096 | whuxga | 7680×4800 | cga | 320×200 |
hd480 | 852×480 | hd720 | 1280×720 | hd1080 | 1920×1080 |
ffmpeg 2.0
I’m having problems with avconv, especially exporting the video properties to json…
“Failed to set value ‘json’ for option”
I was able to create json files with ffmpeg, but since ubuntu uses avconv and ffmpeg is an aliase of avconv… i’m not able to create json files…. be struggling with it for 4 days.
This is how I’v installed FFMPEG 2.0 on my Ubuntu 13.
$ wget -c www.ffmpeg.org/releases/ffmpeg-2.0.tar.gz $ tar -xzvf ffmpeg-2.0.tar.gz $ cd ffmpeg-2.0 $ ./configure $ make $ sudo make install
If you start to have problems while trying to run ./configure…
apt-get install gcc
You will probably also need to install make
root@digitalwhores:/home/ffmpeg/ffmpeg-2.0# make The program 'make' is currently not installed. You can install it by typing: apt-get install make root@digitalwhores:/home/ffmpeg/ffmpeg-2.0# apt-get install make
An them go to ./configure from the initial instructions…
sudo ./configure --disable-yasm
make
FFMPEG 2.0
root@digitalwhores:/home/ffmpeg/ffmpeg-2.0# ./ffmpeg ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers built on Sep 22 2013 10:23:36 with gcc 4.7 (Ubuntu/Linaro 4.7.3-1ubuntu1)
And now! remove the old ffmpeg/avconv!
Hasta la vista!
sudo apt-get remove ffmpeg
sudo apt-get autoremove
ffmpeg-2.0/tests/ref/fate/ffprobe_json
Unknown encoder ‘libx264’
On my stack, on digitalocean, i have Ubuntu (13, and i’m deploying a small work that need avconv (former ffmpeg).
I need to convert from WMV to MP4 files and i was getting Unknown encoder ‘libx264’ error.
This is how i’v added video encoder libx264 to my avcodec.
apt-get update apt-get install libavcodec-extra-53
Tested on
Ubuntu 13.04 (GNU/Linux 3.8.0-19-generic x86_64)
Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-29-generic x86_64)
Tried to share it!
http://stackoverflow.com/questions/11234662/how-to-compile-avconv-with-libx264-on-ubuntu-12-04/18835133#18835133