使用Javascript或PHP更改视频的颜色类型

today i got 1 request from one of my client.

He wants to change color pattern of his video. He wants to convert his colorful video into "black & white", "sepia" , etc.,

Is it possible using javascript or PHP [PHP using any server software].

Thanks

It depends on many factors:

  • if the videos are hosted on youtube or another video service: No way to achieve that
  • if the videos are hosted on your server and are available via HTTP delivery you can use server side processing (ie when the videos are uploaded, you make a system call to a video tool like ffmpeg, or any other video processing tool) or use Javascript to process your video using canvas tag
  • if you are using a specialized streaming server, you can real-time process your videos but i don't think it's the case

you can find several tutorials for video processing using JS (eg:http://html5doctor.com/video-canvas-magic/)

for php (if you are using linux):

<?php exec('/usr/bin/env ffmpeg -i input_video.mp4 -vf "hue=s=0" bw_video.mp4'); ?>

It may take a long time (maybe more than max_execution_time), it may not work on shared hosting...

If you don't care about the job is finished or not (and avoid max_execution_time problem):

<?php exec('2>/dev/null 1>/dev/null /usr/bin/env ffmpeg -i input_video.mp4 -vf "hue=s=0" bw_video.mp4 &'); ?>