在看视频时,图像上面有流动字幕,或者流动图片,这个效果一般名为跑马灯效果,可以通过overlay的filter实现该效果 overlay是ffmpeg的filter中常用的filter,可以深入的研究一下,先解决跑马灯问题:
点击(此处)折叠或打开
- overlay=x='if(gte(t,2), -w (t-2)*20, NAN)
点击(此处)折叠或打开
- ffmpeg -i ~/Movies/objectC/bbs.chinaffmpeg.com-孙悟空.mp4 -i ~/Movies/guanlangaoshou.mp4 -vcodec libx264 -an -filter_complex "overlay=x='if(gte(t,2), -w (t-2)*20, NAN)':y=0" -s 320x240 output.mp4
输出内容:
点击(此处)折叠或打开
- ffmpeg version N-79068-g6b7ce0e Copyright (c) 2000-2016 the FFmpeg bbs.chinaffmpeg.com 孙悟空
- built with Apple LLVM version 7.0.2 (clang-700.1.81)
- configuration: --enable-libass --enable-opengl --enable-libx265 --enable-libx264 --enable-libmp3lame --enable-gpl --enable-libfaac --enable-nonfree --prefix=/usr/local
- libavutil 55. 19.100 / 55. 19.100
- libavcodec 57. 28.103 / 57. 28.103
- libavformat 57. 28.102 / 57. 28.102
- libavdevice 57. 0.101 / 57. 0.101
- libavfilter 6. 39.102 / 6. 39.102
- libswscale 4. 0.100 / 4. 0.100
- libswresample 2. 0.101 / 2. 0.101
- libpostproc 54. 0.100 / 54. 0.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/Movies/objectC/facebook.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf55.22.102
- description : This File is Created by Easy RealMedia Tools@!
- Duration: 02:00:27.85, start: 0.000000, bitrate: 893 kb/s
- Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 797 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
- Metadata:
- handler_name : VideoHandler
- Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 87 kb/s (default)
- Metadata:
- handler_name : SoundHandler
- Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/Movies/guanlangaoshou.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf56.36.100
- Duration: 00:05:29.67, start: 0.000000, bitrate: 1195 kb/s
- Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x268, 1038 kb/s, 24 fps, 24 tbr, 90k tbn, 48 tbc (default)
- Metadata:
- handler_name : VideoHandler
- Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 148 kb/s (default)
- Metadata:
- handler_name : SoundHandler
- File 'output.mp4' already exists. Overwrite ? [y/N] Y
- [libx264 @ 0x7fd4a281d200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
- [libx264 @ 0x7fd4a281d200] profile High, level 1.3
- [libx264 @ 0x7fd4a281d200] 264 - core 133 r2334M a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - [url]http://www.videolan.org/x264.html[/url] - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
- Output #0, mp4, to 'output.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- description : This File is Created by Easy RealMedia Tools@!
- encoder : Lavf57.28.102
- Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 320x240, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
- Metadata:
- encoder : Lavc57.28.103 libx264
- Side data:
- cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
- Stream mapping:
- Stream #0:0 (h264) -> overlay:main
- Stream #1:0 (h264) -> overlay:overlay
- overlay -> Stream #0:0 (libx264)
- Press [q] to stop, [?] for help
- frame= 648 fps=288 q=-1.0 Lsize= 382kB time=00:00:25.84 bitrate= 121.2kbits/s speed=11.5x
截个图看看效果