bakoushin / medooze-streamer-demo

Recording audio/video streams from WebRTC using Medooze Media Server and GStreamer or FFmpeg
25 stars 3 forks source link

Video freeze with Gstreamer recording #1

Closed laricheveg closed 3 years ago

laricheveg commented 4 years ago

Hello. Using ffmpeg it runs good and smooth. With Gstreamer it runs, but when you start moving webcam or do some shaking it immediately freeze video. Then - black screen. But it keeps video bitrate. I made some tests with different bitrates, fullhd & hd webcams, using Ubuntu and latest version of Gstreamer, Chrome and Firefox. Could you please advice smth? Maybe we have some option missing?

laricheveg commented 4 years ago

update:

0:00:26.669476622 15010 0x55674c7bf5e0 INFO               h264parse gsth264parse.c:1915:gst_h264_parse_update_src_caps:<h264parse0> resolution changed 1920x1080
0:00:26.669476622 15010 0x55674c7bf5e0 INFO               h264parse gsth264parse.c:1915:gst_h264_parse_update_src_caps:<h264parse0> resolution changed 1920x1080

log appear on shaking from this moment it stops, just audio writing

bakoushin commented 4 years ago

Probably videoscale could help. Instead video. ! queue ! rtpjitterbuffer ! rtph264depay ! h264parse ! mux. use smt linke this video. ! queue ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoscale ! vtenc_h264 ! h264parse ! mux. Could you test?

laricheveg commented 4 years ago

Probably videoscale could help. Instead video. ! queue ! rtpjitterbuffer ! rtph264depay ! h264parse ! mux. use smt linke this video. ! queue ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoscale ! vtenc_h264 ! h264parse ! mux. Could you test?

GStreamer started WARNING: erroneous pipeline: no element "vtenc_h264" GStreamer stopped with exit code 1 (null)

Maybe Gsteamer hasn't been installed correctly?

sudo apt-get install --yes \
>     gstreamer1.0-plugins-{good,bad,ugly} \
>     gstreamer1.0-{libav,tools}
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gstreamer1.0-libav is already the newest version (1.16.2-2~18.04.sav0).
gstreamer1.0-plugins-bad is already the newest version (1.16.2-2.1ubuntu1~18.04.sav0).
gstreamer1.0-plugins-good is already the newest version (1.16.2-1ubuntu1~18.04.sav0).
gstreamer1.0-plugins-ugly is already the newest version (1.16.2-2~18.04.sav0.1).
gstreamer1.0-tools is already the newest version (1.16.2-2~18.04.sav0).
gstreamer1.0-tools set to manually installed.
You might want to run 'apt --fix-broken install' to correct these.
bakoushin commented 4 years ago

Probably you have another h264 encoder, look gst-inspect-1.0 | grep h264

laricheveg commented 4 years ago
gst-inspect-1.0 | grep h264
typefindfunctions: video/x-h264: h264, x264, 264
rtp:  rtph264depay: RTP H264 depayloader
rtp:  rtph264pay: RTP H264 payloader
videoparsersbad:  h264parse: H.264 parser
uvch264:  uvch264mjpgdemux: UVC H264 MJPG Demuxer
uvch264:  uvch264src: UVC H264 Source
libav:  avenc_h264_omx: libav OpenMAX IL H.264 video encoder encoder
libav:  avdec_h264: libav H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder

with avenc_h264_omx it starts, but produce unplayable video file....

laricheveg commented 4 years ago

You also shared link on mediasoup example, their gstreamer config has the same issue. Maybe you could also check on your side? Because i can't left option that gstreamer hasn't been installed/builded proper way.

bakoushin commented 4 years ago

It worked for me with specifying exact scaling size as shown in this StackOverflow answer: video. ! queue ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoscale ! video/x-raw,width=640,height=480 ! vtenc_h264 ! h264parse ! mux..

Don't know if it is possible to achieve dynamic size change as FFmpeg does.

laricheveg commented 4 years ago

The issue that based on webrtc logs, it has actual full hd during all stream.

this h264parse gsth264parse.c:1915:gst_h264_parse_update_src_caps:<h264parse0> resolution changed 1920x1080 Appears just in case of full scene change (for example place web cam in different corner (but if do this very slow it works). I could write for example room with walking person without any issues.

code which you have provided if i am correct, allow us to write for example full hd in low resolution or vice versa. And main point --> we decode h264, change resolution, after that decode it again.

It's wrong by design, since we just wasting CPU usage for nothing, since we would like just to copy any incoming h264 using low CPU usage.

https://stackoverflow.com/questions/25840509/how-to-save-a-rtsp-video-stream-to-mp4-file-via-gstreamer/25894905

bakoushin commented 3 years ago

Closing due to inactivity. Feel free to reopen if you have further questions.