Convert video to WebM using GStreamer

11,869

Solution 1

You have the pipeline elements all out of order and you have syntax errors when dealing with named elements. Try something like this:

gst-launch-0.10 filesrc location=oldfile.ext ! decodebin name=demux ! queue ! ffmpegcolorspace ! vp8enc ! webmmux name=mux ! filesink location=newfile.webm demux. ! queue ! progressreport ! audioconvert ! audioresample ! vorbisenc ! mux.

This will construct the following pipeline:

               filesrc
                  |
              decodebin
                |   |
        +-------+   +-------+
        |                   |
        |                 queue
      queue                 |
        |             progressreport
        |                   |
ffmpegcolorspace       audioconvert
        |                   |
        |             audioresample
      vp8enc                |
        |               vorbisenc
        |                   |
        +-------+   +-------+
                |   |
               webmmux
                  |
               filesink

Solution 2

If you have videos with no audio (such as videos from a service like VideoBlocks), remove the audio pipeline.

Share:
11,869
Ory Band
Author by

Ory Band

Backend engineer. Loves Clojure, Golang and Linux. Interested in distributed systems. https://ory.band

Updated on July 24, 2022

Comments

  • Ory Band
    Ory Band almost 2 years

    Documentation for GStreamer is confusing. This is still no excuse for resorting to StackOverflow.com, but still:

    What is the GStreamer command line to convert any video file (from any format) to WebM (+WebM audio)?

    This is the only documentation with examples I could find.

    I'm stuck somewhere at gst-launch-0.10 webmmux name=mux ! filesrc location=oldfile.ext ! filesink location=newfile.webm ! name=demux ! demux. ! ffmpegcolorspace ! vp8enc ! queue ! mux.video_0 ! demux. ! progressreport ! audioconvert ! audiorate ! vorbisenc ! queue ! mux.audio_0

    I'm getting a WARNING: erroneous pipeline: link without source element with no idea how to to get this thing going.

    This is pretty frustrating.

    Please help, thank you. :)

  • Ory Band
    Ory Band over 13 years
    I'm getting an error. Here's the details (paste it to notepad/similar and replace '-->' with newlines to make this readable): Pipeline is PREROLLING ... --> ERROR: from element /GstPipeline:pipeline0/GstDecodeBin:demux/GstAviDemux:avidem‌​ux0: Internal data stream error. --> Additional debug info: --> gstavidemux.c(5134): gst_avi_demux_loop (): /GstPipeline:pipeline0/GstDecodeBin:demux/GstAviDemux:avidem‌​ux0: --> streaming stopped, reason not-linked --> ERROR: pipeline doesn't want to preroll. --> Setting pipeline to NULL ... --> Freeing pipeline ...
  • cdhowie
    cdhowie over 13 years
    Which gstreamer version? It looks like the avidemux element is having trouble detecting the format of some streams.
  • Ory Band
    Ory Band over 13 years
    0.10 for OSX. I installed using homebrew (the new MacPorts). I have tried executing the same line on my virtualbox Ubuntu, and it works perfectally. What am I missing?
  • Ory Band
    Ory Band over 13 years
    This is also hapenning with very simple commands. I.E. gst-launch-0.10 filesrc location=horse.mp3 ! decodebin ! audioconvert ! osxaudiosink I'm getting the streaming task paused, reason not-linked (-1) and pipeline doesn't want to preroll error all the time. It works on my Ubuntu (replacing osxaudiosink with alsasink).
  • cdhowie
    cdhowie over 13 years
    @Ory: The question you just linked is this question, silly. And to answer your question, it's likely that you are missing some codecs and decodebin can't find one suitable for the content of the AVI.
  • Ory Band
    Ory Band over 13 years
    Correct! This is the link to the other similiar problem: stackoverflow.com/questions/4094990/…
  • Ory Band
    Ory Band over 13 years
    I have eventually managed to understand the source of this. I was missing the gst-ffmpeg plugin. I installed it and everything worked. Thanks for the answer and thorugh help! :)