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?
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.