Last edited 3 months ago

Gst-transcoder

Applicable for STM32MP25x lines

1. Overview[edit | edit source]

gst-transcoder (gst-transcoder-1.0) is a GStreamer command line utility available with GStreamer-1.X.

This utility transcodes audio / video multimedia content using complex GStreamer elements such as decodebin and encodebin into various audio / video multimedia content. It takes as an input either individual files or URL.

2. Usage[edit | edit source]

gst-transcoder accepts the following options:

 gst-transcoder-1.0 --help
Usage:
  gst-transcoder [OPTION?] <source uri> <destination uri> [<encoding format>[/<encoding profile name>]]

gst-transcoder-1.0 transcodes a stream defined by its first <input-uri>
argument to the place defined by its second <output-uri> argument
into the format described in its third <encoding-format> argument,
or using the given <output-uri> file extension.

The <encoding-format> argument:
===============================

If the encoding format is not defined, it will be guessed with
the given <output-uri> file extension.
<encoding-format> describe the media format into which the
input stream is going to be transcoded. We have two different
ways of describing the format:

GstEncodingProfile serialization format
---------------------------------------

GStreamer encoding profiles can be described with a quite extensive
syntax which is described in the GstEncodingProfile documentation.

The simple case looks like:

    muxer_source_caps:videoencoder_source_caps:audioencoder_source_caps

Name and category of serialized GstEncodingTarget
-------------------------------------------------

Encoding targets describe well known formats which
those are provided in '.gep' files. You can list
available ones using the `--list-targets` argument.


Help Options:
  -h, --help                        Show help options
  --help-all                        Show all help options
  --help-gst                        Show GStreamer Options

Application Options:
  -c, --cpu-usage                   The CPU usage to target in the transcoding process
  -l, --list-targets                List all encoding targets
  -s, --size                        set frame size (WxH or abbreviation)
  -r, --audio-rate                  set audio sampling rate (in Hz)
  -f, --framerate                   set video framerate as a fraction (24/1 for 24fps) or a single number (24 for 24fps))
  -v, --video-encoder               The video encoder to use.

3. List the available output profiles[edit | edit source]

Use -l option to get the list of available destination multimedia content:

 gst-transcoder-1.0 -l
dvd (device): Encoding target suitable for DVDs
 * Profiles:
     - dvd: This is an encoding profile usable for DVDs
avi (file-extension): Default target for files with a .avi extension
 * Profiles:
     - default: Default profile for files with a .avi extension.
mp3 (file-extension): Default target for files with a .mp3 extension
 * Profiles:
     - default: Default profile for files with a .mp3 extension.
oga (file-extension): Default target for files with a .ogg and friends extension
 * Profiles:
     - default: Default target for files with a .ogg and friends extension
ogv;ogg (file-extension): Default target for files with a .ogg and friends extension
 * Profiles:
     - default: Default target for files with a .ogg and friends extension
webm (file-extension): Default target for files with a .webm extension
 * Profiles:
     - default: Default profile for files with a .webm extension.
                    Audio stream can be either vorbis (default) or opus depending on what is available on the system.
                    Video stream will be either in vp8 (default) or vp9.


4. Examples[edit | edit source]

Info white.png Information
Do not have big_buck_bunny_720p_H264_AAC_25fps_3400K_short.mp4? Download it from here.

4.1. Media file format conversion[edit | edit source]

Transcode from H264/AAC encapsulated in mp4 container to VP8/Vorbis encapsulated in webm container:

 gst-transcoder-1.0 big_buck_bunny_720p_H264_AAC_25fps_3400K_short.mp4 av_vp8_720p_vorbis.webm webm
Encoding to:
  Container: default: Default profile for files with a .webm extension. Audio stream can be either vorbis (default) or opus depending on what is available on the system. Video stream will be either in vp8 (def)
    - Audio: audio/x-vorbis; audio/x-opus
    - Video: video/x-vp8; video/x-vp9
Starting transcoding...
0:00:03.9 / 0:00:04.0                                                                
DONE.

Verification of encoded video details:

 gst-discoverer-1.0 av_vp8_720p_vorbis.webm
  container #0: WebM
    audio #1: Vorbis
      Channels: 2 (front-left, front-right)
      Sample rate: 44100
      Depth: 32
      Bitrate: 112000
    video #2: VP8
      Width: 1280
      Height: 720
      Depth: 24
      Frame rate: 25/1
      Pixel aspect ratio: 1/1
      Interlaced: false

Transcode from VP8/Vorbis encapsulated in webm container to H264/AAC encapsulated in Quicktime container:

 gst-transcoder-1.0 av_vp8_720p_vorbis.webm av_h264_720p_aac.mp4 mp4
  Container: default: Default profile for files with a .mp4 extension. Suitable for uploading to youtube. (Quicktime)
    - Audio: audio/mpeg, mpegversion=(int)4, base-profile=(string)lc, rate=(int){ 48000, 96000 }, channels=(int)2; audio/mpeg, mpegversion=(int)4, base-profile=(string)lc, rate=(
int){ 48000, 96000 }
    - Video: H.264
    - Audio: MPEG-4 AAC
    - Video: H.264
Starting transcoding...
0:00:09.9 / 0:00:10.0                                                                
DONE.

Verification of encoded video details:

 gst-discoverer-1.0 av_h264_720p_aac.mp4
  container #0: Quicktime
    video #1: H.264 (Main Profile)
      Width: 640
      Height: 480
      Depth: 24
      Frame rate: 30/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 0
      Max bitrate: 0
    audio #2: MPEG-4 AAC
      Language: <unknown>
      Channels: 2 (front-left, front-right)
      Sample rate: 48000
      Depth: 32
      Bitrate: 0
      Max bitrate: 0


4.2. Rescale video track[edit | edit source]

More control can be given to the transcoding process by giving a control string as the last argument. Here is an example with resolution downscaled to 640x480 from original 1280x720 resolution.

 gst-transcoder-1.0 big_buck_bunny_720p_H264_AAC_25fps_3400K_short.mp4 av_vp8_640x480_vorbis.webm "video/webm:video/x-raw,width=640,height=480->video/x-vp8:audio/x-vorbis"

Verification of encoded video details:

 gst-discoverer-1.0 av_vp8_640x480_vorbis.webm
  container #0: WebM
    audio #1: Vorbis
      Language: en
      Channels: 2 (front-left, front-right)
      Sample rate: 44100
      Depth: 32
      Bitrate: 112000
    video #2: VP8
      Width: 640
      Height: 480
      Depth: 24
      Frame rate: 25/1
      Pixel aspect ratio: 853/640
      Interlaced: false