[FFmpeg-user] Create transparent movie with subtitles
DopeLabs
dopelabs at dubstep.fm
Wed Sep 20 22:45:40 EEST 2017
i think you were close with the transparent png, you just used png as a video codec.
try something like -c:v h264
i dont have a subtitles file so i used drawtext filter in its place and seems to work as expected.
$ ffmpeg -loop 1 -i alpha1080.png -vf drawtext=text="some text":x=10:y=10:fontcolor="white":fontsize=72 -t 00:00:10.000 -c:v h264 -f mp4 test.mp4
ffmpeg version N-86825-g99c5ac2039 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --enable-videotoolbox --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-filter=coreimage --enable-filter=coreimagesrc --enable-filter=frei0r --enable-filter=frei0r_src --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --enable-libx265 --enable-version3 --enable-libwavpack --enable-libssh --enable-librtmp --enable-libfdk-aac --enable-nonfree --enable-libzmq --enable-opencl --enable-ffplay --enable-libcaca
libavutil 55. 68.100 / 55. 68.100
libavcodec 57.102.100 / 57.102.100
libavformat 57. 76.100 / 57. 76.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 95.100 / 6. 95.100
libavresample 3. 6. 0 / 3. 6. 0
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, png_pipe, from 'alpha1080.png':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: png, rgba(pc), 1920x1080 [SAR 2835:2835 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'test.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[Parsed_drawtext_0 @ 0x7fa67e1001a0] Using "/Library/Fonts/Verdana.ttf"
[libx264 @ 0x7fa67c005e00] using SAR=1/1
[libx264 @ 0x7fa67c005e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fa67c005e00] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 @ 0x7fa67c005e00] 264 - core 148 r2748 97eaef2 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=4 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=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 'test.mp4':
Metadata:
encoder : Lavf57.76.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc57.102.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 250 fps= 90 q=-1.0 Lsize= 26kB time=00:00:09.88 bitrate= 21.8kbits/s speed=3.57x
video:23kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 16.684706%
[libx264 @ 0x7fa67c005e00] frame I:1 Avg QP: 9.87 size: 3260
[libx264 @ 0x7fa67c005e00] frame P:63 Avg QP: 9.16 size: 80
[libx264 @ 0x7fa67c005e00] frame B:186 Avg QP:12.78 size: 76
[libx264 @ 0x7fa67c005e00] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x7fa67c005e00] mb I I16..4: 0.1% 99.0% 0.8%
[libx264 @ 0x7fa67c005e00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x7fa67c005e00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0:64.3% L1:35.7% BI: 0.0%
[libx264 @ 0x7fa67c005e00] 8x8 transform intra:98.7% inter:0.0%
[libx264 @ 0x7fa67c005e00] coded y,u,v intra: 0.6% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7fa67c005e00] i16 v,h,dc,p: 35% 62% 3% 0%
[libx264 @ 0x7fa67c005e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 93% 5% 2% 0% 0% 0% 0% 0% 0%
[libx264 @ 0x7fa67c005e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 16% 19% 5% 5% 4% 5% 2% 5%
[libx264 @ 0x7fa67c005e00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fa67c005e00] ref P L0: 96.7% 0.0% 3.3%
[libx264 @ 0x7fa67c005e00] ref B L0: 51.6% 48.4%
[libx264 @ 0x7fa67c005e00] ref B L1: 99.6% 0.4%
[libx264 @ 0x7fa67c005e00] kb/s:17.93
[24][12:37:07] dopelabs at jeez:~/Pictures $ ffprobe test.mp4
ffprobe version N-86825-g99c5ac2039 Copyright (c) 2007-2017 the FFmpeg developers
built with Apple LLVM version 8.1.0 (clang-802.0.42)
configuration: --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --enable-videotoolbox --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-filter=coreimage --enable-filter=coreimagesrc --enable-filter=frei0r --enable-filter=frei0r_src --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --enable-libx265 --enable-version3 --enable-libwavpack --enable-libssh --enable-librtmp --enable-libfdk-aac --enable-nonfree --enable-libzmq --enable-opencl --enable-ffplay --enable-libcaca
libavutil 55. 68.100 / 55. 68.100
libavcodec 57.102.100 / 57.102.100
libavformat 57. 76.100 / 57. 76.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 95.100 / 6. 95.100
libavresample 3. 6. 0 / 3. 6. 0
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.76.100
Duration: 00:00:10.00, start: 0.000000, bitrate: 21 kb/s
Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1920x1080 [SAR 1:1 DAR 16:9], 18 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
> On Sep 20, 2017, at 3:52 49AM, Frank @ Taapo <info at taapo.com> wrote:
>
> I'm at a loss at the moment. I have been testing and posting questions @
> SO, VideoHelp, Doom9 -- nobody seems to have an answer. Maybe I have better
> luck here.
>
> I'm trying to generate a transparent movie with ASS subtitles burnt in. The
> only way to do this correctly seems to be using AviSynth as an
> intermediate, but I'm sure there is another way.
>
> I can use colorkey, like below - and it'll create a usable transparent
> movie - but the edges of the subtitles are not smooth anymore:
>
> ffmpeg.exe -y -f lavfi -i color=s=1920x1080:color=0xff0000 -an -vf
> "ass=test.ass,colorkey=0xff0000:0.5:0.5,format=yuva420p" -c:v png -t
> "00:01:40.544" -threads 0 "video.mov" -stats
>
> It's clear that this is not the way to go.
>
> So my second way of thinking was creating a virtual background using lavfi,
> and setting this to a transparent color -- but I have not found a way to
> set a color and make it transparent using ffmpeg filters.
>
> Third try was to create a transparent png, loop it and overlay the
> subtitles:
>
> ffmpeg.exe -y -loop 1 -i transparent-1920x1080.png -vf
> "ass=test-normal.ass,format=rgba" -c:v png -t "00:00:10.000" -threads 4
> "video-transparent.mov" -stats
>
> While I preview the resulting movie in a media player, it shows the
> subtitles on a white background, but when I import in Premiere or After
> Effects, the full movie is transparent. Like if the alpha channel is
> applied on top of the subtitles.
>
> Is there a way to get this done properly in ffmpeg?
> ᐧ
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list