Actions

Ffmpeg notes

From /oooooooooo.io/


FFMPEG

Encoding For Raspberry Pi

https://raspberrypi.stackexchange.com/questions/3471/omxplayer-h-264-bitrates-and-encoding-settings-for-stutter-free-playback

mosaic

Following https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos

For 2 videos, side by side.

ffmpeg -i left.mp4 -i right.mp4 -filter_complex " \
nullsrc=size=3840x1080 [base];\
[0:v] setpts=PTS-STARTPTS, scale=1920x1080 [left]; \
[1:v] setpts=PTS-STARTPTS, scale=1920x1080 [right]; \
[base][left] overlay=shortest=1 [tmp1]; \
[tmp1][right] overlay=shortest=1:x=1920" -c:v libx264 mosaic.mp4


screenshots

key: s and

-vf screenshot 

FFMPEG encoding examples

Screen cast to .webm

Using x11grab to video grab your display and using ALSA for sound. First we create lossless raw file Template:Ic.

$ ffmpeg -f x11grab -r 30 -i :0.0 -f alsa -i hw:0,0 -acodec flac -vcodec ffvhuff test.mkv


Then we process this Template:Ic file into a smaller Template:Ic end product. Complex switches like Template:Ic and Template:Ic convert the stream into what's needed for WebM.

$ ffmpeg -y -i test.mkv -c:a libvorbis -q:a 3 -c:v libvpx -b:v 2000k test.webm

See https://github.com/kaihendry/recordmydesktop2.0/ for a more fleshed out example.

Recording webcam

FFmpeg supports grabbing input from Video4Linux2 devices. The following command will record a video from the webcam, assuming that the webcam is correctly recognized under Template:Ic:

$ ffmpeg -f v4l2 -s 640x480 -i /dev/video0 output.mpg

The above produces a silent video. It is also possible to include audio sources from a microphone. The following command will include a stream from the default ALSA recording device into the video:

$ ffmpeg -f alsa -i default -f v4l2 -s 640x480 -i /dev/video0 output.mpg


VOB to any container

Concatenate the desired VOB files into a single VOB file:

$ cat video-1.VOB video-2.VOB video-3.VOB > output.VOB

Concatenate and then pipe the output VOB to FFmpeg to use a different format:

$ cat video-1.VOB video-2.VOB video-3.VOB > output.VOB | ffmpeg -i ...

x264 lossless

The ultrafast preset will provide the fastest encoding and is useful for quick capturing (such as screencasting):

$ ffmpeg -i input -vcodec libx264 -preset ultrafast -qp 0 -acodec copy output.mkv

On the opposite end of the preset spectrum is veryslow and will encode slower than ultrafast but provide a smaller output file size:

$ ffmpeg -i input -vcodec libx264 -preset veryslow -qp 0 -acodec copy output.mkv

Both examples will provide the same quality output.

Single-pass MPEG-2 (near lossless)

Allow FFmpeg to automatically set DVD standardized parameters. Encode to DVD MPEG-2 at a frame rate of 30 frames/second:

$ ffmpeg -i video.VOB -target ntsc-dvd -q:a 0 -q:v 0 output.mpg

Encode to DVD MPEG-2 at a frame rate of 24 frames/second:

$ ffmpeg -i video.VOB -target film-dvd -q:a 0 -q:v 0 output.mpg

Volume gain

Change the audio volume in multiples of 256 where 256 = 100% (normal) volume. Additional values such as 400 are also valid options.

-vol 256  = 100%
-vol 512  = 200%
-vol 768  = 300%
-vol 1024 = 400%
-vol 2048 = 800%

To double the volume (512 = 200%) of an MP3 file:

$ ffmpeg -i file.mp3 -vol 512 louder file.mp3

To quadruple the volume (1024 = 400%) of an Ogg file:

$ ffmpeg -i file.ogg -vol 1024 louder file.ogg

Note that gain metadata is only written to the output file. Unlike mp3gain or ogggain, the source sound file is untouched.



video codec /ffmpeg resources

http://ffmpeg.org/

https://www.virag.si/2012/01/web-video-encoding-tutorial-with-ffmpeg-0-9/

trnascode audio to aac

ffmpeg -i test_4chan_2.wav -acodec libfdk_aac -b:a 384k test_4chan_2.mkv

bit rates: for multichannel: 384k; for setero: 128k

encoders: libfdk_aac (the highest quality), libfaac

commor containers: m4a (mp4 for audio), mkv

https://trac.ffmpeg.org/wiki/AACEncodingGuide

burn subtitles

ffmpeg -i video.avi -vf "ass=subtitle.ass" out.avi

generate video w/ color

ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv

trim video

ffmpeg -i video.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:00:04 trimmed_video.avi

will start at 00:00:00 and last until 00:00:04

extract audio only

-vn - video no

ffmpeg -i input.ogv -vn audio-out.ogg


extract video only

-an - audio no

ffmpeg -i input.ogv -an video-out.ogv

no subtitetles

-sn - subtutiles no

ffmpeg -i file.mkv -map 0 -sn file.m4v


join audio and video

ffmpeg -i audio.wav -i video.mp4 -acodec copy -vcodec copy output.mp4

convert to webm

quick and dirty

ffmpeg -i input.mp4 -acodec libvorbis -vcode libvpx -f webm output.webm

convert to ogv

ffmpeg -i input.mp4 -acodec libvorbis -vcodec libtheora -f ogv output.ogv


ffmpeg -i infile.mov -acodec libvorbis -ac 1 -b:a 96k -ar 44100 -vcodec libtheora -b:v 1000k -s 640x360 -g 30 out-file.ogv


¿What is the best video bit rate for web??

convert to mp4

ffmpeg -i out-file.mov -acodec libmp3lame -b:a 96k -ar 44100 -ac 1 -vcodec libx264 -b:v 250k -s 640x360 out-file.mp4


vpre

-vpre = video preset
-vpre slower -vpre main  ??

The preset files are stored in different places, depending on what OS you have. If you search your computer for: libx264-slow_firstpass.ffpreset you can hopefully find the folder with them in.

You need to create a separate preset file for the codec you're trying to use. http://www.ffmpeg.org/ffmpeg-doc.html#SEC13


using -vpre ipod640 ipod preset

ffmpeg -i video_source_file.ext -vcodec libx264 -vpre hq -vpre ipod640 -b:v 250k -bt 50k -acodec libfaac -b:a 56k -ac 2 -s 480x320 video_out_file.mp4


Examples

https://wiki.archlinux.org/index.php/FFmpeg http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

enconde for web EXAMPLES

For mp4 (H.264 / ACC):

ffmpeg -i INPUTFILE -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 "OUTPUTFILE.mp4" For webm (VP8 / Vorbis):

ffmpeg -i "INPUTFILE" -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 "OUTPUTFILE.webm" For ogv (Theora / Vorbis):

ffmpeg -i "INPUTFILE" -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 "OUTPUTFILE.ogv"

video w/ 4 audio channels

   mkv - matroska
   acc audio codec w/ high bit rate encoder
   + generorous cache space
   power saving  - off: smartctl - change smart attributes
   screen saver off

test

created 4chan wav

ecasound can play it

ecasound -f 16,4,44100 -i 4chn.wav -o jack

but mplayer not yet http://www.mplayerhq.hu/DOCS/HTML/en/advaudio-channels.html

encoders

  • aac - libfaac


mplayer

some tricks and treats

-osdlevel=0 

disables all the visual elements like progress bars, etc


Technical aspects(bit rates, sizes,etc)

bit rates

http://www.ezs3.com/public/What_bitrate_should_I_use_when_encoding_my_video_How_do_I_optimize_my_video_for_the_web.cfm

Output size Bitrate Filesize
320x240 pixels 400 kbps 3MB / minute
480x270 pixels 700 kbps 5MB / minute
1024 x 576 pixels 1500 kbps 11MB / minute
1280x720 pixels 2500 kbps 19MB / minute
1920x1080 pixels 4000 kbps 30MB / minute

Standard web video pixel dimensions

http://phildawson.tumblr.com/post/44238901/standard-web-video-pixel-dimensions


16:9 4:3
1920 x 1080 (1080p) -
1280 x 720 (720p) -
960 x 540 (540p) -
720 x 405 -
640 x 360 640 x 480
560 x 315 560 x 420
480 x 270 480 x 360
400 x 225 400 x 300
320 x 180 320 x 240
240 x 135 240 x 180
160 x 90 160 x 120
- 120 x 90
- 100 x 75
80 x 45 80 x 60
- 60 x 45


... more about "Ffmpeg notes"
Code_Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2021 +