FFMPEG h.264 stream to VLC from raw YUV444 produces black screen and audio noise

1

I am piping raw YUV444 640x480 frames to ffmpeg from inside a C++ program using stdout (Pipe format: pipe<-Y<-U<-V whole frames each). ffmpeg encodes them using h.264 and streams the video via UDP to an IP of my choice.

When I am not streaming and saving the video on the recording device as -mp4 file with ffmpeg, everything works - But when I stream over the network and try to receive in VLC, the stream is received and the playing timer under the video screen runs,but the image is black, none of the video is displayed. Also I have some crackling sounds on my audio output. The raw video does not have an audio track.

My ffmpeg settings are as follows:

ffmpeg -y -loglevel verbose -f rawvideo -r 25 -c:v rawvideo -pix_fmt yuv444p -s 640x480 -i - -c:v libx264 -preset superfast -framerate 25 -f mpegts udp://192.168.150.1:20001

in VLC (GUI), I just use "open network stream" with udp://@:20001. The port is open, I tested it with a simple dummy sender/receiver. Almost the same cli arguments for the video recording lead to a perfectly playable video when writing to a file and downloading it:

ffmpeg -y -loglevel verbose -f rawvideo -r 25 -c:v rawvideo -pix_fmt yuv444p -s 640x480 -i - -c:v libx264 -preset superfast -framerate 25 video.mp4

If I try to stream the same recorded video using

ffmpeg -i video.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://192.168.150:20001

I get a black screen again, like above.

The VLC log output identifies my stream as mp3, so maybe stream type recognition is to blame. But why?

Here are the ffmpeg console output and the VLC log.

What am I doing wrong?

PS: Moved this question over here from Stack Overflow because it was not getting any answers, old unanswered duplicate is deleted.

GerbGerb

Posted 2018-12-04T13:06:38.073

Reputation: 21

Do other players receive it ok? – Gyan – 2018-12-04T17:55:27.720

Wohoo! You were totally on the right track. I tried SMPlayer and PotPlayer (What a name) and PotPlayer could play it! The question remains: Why doesn't VLC? – GerbGerb – 2018-12-04T20:16:16.027

I'll look into it tomorrow. – Gyan – 2018-12-04T20:39:58.533

Update: I tried also with OpenCV(Python3)'s VideoCapture. This produces a highly corrupted image and a ton of "error while decoding". Could it be that VLC and OpenCV use the same decoder, which has problems with h.264? – GerbGerb – 2018-12-06T10:05:38.423

Appears to be related to this: https://trac.videolan.org/vlc/ticket/21024. Downgrade VLC or use another player.

– Gyan – 2018-12-06T11:10:13.543

Downgrading did the Trick, I am baffled that this is necessary, hopefully the issue gets fixed soon. Thanks for the help! – GerbGerb – 2018-12-07T18:26:11.013

Answers

1

While the underlying issue has not been resolved, @Gyans hints helped me to solve my problem. Using other players (PotPlayer) or an older version of VLC got the stream display to work, and that is all I needed.

GerbGerb

Posted 2018-12-04T13:06:38.073

Reputation: 21