Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S scripts
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • rizzle
  • scripts
  • Wiki
  • Tutorials
  • vp9 conversion

Last edited by rizzle Apr 05, 2019
Page history

vp9 conversion

Parameters

Parameter Function
$INPUT the input video file
$CRF the target quality (33 is a good value, the smaller the better the video quality)
$THREADS the number of threads to use converting the video
$GOP the number of frames after which another inter frame is forced. You can seek between inter frames, so if you want to seek make this something like 5 * $FPS
$OUTFILE the target video file name
$WIDTH the target width when scaling. When setting the height to -1 the aspect ratio is kept

Other regulations:

The webm container only supports webvtt subtitles, so if you have embedded subtitle in the video -c:s webvtt tries to convert them into webvtt.

Converting a single file

With one-pass:

ffmpeg -i $INPUT -c:v libvpx-vp9 -b:v 0 -crf $CRF -threads $THREADS -g $GOP -tile-columns 6 -frame-parallel 1 -c:s webvtt -speed 1 -c:a libopus -b:a 64k -f webm $OUTFILE

When doing a two-pass, the speed value can be changed and the audio conversion can be omitted during 1st pass:

ffmpeg -i $INPUT -pass 1 -passlogfile $PREFIX -c:v libvpx-vp9 -b:v 0 -crf $CRF -threads $THREADS -g $GOP -tile-columns 6 -frame-parallel 1 -speed 4 -an -f webm /dev/null
ffmpeg -i $INPUT -pass 2 -passlogfile $PREFIX -c:v libvpx-vp9 -b:v 0 -crf $CRF -threads $THREADS -g $GOP -tile-columns 6 -frame-parallel 1 -c:s webvtt -speed 1 -c:a libopus -b:a 64k -f webm $OUTFILE

When scaling the video just add the following parameter:

-vf scale=$WIDTH:-1

Merging several files into one

To merge several files into one a "complex filter" has to be used. When this is used, no normal filter can be used (e.g. for scaling). To simply merge two files use the following parameters:

-i $INPUT1 -i $INPUT2 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" -map '[v]' -map '[a]'

This takes the first video and audio streams from the first file and the first video and audio streams from the second file. It then concats the two (n=2) streams in one video (v=1) and audio stream (a=1) and exports them as [v] and [a]. Later it maps them to the output file.

When trying to scale this video you can chain complex filters. This would look like this:

-i $INPUT1 -i $INPUT2 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]; [v]scale=$WIDTH:-1[v2]" -map '[v2]' -map '[a]'

Known Errors and Workarounds

Invalid channel layout 5.1(side) for specified mapping family -1

Either add an audio filter

-af "channelmap=channel_layout=5.1"

or enhance the complex filter with

;[a] channelmap=channel_layout=5.1 [a2]
Clone repository
  • Home
  • small howtos
  • tutorials
  • tutorials
    • backup duplicity
    • multi storage server
    • multiple ssid hostapd
    • openwrt on nfs root
    • po documention
    • pxe server
    • rsync only ssh
    • tinc
    • vp9 conversion