FFmpeg
Sissejuhatus
- THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Tuleb..
Kasutamine
Süntaks
ffmpeg input_filename.mpg -ovc codec for video output -oac codec for audio output -o output_filename.avi
ffmpegi toetatud formaate saab vaadata käsurealt, vastavalt:
$ ffmpeg -codecs $ ffmpeg -formats
Videokohta infot saab
$ ffmpeg -i video.avi
Muudame aktiivses kataloogis olevad jpg failid mpg failiks. Selleks nimetame oma pildifailid sobilikule kujule:
# x=1; for i in *jpg; do counter=$(printf %03d $x); ln "$i" img"$counter".jpg; x=$(($x+1)); done
Teeme konvertimise
# ffmpeg -qscale 5 -r 20 -b 9600 -i img%03d.jpg /tmp/a2.mpg
Lammutame vastupidi videofaili jpg failideks
$ ffmpeg -i video.mpg image%d.jpg
(This will create 25 images for every 1 second, but it may serve us to have more or less images, this can be achieved with the parameter -r, -r fps Set frame rate [default 25])
Liidame 2 mpg faili kokku
# cat 2012-08-02/a3.mpg 2012-08-03/a4.mpg > a1_all.mpg
Eemaldame videost heli ja salvestame mp3 formaati
$ ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
Pakime avi faili divx koodekiga
$ ffmpeg -i source_video.avi -s 320x240 -vcodec msmpeg4v2 final_video.avi
Konverdime avi faili mpg formaati
$ ffmpeg -i video_origine.avi video_finale.mpg
Konverdime avi faili dvd mängijatele sobivaks mpeg failiks
$ ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg
Ffmpeg suudab salvestada X11 pilti
$ ffmpeg -f x11grab -r 24 -s cif -i :0.0 /tmp/out.mpg
0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.
Kopeeri ainult lõik vieost
$ ffmpeg -vcodec copy -acodec copy -i orginalfile -ss 00:01:30 -t 0:0:20 newfile
Salvesta lõik veebikaamerast
$ ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
Nii heli kui video salvestamiseks
$ ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -i /dev/video0 out.mpg
Soovides DVD vaile backupida kettale varuks
fmpeg -i sisendfail.vob -vcodec libx264 -preset veryfast -tune film -crf 18 \ -acodec ac3 -ab 256k -sn -threads 0 Valjundfail.crf18.mkv
Kodeerime tihendamata kõrgkvaliteedilise video kokku x264 formaati ffmpeg abil
$ ffmpeg -i algfail -vf "crop=1920:816, scale=1280:544" -vcodec libx264 -preset veryfast -tune film -crf 18 \ -acodec ac3 -ab 256k -sn -threads 0 Videofail.crf18.mkv
lõppfailiks Videofail.crf18.mkv
Crop ja scale tuleb iga konkreetse video puhul järgi vaadata. Kui mustad ääred ei häiri siis lihtsalt -vf "scale=1280:720"
Audio 5 kanaliga saamiseks muuta parameetrit -ab 448k
-benchmark perform faster than realtime --crf 20 to enable constant quality mode, --threads auto enables parallel encoding --output output.264 outputs the raw h264/avc bytestream to output.264 (this is the encoded video), -2>x264.log sends the terminal output from x264 to x264.log (you can open another terminal and monitor x264's progress with tail -f x264.log).
One-pass CRF (Constant Rate Factor) using the slow preset. One-pass CRF is good for general encoding and is what I use most often. Adjust -crf to change the quality. Lower numbers mean higher quality and a larger output file size. A sane range is 18 to 28 For more info see x264 --fullhelp | less and man mplayer.
FFmpeg server
Eesmärk, jagada veebikaamera streami võrku
Avame selleks faili ffserver.conf (nt Linuxis /etc/ffserver.conf)
Ja kirjutame sinna järgneva info
Port 8090
# bind to all IPs aliased or not
BindAddress 0.0.0.0
# max number of simultaneous clients
MaxClients 1000
# max bandwidth per-client (kb/s)
MaxBandwidth 10000
# Suppress that if you want to launch ffserver as a daemon.
# NoDaemon
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 5M
</Feed>
# FLV output - good for streaming
<Stream test.flv>
# the source feed
Feed feed1.ffm
# the output stream format - FLV = FLash Video
Format flv
VideoCodec flv
# this must match the ffmpeg -r argument
VideoFrameRate 15
# generally leave this is a large number
VideoBufferSize 80000
# another quality tweak
VideoBitRate 200
# quality ranges - 1-31 (1 = best, 31 = worst)
VideoQMin 1
VideoQMax 5
VideoSize 352x288
# this sets how many seconds in past to start
PreRoll 0
# wecams don't have audio
Noaudio
</Stream>
# ASF output - for windows media player
<Stream test.asf>
# the source feed
Feed feed1.ffm
# the output stream format - ASF
Format asf
VideoCodec msmpeg4
# this must match the ffmpeg -r argument
VideoFrameRate 15
# generally leave this is a large number
VideoBufferSize 80000
# another quality tweak
VideoBitRate 200
# quality ranges - 1-31 (1 = best, 31 = worst)
VideoQMin 1
VideoQMax 5
VideoSize 352x288
# this sets how many seconds in past to start
PreRoll 0
# wecams don't have audio
Noaudio
</Stream>
Stardime tehtud konfiga ffserveri, selleks
# ffserver
Ning seejärel paneme kliendi pumpama ffserveri peale videpilti. Seadmeks mille taga asub kaamera on /dev/video0
# ffmpeg -r 15 -s 352x288 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm
Video vaatamiseks tuleb enda lemmik videomängijaga avada url http://localhost:8090/test.flv või http://localhost:8090/test.asf.
Windows playeri puhul mms://localhost:8090/test.asf
Võimalik on videot kodeerida ka swf, mpg või mõnda teise formaati. Dokumentatsioonis seletakse pikemalt Juhul kui interneti ühendus on aegnale võib seadistada VideoFrameRate madalamaks (1-5).
Selleks, et streamida flashi mängijale (swf)
Tuleb lisada ffserver.conf faili järgnevad read
<Stream test.swf> Feed feed1.ffm Format swf VideoCodec flv VideoFrameRate 2 VideoBufferSize 80000 VideoBitRate 100 VideoQMin 1 VideoQMax 5 VideoSize 352x288 PreRoll 0 Noaudio </Stream>
Vaadata saab urlilt
http://localhost:8090/test.swf
Algses näites on nii server kui klient ühes masinas aga tüüpiliselt võib neid kasutada ka täiesti eraldi.
Soovides kiiremat reaktsiooniaega ning olles kvaliteetsemas võrgus võib buffreid väiksemaks keerata.
- http://ubuntuforums.org/archive/index.php/t-665607.html info algselt pärit siit lingilt