Giter VIP home page Giter VIP logo

media-editor's Introduction

media-editor

使用moviepy & ffmpeg來剪輯影片和音檔。

安裝

建議作業系統為ubuntu,我們使用Python 2.7的環境且必須要先安裝pipenv。 請執行下列指令來安裝所有需要的第三方套件

$ pipenv install --ignore-pipfile --dev

安裝注意事項

  • 安裝完後,在目錄~/.imageio/ffmpeg中會看到ffmpeg執行檔,這個執行檔是專門給moviepy用的,若沒透過特別設定,其他想用ffmpeg的程式是無法用到它的。

  • 如果你的/usr/bin/中沒有ffmpeg,則執行autosubextract_subtitles.pyextract_subtitles_batch.py都會失敗,這時請你在/usr/bin/中建立一個soft link到~/.imageio/ffmpeg/ffmpeg執行檔就可以解決問題,例如:假設ffmpeg執行檔的檔名為ffmpeg-linux64-v3.3.1,且家目錄的名稱為/home/jimmy,則請執行以下指令

    $ cd /usr/bin
    $ ln -s /home/jimmy/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1 ffmpeg
    

    這樣autosubextract_subtitles.pyextract_subtitles_batch.py就可以正常執行。 當然你也可以考慮直接apt-get install ffmpeg在global安裝另一個ffmpeg執行檔也行

Usage

關於每個python script的用法,請參考每個script的main function中最上方的comment.

備忘

  • 若想單獨執行autosub來產生字幕,請執行

    $ pipenv run autosub input-video.mp4 -S "zh-TW" -D "zh-TW" -F vtt -o output-subtitles.vtt
    

    其中input-video.mp4為輸入的影片檔(也可以輸出音訊檔,例如.mp3.wav),-S "zh-TW"是設定輸入影片檔的語言(預設是英語),-D "zh-TW"是設定輸出字幕檔的語言,-F vtt是設定字幕檔為vtt格式(預設是srt),-o output-subtitles.vtt是設定輸出字幕檔的檔名(預設是和輸入影片擁有同樣的主檔名)。

  • 若你想要將字幕(subtitles)檔和影片合併成一個影片檔,請執行

    $ ffmpeg -i input-video.mp4 -vf "subtitles=input-video.vtt:force_style='FontName=AR PL UMing TW,Fontsize=10,PrimaryColour=&Hffffff&,Outline=2,BackColour=&H000000&,BorderStyle=3,Shadow=0,OutlineColour=&H80000000'" output-video.mp4
    

    其中input-video.mp4為輸入的影片檔,input-video.vtt為輸入的字幕檔(.srt, .vtt都可以),output-video.mp4為輸出的影片檔,FontName=AR PL UMing TW這段是設定字體,Fontsize=10這段是設定字體大小(預設是Fontsize=16),你的電腦上必須有對應的字體才行。在ubuntu上,可以用fc-list來看電腦中安裝了哪些字體。除了FontName之外,其他在force_style中的設定原則上不要動,出來的字幕應該是白色字且背景是半透明的淺灰色。

media-editor's People

Contributors

weichuntsai0217 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.