Playing videos using gstreamer on Jetson Nano

Hi,
I’ve been trying to play videos on my jetson nano using gstreamer. Here’s the current situation:

  • I can play most videos using the command gst-play-1.0
  • However, using the totem video player doesn’t work as well with the same videos - much higher resource consumption when i run tegrastats
  • I am unable to play some 4k videos using gst-play-1.0
  • After a few hours of searching I was able to patch together a command to play these 4k videos with audio using gst-launch-1.0 (the ones that didn’t play with gst-play)

Here is the command:
gst-launch-1.0 filesrc location=ko.mkv ! decodebin name=decoder decoder. ! queue ! videoconvert ! autovideosink decoder. ! queue ! audioconvert ! autoaudiosink

Now, this works for me, except one problem. For the life of me I can’t seem to be able to figure out how to add subtitles from a .srt file. Can someone please help me? Thanks.

PS: I would like to have gui as well of course, is there another video player other than totem that is better at this?

hi,
Please refer to this topic:

Thanks @DaneLLL , the above command gives the following error:

Redistribute latency…
Caught SIGSEGV
#0 0x0000007f9996d038 in __GI___poll (fds=0x5576b847c0, nfds=548038750776, timeout=) at …/sysdeps/unix/sysv/linux/poll.c:41
#1 0x0000007f99a7ae08 in () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2 0x0000005576868d60 in ()
Spinning. Please run ‘gdb gst-launch-1.0 29579’ to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

Running the suggested ‘gdb gst-launch-1.0 29579’ gives another error - no such file or directory 29579.

Went through the other topic and tried to patch something together. I tried some basic combinations to try to get textoverlay in there somehow:
Does not work: gst-launch-1.0 textoverlay name=ov ! autovideosink filesrc location=ko.mkv ! decodebin3 ! videoconvert ! ov.video_sink
Works:gst-launch-1.0 filesrc location=ko.mkv ! decodebin3 ! videoconvert ! autovideosink
Does not work:gst-launch-1.0 textoverlay name=ov ! autovideosink filesrc location=ko.mkv ! decodebin3 ! videoconvert ! autovideosink
The last one does not give an error, just displays a black screen. The first one also gives no error, but no display either of any kind.

1 Like

Hi,
Please check if you can run this:

I think it has something to do with the sink, I get the following error when running that command with the file you provided:

Setting pipeline to PAUSED …
ERROR: Pipeline doesn’t want to pause.
ERROR: from element /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0: Could not initialise Xv output
Additional debug info:
xvimagesink.c(1773): gst_xv_image_sink_open (): /GstPipeline:pipeline0/GstXvImageSink:xvimagesink0:
Could not open display (null)
Setting pipeline to NULL …
Freeing pipeline …

Changing xvimagesink to autovideosink did not help.

Hi,
For using xvimagesink, you would need to set:

$ export DISPLAY=:0(or 1)

Please set it and try again.

This made it work for me. However, I still did not manage to patch together a command to make it work for my video.

Hi,
So you can play vsshort-vorbis-subs.mkv by following the post, but cannot play your own video file?

Yes, that is correct, however, as I noted above, my own video runs just fine with the following command:

gst-launch-1.0 filesrc location=ko.mkv ! decodebin3 name=decoder decoder. ! queue ! videoconvert ! autovideosink decoder. ! queue ! audioconvert ! autoaudiosink

I am just not able to combine the two commands in a meaningful way and issue a separate file as a subtitle rather than something embedded within the video. I just don’t know enough about connecting these pipes. It is clear that each of the pieces work on their own.

Hi,
You may share/attach a video file so that we can check and suggest next.

Please see attached:vid.zip (3.3 MB)

Thank you for all the help.

@DaneLLL any additional thoughts here? I spent additional time trying to get this to work but no luck getting subtitles from an external file on a track on my setup.

Hi,
Please try the pipeline:

$ gst-launch-1.0 filesrc location=vid.mkv ! matroskademux name=dem dem.video_0 ! h265parse ! nvv4l2decoder ! nvvidconv ! video/x-raw ! subtitleoverlay name=sub dem.subtitle_0 ! queue ! sub. sub. ! xvimagesink

Hi, This works! How do I add subtitles from an external file here?

And any way I can edit the command to play other files, e.g. mp4, with subtitles?

Hi,

Subtitle display is actually relies on gstreamer native frameworks. We don’t have much experience on it. Suggest you go to gstreamer forum.

This tutorial may help:
https://gstreamer.freedesktop.org/documentation/tutorials/playback/subtitle-management.html?gi-language=c

1 Like