Convert video with vp9 codec using ffmpeg

352

Solution 1

The most basic command is:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -c:a libopus output.webm

See FFmpeg Wiki: VP9 for more info.

Solution 2

With my version of ffmpeg,

$ ffmpeg -version
ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers

the command looks like this

ffmpeg -y -i input.mkv -c:v libvpx-vp9 -b:v 2000k -pass 1 -an -f webm /dev/null
ffmpeg    -i input.mkv -c:v libvpx-vp9 -b:v 2000k -pass 2 -c:a opus -b:a 64k -f webm output.webm

i.e.

  • leave out the experimental flags
  • do a two pass encoding, because the first two seconds of the output are blurry otherwise. Doing a two pass encoding is also faster than single pass.
  • when doing 2 pass, you do not need to encode the audio in the first pass as @FrankGalligan noted in a comment

Single pass is/was broken, according to http://wiki.webmproject.org/vp9/known-issues

Share:
352

Related videos on Youtube

Soumya Gupta
Author by

Soumya Gupta

Updated on September 18, 2022

Comments

  • Soumya Gupta
    Soumya Gupta almost 2 years

    While I know there are cleaner more efficient programs out there for BFS traversal in other languages, in c it gets a bit lengthy
    I've found some really lengthy and complicated programs on leetcode, as a beginner those are a little hard to understand, while I understand the basic concept behind it I found a much simpler and cleaner code here sanfoundry but it doesn't work for some reason? I'd be grateful if someone can help me out with this :)

    #include <stdio.h>
    #include <stdlib.h>
     
    struct btnode
    { 
        int value; 
        struct btnode *left, *right; 
    }; 
    typedef struct btnode node;
     
    /* function declarations */
    void insert(node *, node *);
    void bfs_traverse(node *);
     
    /*global declarations */
    node *root = NULL;
    int val, front = 0, rear = -1, i;
    int queue[20];
     
    void main() 
    { 
        node *new = NULL ; 
        int num = 1; 
        printf("Enter the elements of the tree(enter 0 to exit)\n"); 
        while (1) 
        {     
            scanf("%d",  &num); 
            if (num  ==  0) 
                break; 
            new = malloc(sizeof(node)); 
            new->left = new->right = NULL; 
            new->value = num; 
            if (root == NULL) 
                root = new; 
            else 
            { 
                insert(new, root); 
            } 
        }
        printf("elements in a tree in inorder are\n"); 
        queue[++rear] = root->value;
        bfs_traverse(root);
        for (i = 0;i <= rear;i++)
            printf("%d -> ", queue[i]);
        printf("%d\n", root->right->right->right->value);
    }
     
    /* inserting nodes of a tree */
    void insert(node * new , node *root) 
    { 
        if (new->value>root->value) 
        {     
            if (root->right == NULL) 
                root->right = new; 
            else 
                insert (new, root->right); 
        } 
        if (new->value < root->value) 
        {     
            if (root->left  ==  NULL) 
                root->left = new; 
            else 
                insert (new, root->left); 
        }     
    }
     
    /* displaying elements using BFS traversal */
    void bfs_traverse(node *root)
    {
        val = root->value;
        if ((front <= rear)&&(root->value == queue[front]))
        {
            if (root->left != NULL)
                queue[++rear] = root->left->value;
            if (root->right != NULL || root->right  ==  NULL)
                queue[++rear] = root->right->value;
            front++;
        }
        if (root->left != NULL)
        {
            bfs_traverse(root->left);
        }
        if (root->right != NULL)
        {
            bfs_traverse(root->right);
        }
    }
    
    • Joel Purra
      Joel Purra over 9 years
      brew install ffmpeg --with-libvpx --with-opus
    • Aaron Franke
      Aaron Franke over 2 years
      @JoelPurra Usage: brew install [options] formula|cask [...] Error: invalid option: --with-libvpx
    • trincot
      trincot over 2 years
      Why is there no feedback on the answer that was given?
  • Pavel Binar
    Pavel Binar over 10 years
    I installed ffmpeg and all its components via this guide and it works now! sites.google.com/a/webmproject.org/wiki/ffmpeg/…
  • FrankGalligan
    FrankGalligan over 9 years
    Do not set -strict experimental. That was for older FFmpeg. When doing 2 pass, you do not need to encode the audio in the first pass. ffmpeg -y -i input.mkv -c:v libvpx-vp9 -b:v 2000k -pass 1 -an -f webm /dev/null ffmpeg -i input.mkv -c:v libvpx-vp9 -b:v 2000k -pass 2 -c:a opus -b:a 64k -f webm output.webm
  • Aaron Franke
    Aaron Franke over 2 years
    How do I check if the input file has VP9 or some other codec?
  • Admin
    Admin about 2 years
    Its odd no one uses cq. What is your reason to use webm vs mkv?