DICE PACKS BUNDLE
  1. #1

    Bash: Batch convert webm VP9 to webm VP8 using ffmpeg

    Bash script to batch convert animated assets VP9 to VP8 for FG using ffmpeg.
    Linux/OSX Bash Script
    Windows Powershell - By Lo Zeno

    Will recursively batch convert animated assets. Works well for large amounts of assets such as https://jb2a.com
    It will copy over existing VP8 assets to the new destination and convert VP9 to VP8. There is option to re-encode VP8 if you wish. You can also adjust some of the encoding settings I have if you don't like them. It will also not copy over anything that isn't a webm file so it cleans out any text files or webp files that may also be there.

    Instructions OSX/Linux
    • Install ffmepg
    • Download attached convert-vp9.txt and rename it convert-vp9
    • Make it executable. chmod +x convert-vp9
    • Run it ./convert-vp9 -i input-folder -o images


    Windows should also be possible but it may have to get converted to a powershell script. Someone who has more knowledge than I may be able to do that pretty quickly
    Attached Files Attached Files
    Last edited by rhagelstrom; July 6th, 2023 at 22:16. Reason: Update Powershell link to latest

  2. #2
    Thanks!
    Savage Rifts© on Fantasy Grounds Store
    Ultimate Edition Fantasy Grounds - ONLY ON Linux
    Twitch Channel

  3. #3
    Quote Originally Posted by rhagelstrom View Post
    Bash script to batch convert animated assets VP9 to VP8 for FG using ffmpeg.

    Will recursively batch convert animated assets. Works well for large amounts of assets such as https://jb2a.com
    It will copy over existing VP8 assets to the new destination and convert VP9 to VP8. There is option to re-encode VP8 if you wish. You can also adjust some of the encoding settings I have if you don't like them. It will also not copy over anything that isn't a webm file so it cleans out any text files or webp files that may also be there.

    Instructions OSX/Linux
    • Install ffmepg
    • Download attached convert-vp9.txt and rename it convert-vp9
    • Make it executable. chmod +x convert-vp9
    • Run it ./convert-vp9 -i input-folder -o images


    Windows should also be possible but it may have to get converted to a powershell script. Someone who has more knowledge than I may be able to do that pretty quickly
    I have made a powershell conversion of it - very hasted, very brutal and absolutely ugly looking in terms of code and Powershell best practices - I basically converted your bash line-by-line. Ugly, but works fine for what I tested so far.
    If I'll have time I'll clean it up.
    Once downloaded, the file needs to be renamed from convert-vp9.txt to convert-vp9.ps1

    For windows users, the best way to install ffmpeg is to use a package manager:
    if you have chocolatey from powershell with admin rights type:
    Code:
    choco install ffmpeg
    if you have scoop, from powershell without admin rights type:
    Code:
    scoop install ffmpeg
    if you prefer WinGet, which comes included in Windows 11, from powershell with or without admin rights type:
    Code:
    winget install ffmpeg
    EDIT: I've removed the old version of the script, the post just below this has the latest version.
    Last edited by Lo Zeno; July 3rd, 2023 at 10:53. Reason: Removed old version of the script that did not set alpha channel correctly

  4. #4
    I've made a better version with some small cleanup to the code and a fix to the parameters passed to ffmpeg which were not passing the transparency correctly.

    The instructions to use it are similar to the ones for the bash file, except the commands are run in Powershell:
    • Install ffmpeg (refer to the post above for ways to do it on Windows)
    • Download the file and rename it to convert-vp9.ps1
    • Set your powershell execution policy to allow the script to be run: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
    • Run it: convert-vp9.ps1 -i input-folder -o output-folder
    Attached Files Attached Files

  5. #5
    I am not versed in Powershell.

    So I installed ffmpeg with winget, I ran powershell as admin, ran the set-executionpolicy and then ran your script and I get the following error:

    ffprobe : The term 'ffprobe' is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At D:\RPG\convert-vp9.ps1:43 char:28
    + $vp8 = ffprobe -show_streams -hide_banner -logle ...
    + ~~~~~~~
    + CategoryInfo : ObjectNotFound: (ffprobe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    Any ideas?

    [UPDATE]
    Uninstalled ffmpeg and then reinstalled using powershell with admin rights and it works now.
    Last edited by Farnaby; June 27th, 2023 at 18:13. Reason: Working now
    “He says gods like having an atheist around. Gives them something to aim at.”

    Terry Pratchett [RIP] - Small Gods

  6. #6
    Quote Originally Posted by Farnaby View Post
    I am not versed in Powershell.

    So I installed ffmpeg with winget, I ran powershell as admin, ran the set-executionpolicy and then ran your script and I get the following error:



    Any ideas?

    [UPDATE]
    Uninstalled ffmpeg and then reinstalled using powershell with admin rights and it works now.
    You don't need to use powershell with admin rights in order to install ffmpeg - actually you don't need to run powershell with admin rights at all for this script to work. I think your issue was that winget, unlike scoop and chocolatey, does not automatically refresh the PATH and environment variable of your powershell session, so after installing ffmpeg with winget what you needed to do was close powershell, wait a few seconds, and reopen it (without admin rights) for it to work. Your uninstalling and reinstalling achieved probably the same thing.

  7. #7
    One more small fix to the Powershell version: the script was failing to copy files or folders that included wildcard characters (square brackets in particular), so I changed the relevant commandlets to use -LiteralPath instead of -Path

    As usual, rename the file to convert-vp9.ps1 to use.
    Attached Files Attached Files

  8. #8
    Farratto's Avatar
    Join Date
    May 2023
    Location
    East Coast, USA
    Posts
    42
    I updated the bash script slightly for myself to add an additional option to rotate the tokens 90 degrees clockwise. The script still does everything it did before. Just one new command line option available.

    It may sound wierd, but the reason I did it is because I have a lot of spell tokens originally intended for Foundry and for what ever reason they're token graphics default shooting to the right and B9 Spell Tokens extension uses shooting downward. For the most part this doesn't cause a problem but if you're using the B9 Spell Tokens to target, it becomes an issue for cone shaped spells only (i.e. dragon breath & what-not).

    If you want to make use of these tokens in this manner, you separate out the cone spells (or any token you want to rotate 90 degrees clockwise) in a different directory. Run the script normally with the tokens you don't want to rotate. Then run the script again on your separated directy, this time, adding the "-t" argument. You don't have to remember that. If you do a help on the script, it will tell you all the available arguments and it is there.

    Hope it's helpful to someone. Helped me a lot.

    P.S. don't forget to rename the file to .sh and give it execute permission.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Cosmere RPG Beta Launch

Log in

Log in