Sunday 20 January 2019

alpha channel - How do i convert a transparent .mov-file to an mp4 file overlayed on a background-image using FFMPEG

I'm trying to convert a mov file with the following specs:


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

I want a background-image with that video on top of it and save it as an mp4-file. In the meantime the video has to be scaled and cropped I need a solution which can be automated and placed on a server, that is why i tried ffmpeg


This is wat have at the moment:


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


The problem is, somehow, the transparency is lost, and the background is black, instead of the underlying image. When i try the same ffmpeg command with a transparent FLV as input, it works, but i would like it to work without having to convert al source files first to another format


Any help with this would be greatly appreciated !


This is my current ffmpeg configuration:


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

EDIT


This is the complete console output for the command:


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

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...