Decodebin: skip a stream - gstreamer

I want to encode my TV recordings with Gstreamer on a raspberry pi. Inspired by this post, the following code works for a downloaded mkv:
/usr/bin/gst-launch-1.0 -e filesrc location=/media/Seagate/complete/TV/Better\ Call\ Saul/Season\ 01/Better\ Call\ Saul\ -\ S01E10\ -\ Marco.mkv ! decodebin name=demux ! queue ! audioconvert ! audio/x-raw ! audiorate ! avenc_ac3 bitrate=320000 ! mux. mpegtsmux name=mux ! filesink location=/media/Seagate/pvr/Buitenhof_compressed.mkv demux. ! queue ! videoconvert ! deinterlace ! omxh264enc target-bitrate=2000000 control-rate=1 inline-header=true periodicty-idr=250 interval-intraframes=250 ! "video/x-h264,profile=high" ! h264parse ! mux.
The used file has this structure (gst-discoverer output):
Topology:
container: Matroska
audio: AC-3 (ATSC A/52)
video: H.264
Properties:
Duration: 0:49:18.048000000
Seekable: yes
Tags:
container format: Matroska
audio codec: AC-3 audio
language code: und
video codec: H264
minimum bitrate: 7288
bitrate: 24263
maximum bitrate: 9206
My recording software (TVHeadend) outputs this format however:
Topology:
container: Matroska
subtitles: application/x-subtitle-unknown
subtitles: application/x-subtitle-unknown
audio: MPEG-1 Layer 2 (MP2)
audio: AC-3 (ATSC A/52)
audio: MPEG-1 Layer 2 (MP2)
video: H.264
Properties:
Duration: 0:00:06.440000000
Seekable: yes
Tags:
title: Buitenhof
extended comment: DATE_BROADCASTED=2015-05-24 10:05:00
container format: Matroska
audio codec: MPEG 1 Audio, Layer 2
language code: nl
nominal bitrate: 256000
has crc: true
channel mode: stereo
video codec: H264
minimum bitrate: 8972400
bitrate: 16546750
maximum bitrate: 22841600
How can I tell the pipeline to skip the subtitlestreams and use the AC-3 and H264 streams? Ive tried decodebin name=demux demux.audio_01 to no avail. The output is
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Missing element: application/x-subtitle-unknown decoder
Missing element: application/x-subtitle-unknown decoder
It would be nice to have the subtitles included as well, but I can certainly live without them.

The order of the streams had nothing to do with with the problem. There was insufficient video memory available. For a full hd mkv I needed to set the video memory split to 128MB.
One way of doing this is running sudo raspi-config For my raspbian version de video memory split was under the advanced menu. Reboot required.
After this, the command I posted works

Related

Gstreamer pipeline to convert MPEG-4 video to MPEG-TS format

I am trying to write gstreamer pipeline to convert mpeg4 video to mpegts format.
I tried below pipeline but no luck
$ gst-launch-1.0 -e filesrc location=20200818125158_00001.ts.mp4 ! qtdemux name=mdemux ! \
h264parse ! video/x-h264,stream-format=byte-stream ! mpegtsmux name=mux ! filesink location=20200818125158_00001.ts
I get below error when I execute above pipeline
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
WARNING: from element /GstPipeline:pipeline0/GstQTDemux:mdemux: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstQTDemux:mdemux:
failed delayed linking some pad of GstQTDemux named mdem
My Input format
gst-discoverer-1.0 vid.mp4
Analyzing file:///vid.mp4
Done discovering file:///vid.mp4
Topology:
container: Quicktime
video: MPEG-4 Video (Simple Profile)
Properties:
Duration: 0:00:07.267000000
Seekable: yes
Live: no
Tags:
video codec: MPEG-4 video
maximum bitrate: 8400000
bitrate: 298925
encoder: Lavf57.83.100
container format: ISO MP4/M4A
My target format
Topology:
container: MPEG-2 Transport Stream
video: H.264 (High Profile)
Properties:
Duration: 0:00:09.900164000
Seekable: yes
Live: no
Tags:
video codec: H.264
video codec: MPEG-4 video
Your video codec in the source file is MPEG-4 Video. That is different from H.264. Try mpegvideoparse instead of h264parse.
Als video/x-h264,stream-format=byte-stream caps forcing should not be required. The parser and muxer should agree on caps by themselves.
After spending multiple hours and reading more about gstreamer I figured out correct pipeline. Below pipeline works for me
gst-launch-1.0 filesrc location=vid.mp4 ! qtdemux ! avdec_mpeg4 ! X264enc ! mpegtsmux ! filesink location=vid.ts

Use gstreamer to take rtsp input and output rtmp

I'm trying to use gstreamer to go from h264 rtsp input to rtmp output to youtube without re-encoding. in ffmpeg I can simply do a codec copy, but in gstreamer, I can't my pipeline to work:
gst-launch-1.0 -e -v rtspsrc location="rtsp://rtsp/input" protocols=tcp latency=0 ! rtph264depay ! h264parse ! flvmux streamable=true ! rtmpsink sync=true async=true location='rtmp://a.rtmp.youtube.com/live2/key live=true'
I have a feeling it has to do with the audio. I'm receiving aac audio from the rtsp feed but can't figure out how to parse it into the rtmp output.

gstreamer correct pipeline to decode rtsp stream to raw video

using gstreamer-1.10 I have been trying several version of pipeline to decode an RTSP stream that starts as a webrtc connection.
ffprobe reports stream as
Duration: N/A, start: 0.128000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp
Stream #0:1: Video: h264 (Constrained Baseline), yuv420p, 512x288 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 90k tbn, 60 tbc
using variations of the following pipeline
GST_DEBUG=3 gst-launch-1.0 -e rtspsrc location=rtsp://xxx.xxx.xxx.xxx:1935/alpha/Stream1 \
! decodebin name=decode \
decode. \
! x264enc bitrate=512 speed-preset=6 \
! video/x-h264, profile=baseline \
! queue ! mp4mux name=mp4mux ! filesink location=file.mp4 \
decode. ! avenc_aac bitrate=96000 ! aacparse ! queue ! mp4mux.
I get the following errors
0:00:00.299416405 7705 0x7f0d48001e80 WARN default grammar.y:510:gst_parse_no_more_pads:<decode> warning: Delayed linking failed.
0:00:00.299435518 7705 0x7f0d48001e80 WARN default grammar.y:510:gst_parse_no_more_pads:<decode> warning: failed delayed linking some pad of GstDecodeBin named decode to some pad of GstX264Enc named x264enc0
WARNING: from element /GstPipeline:pipeline0/GstDecodeBin:decode: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstDecodeBin:decode:
failed delayed linking some pad of GstDecodeBin named decode to some pad of GstX264Enc named x264enc0
0:00:01.296295371 7705 0x7f0d6402a8f0 WARN basesrc gstbasesrc.c:2951:gst_base_src_loop:<udpsrc3> error: Internal data stream error.
0:00:01.296324999 7705 0x7f0d6402a8f0 WARN basesrc gstbasesrc.c:2951:gst_base_src_loop:<udpsrc3> error: streaming stopped, reason not-linked (-1)
what is the correct pipeline to decode this stream?

gstreamer pipeline only generates mono stream

I'm trying to get UPNP streaming to work. Rygel runs fine, however, all I get is a mono stream, even if the input is stereo. Doing some debugging, I replicated Rygel's gstreamer pipeline with
gst-launch-1.0 pulsesrc device=upnp.monitor num-buffers=100 ! audioconvert ! lamemp3enc target=quality quality=6 ! filesink location=test.mp3
where the problem is also apparent:
mp3info -x test.mp3
...
Media Type: MPEG 1.0 Layer III
Audio: Variable kbps, 44 kHz (mono)
...
Where does this pipeline lose the second channel? How can I debug this?
You never ask for stereo:
gst-launch-1.0 pulsesrc device=upnp.monitor num-buffers=100 ! "audio/x-raw,channels=2" ! audioconvert ! lamemp3enc target=quality quality=6 ! filesink location=test.mp3
Add a -v to the launch-line to see all the caps negotiated on all pads of the pipeline. Look for "channels" and see where it goes from 2 to 1.

Gstreamer : transcoding Matroska video to mp4

The hardware on which we are working on doesnt support playing of mkv files.
So i'm required to transcode Matroska (mkv) video filea to mp4 video file.
As I have understood from the material available online on transcoding,I'm required to do the following :
separate out different streams of mkv file using matroskademux element.
decode the audio and Video streams into raw format using available mkv decoder and
supply this data to the mp4 Muxer element and re-encode to required format.
Could anyone please tell me if I applying right approach?
Any information/link on this would be very helpful.
vikram
Depending on what is in the Matroska file you might not need to decode it at all, just remux.
I assume the video for instance is H264, so just remux that.
Below is an example pipeline for gst-launch for remuxing a file with h264 and mp3.
gst-launch-0.10 -v filesrc location=$file \
! matroskademux name="demux" demux. ! h264parse ! queue \
! mp4mux name=mux ! filesink location=$file._out.mp4 demux. \
! mp3parse ! queue ! mux.`
You can also look at the Transmageddon transcoder (www.linuxrising.org) which should give you want you want.