Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert mov with Alpha to VP9 Webm with Alpha Using ffmpeg

Tags:

video

ffmpeg

webm

I am trying to convert a mov with alpha transparency to webm with alpha transparency, as seen here. I followed the steps explained here to no avail.

From this answer I was able to remove all the black in the video, thus making it transparent but this is not what I need as I already have a transparent mov and would like to convert that to transparent webm format.

ffmpeg -i input.mp4 -c:v libvpx -vf "colorkey=0x000000:0.1:0.1,format=yuva420p" out.webm

This is the ffprobe output of the video I would like to convert to webm with transparency.

built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 --enable-nonfree --enable-vda
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2016-01-17 16:04:07
    encoder         : Mac OS X v? (AVF 1046.9.1, CM 1731.15.20, x86_64)
    encoder-eng     : Mac OS X v? (AVF 1046.9.1, CM 1731.15.20, x86_64)
  Duration: 00:00:06.63, start: 0.000000, bitrate: 63966 kb/s
    Stream #0:0(eng): Video: prores (ap4h / 0x68347061), yuva444p10le(bt470bg/smpte240m/bt709), 1920x1080, 63963 kb/s, 25.03 fps, 25 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2016-01-17 16:04:07
      handler_name    : Core Media Data Handler
      encoder         : Apple ProRes 4444

I've also tried the following command which didn't work for me either.

ffmpeg -y -i input.mov -c:v libvpx-vp9 -b:v 2000k -pass 1 -an -f webm output.webm

I'm using version 2.8.4 of ffmpeg on a Mac, installed with brew. 2.8.5 is the latest version.

like image 307
Enijar Avatar asked Jan 18 '16 13:01

Enijar


People also ask

Does ffmpeg support Alpha?

Yes ffmpeg certainly does support alpha channel in a video file.

Does WebM support alpha channel?

WebM format doesn't support Alpha channels. So, use any format that supports alpha like Quicktime and then convert it to WebM.

Does ffmpeg support MOV?

FFmpeg can input most container formats natively, including MP4, . ts, MOV, AVI, Y4M, MKV, and many others.


Video Answer


1 Answers

Since 2016-07-13, it's possible to encode VP9/webm videos with alpha channel (VP9a). However, the command you use here will create a VP8a video. Assuming you got a copy of ffmpeg compiled after that date, all you need is change the libvpx to libvpx-vp9. You don't need the yuva420p conversion either (is selected by default).

like image 65
cdlvcdlv Avatar answered Nov 14 '22 15:11

cdlvcdlv