【libav】libav的常用方法
2016-03-25 10:29
447 查看
https://wiki.libav.org/Snippets/avconv
ffmpeg是对libav的封装
avconv
Thanks to roxlu for providing most of them.
Convert from raw x264 to flv (when you get an error with monotonically increasing dts)
avconv -i test_input.264 -c:v copy output.flv
Convert from flv to mov and specify bitrate
avconv -i test_input.flv -b 512k output.mov
Extract audio from movie
avconv -i test_input.mp4 -c:a copy -vn -y out.aac
Export only video from movie
avconv -i input.mov -an -c:v copy out.mov
Combine audio and video file
avconv -i video_input.mov -i audio_input.mp3 -c copy audio_and_video.mov
Create video from image sequence
avconv -framerate 25 -f image2 -i image-%03d.jpeg -b 65536k out.mov
Create video from image sequence (really good quality)
avconv -framerate 25 -f image2 -i %04d.png -c:v h264 -crf 1 out.mov
Extract one second from a video
avconv -ss 00:00:00 -i scanner.mov -t 00:00:01 -c:v copy scanner_small.mov
Read raw RGB frames from tcp and convert them into a video
avconv -v debug -f rawvideo -pix_fmt rgb24 -s 320x240 -i tcp://localhost:2233 -c:v h264 result.mov
Add audio to a video file and make sure the shortest stream is used, also show some debug info
avconv -v debug -i audio.wav -i video.mp4 -c:a libmp3lame -qscale 20 -shortest output.mov
Combining image sequences
Combining image sequences which are spread over multiple directories
On unix-like systemscat dir_a/*.jpg dir_b/*.jpg dir_c/*.jpg | ./avconv -f image2pipe -c:v mjpeg -i - -r 25 -map 0 out.mov
On windows, note the slashes
type dir_a\\*.jpg dir_b\\*.jpg dir_c\\*.jpg | avconv.exe -f image2pipe -c:v mjpeg -i - -r 25 -map 0 out.mov
Set a quality scale, use the shortest stream (audio of video)
cat dir_a/*.jpg dir_b/*.jpg dir_c/*.jpg ./avconv | ./avconv -f image2pipe -c:v mjpeg -i - -i audio.mp3 -c:a libmp3lame -qscale 20 -shortest -r 25 -map 0 -map 1 out.mov
Exporting frames from a video
Exporting to jpeg images
The qscale is the jpeg quality, 1 = excellent, 31 = worstavconv -i intro.mov -vsync 1 -r 25 -an -y -qscale 1 out_%04d.jpg
Resizing the output on the fly.
avconv -i intro.mov -vsync 1 -r 25 -an -y -qscale 1 -s 1280x720 out_%04d.jpg
Exporting to raw YUV
avconv -v debug -f rawvideo -pix_fmt yuv420p -s 320x240 -i raw.yuv -r 1 -vcodec h264 out.mov
Produce a 10s test video
avconv -y -filter_complex testsrc -t 10s out.avi
Streaming
Test akamai CDN using synthetic video
avconv -filter_complex text testsrc=hd720 -c:v h264 -b:v 500k -f flv rtmp://<USERNAME>:<PASSWORD>@p.<CPCODE>.i.akamaientrypoint.net/EntryPoint/mystream_1_500@<STREAMID>
Streaming pcm audio
Never use the wav container if you plan to stream indefinitely. arecord is provided as example, the alsa or pulsebuiltincapture should work better.
arecord -Dplughw:0,0 -f S16_LE -t raw -r 44100 -c 2 -N - | /usr/bin/avconv -f s16le -ar 44100 -ac 2 -i - -c:a libfdk_aac -b:a 80k -f mpegts udp://localhost:5000
Restream multicast mpegts to rtmp
Select a specific PID from a multicast mpegts stream and re-encode it before reflecting to an rtmp serveravconv -f mpegts -i udp://host:port -c:a:i:2300 aac -b:a 384k -c:v copy -f flv rtmp://host/live/stream
Interlace a progressive content
Creating new interlaced content is a badidea in general terms, do that only if you need to feed content to legacy equipment that does not have a progressive mode. 720p50 is always better than 1080i25 and it uses the same bandwidth.
avconv -i INPUT -vf interlace -flags +ildct+ilme OUTPUT
Use avfilter
Use frei0r's bluescreen0r-filter
Make a certain color transparent, for example for webcam chroma key'ingavconv -i overlay_source -i background_source -filter_complex 'frei0r=bluescreen0r:0/0/255|128,[1:v]overlay=0:0' output_destination
0/0/255|128 are the bluescreen0r-parameters, first color, then the tolerance. The format is blue/green/red|tolerance. The components of the color being alpha'ed out is specificed
between 0-255, and the tolerance adjusts how wide a range around the specified color is to be adjusted.
bluescreen0r will ignore all existing alpha-components in the source and completely replace them.
相关文章推荐
- DAO-CompactDataBase
- 北京Uber优步司机奖励政策(3月25日)
- 批量SSH操作工具---OmniTTY安装
- 测试技术的一些概念
- pysproto bug修复
- 掘金 Android 导航改进过程
- opensips介绍
- select选中方法
- Android使用fitsSystemWindows属性实现--状态栏【status_bar】各版本适配方案
- java代码解析excel文件(包含日期、小数的处理)
- 设置ListView item 不可点击,item中的元素可以点击
- 2015最流行的Android组件、工具、框架大全
- Android ListView 的一些问题
- nginx日志配置详解 -----谷营中西软件科技园
- apache链接svn出现的错误
- Oracle中快速查询和操作某个用户下的所有表数据信息
- 省市二级显示jquery
- Oracle中的单引号和&
- linux配置nodejs环境
- mybatis 集成spring 动态数据源,注解式切换