我正在尝试转换具有以下规格的 mov 文件:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2012-10-09 13:34:01
Duration: 00:00:51.60, start: 0.000000, bitrate: 217433 kb/s
Stream #0:0(eng): Video: prores (ap4h / 0x68347061), yuv444p10le, 1920x1080, 215844 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc
Metadata:
creation_time : 2012-10-09 13:34:01
handler_name : Apple Alias Data Handler
timecode : 01:00:00:00
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
creation_time : 2012-10-09 13:34:01
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
creation_time : 2012-10-09 13:42:30
handler_name : Apple Alias Data Handler
timecode : 01:00:00:00
我想要一张背景图片,上面有视频,然后将其保存为 mp4 文件。与此同时,视频必须缩放和裁剪,我需要一个可以自动化并放置在服务器上的解决方案,这就是我尝试 ffmpeg 的原因
目前的情况如下:
ffmpeg -loop 1 -f image2 -i background.png -r 25 -an -vcodec libx264 -b:v 1500k -vf "movie=test.mov[movie];[movie]scale=max(552\, 420*iw/ih):-1[OUT1]; [OUT1]crop=552:420[OUT2]; [0][OUT2] overlay=0:0 [out]" -s 552x420 -y output.mp4
问题是,不知何故,透明度丢失了,背景是黑色的,而不是底层图像。当我尝试使用透明 FLV 作为输入的相同 ffmpeg 命令时,它可以工作,但我希望它无需先将所有源文件转换为另一种格式即可工作
如能得到任何帮助都将非常感激!
这是我当前的 ffmpeg 配置:
ffmpeg version 1.1.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 4 2013 11:19:29 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac
libavutil 52. 13.100 / 52. 13.100
libavcodec 54. 86.100 / 54. 86.100
libavformat 54. 59.106 / 54. 59.106
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 32.100 / 3. 32.100
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
编辑
这是该命令的完整控制台输出:
ffmpeg -loop 1 -f image2 -i background.jpg -r 25 -an -vframes 2500 -vcodec libx264 -b:v 1500k -vf "movie=test.mov[movie];[movie]scale=max(552\, 420*iw/ih):-1[OUT1]; [OUT1]crop=552:420[OUT2]; [0][OUT2] overlay=0:0 [out]" -s 552x420 -y output.mp4
ffmpeg version 1.1.2 Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 4 2013 11:19:29 with Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libfreetype --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfaac
libavutil 52. 13.100 / 52. 13.100
libavcodec 54. 86.100 / 54. 86.100
libavformat 54. 59.106 / 54. 59.106
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 32.100 / 3. 32.100
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, image2, from 'background.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p, 1024x576, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x7fddc3813600] using cpu capabilities: none!
[libx264 @ 0x7fddc3813600] profile High, level 3.0
[libx264 @ 0x7fddc3813600] 264 - core 128 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - 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=12 lookahead_threads=2 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=abr mbtree=1 bitrate=1500 ratetol=1.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:
encoder : Lavf54.59.106
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 552x420, q=-1--1, 1500 kb/s, 12800 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg -> libx264)
Press [q] to stop, [?] for help
frame= 2500 fps= 53 q=32766.0 Lsize= 9772kB time=00:01:39.92 bitrate= 801.2kbits/s
video:9742kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.309877%
[libx264 @ 0x7fddc3813600] frame I:10 Avg QP: 1.97 size: 58522
[libx264 @ 0x7fddc3813600] frame P:634 Avg QP: 4.19 size: 7889
[libx264 @ 0x7fddc3813600] frame B:1856 Avg QP: 7.63 size: 2364
[libx264 @ 0x7fddc3813600] consecutive B-frames: 1.0% 0.0% 0.1% 98.9%
[libx264 @ 0x7fddc3813600] mb I I16..4: 47.6% 16.4% 36.0%
[libx264 @ 0x7fddc3813600] mb P I16..4: 0.1% 0.1% 0.3% P16..4: 2.9% 2.9% 2.6% 0.0% 0.0% skip:91.1%
[libx264 @ 0x7fddc3813600] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 2.3% 1.1% 1.1% direct: 3.0% skip:92.4% L0:23.8% L1:24.1% BI:52.0%
[libx264 @ 0x7fddc3813600] final ratefactor: -0.23
[libx264 @ 0x7fddc3813600] 8x8 transform intra:16.7% inter:26.0%
[libx264 @ 0x7fddc3813600] coded y,uvDC,uvAC intra: 65.5% 84.3% 83.9% inter: 5.8% 4.8% 3.8%
[libx264 @ 0x7fddc3813600] i16 v,h,dc,p: 60% 21% 8% 12%
[libx264 @ 0x7fddc3813600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 31% 9% 3% 5% 8% 6% 6% 5%
[libx264 @ 0x7fddc3813600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 27% 11% 4% 7% 9% 7% 6% 6%
[libx264 @ 0x7fddc3813600] i8c dc,h,v,p: 34% 43% 17% 7%
[libx264 @ 0x7fddc3813600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fddc3813600] ref P L0: 61.2% 19.9% 10.0% 8.8%
[libx264 @ 0x7fddc3813600] ref B L0: 91.0% 7.3% 1.7%
[libx264 @ 0x7fddc3813600] ref B L1: 98.7% 1.3%
[libx264 @ 0x7fddc3813600] kb/s:798.01
答案1
ffmpeg
目前不支持 ProRes alpha 通道。(这是打开增强请求.) 如果您可以改用 QuickTime Animation (RLE) 编解码器 ( qtrle
) 来制作覆盖影片,那么应该可以。