Page 1 of 1

Play YUV-files from a Python script

Posted: 16 Aug 2019 15:39
by Oussama_Chiha
Hi everyone,
I'am trying to write a python script that plays YUV-files by using the vlc.py. My first script looks like this :

Code: Select all

import vlc instance = vlc.Instance() media = None mediaplayer = vlc.MediaPlayer() # Put the media in the media player mediaplayer.set_rate(24) mediaplayer.video_set_format('I420',1920,1080,2) media = instance.media_new('D:/hdr/Kimono_1920x1080_24.yuv') mediaplayer.set_media(media) mediaplayer.play()

but i get the following error messages :

Code: Select all

rawvid demux error: invalid or no framerate specified. [IMGUTILS @ 0000005db409efc0] Picture size 0x0 is invalid [0000024c620b92c0] avcodec demux error: Could not open D:\hdr\Kimono_1920x1080_24.yuv: Invalid argument
Any tips would be very helpful.
Thank you in advance.

best,
Oussama

Re: Play YUV-files from a Python script

Posted: 19 Aug 2019 20:51
by fossette
As far as I understand, YUV is just a pixel format.

Code: Select all

https://wiki.videolan.org/YUV/
If you don't have a specific codec for your file format, VLC will never know what to do with it. And we see this from the demux error above. I would suggest that you convert your file to a known container like mp4, mkv, avi, etc...

Re: Play YUV-files from a Python script

Posted: 26 Aug 2019 11:27
by chubinou
Hi,

you can try something like this:

Code: Select all

media = instance.media_new("file/rawvid://D:/hdr/Kimono_1920x1080_24.yuv", ":rawvid-fps=24", ":rawvid-chroma=I420", ":rawvid-width=1920", ":rawvid-height=1080")
mediaplayer.video_set_format doesn't specify the input format but the decoding format, to be able to use video frames within your program.