Gstreamer x264enc unexpected LOSS when recording video - c++

I recently implement a simple code that can record rtsp stream with changing filesink location dynamically every 10 seconds by referencing this tutorial and this.
Rtsp stream example: rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
However, when I tested an x264enc element, the result videos seems to loss lots of frames.
When I open the recorded videos, they start at, for example, 00:07 instead of 00:00.
This is my code....
test.cpp
Compile:
g++ test.cpp -o test `pkg-config --cflags --libs gstreamer-1.0`
gstreamer version: 1.14.4
g++ version: 8.2.1
Could anybody help this issue ?
EDIT:
I finally solved this problem with the concept :
pipeline = rtspsrc ! rtpjpegdepay ! queue ! bin
bin = (ghost pad) ! jpegdec ! openh264enc ! h264parse ! mp4mux ! filesink
The bin will dynamically remove from pipeline and have a new one added to pipeline every 10 seconds.

Related

Trying to build test-launch.c for gstreamer but fails to build

I am trying to build test-launch.c on my ubuntu machine (i5) with this command:
gcc -o test-launch test-launch.c `pkg-config --cflags --libs gstreamer-rtsp-server-1.0`
but it fails to build. The error message I see is the following:
test-launch.c:(.text+0x170): undefined reference to `gst_rtsp_media_factory_set_enable_rtcp'
I have already installed
libgstrtspserver-1.0
libgstreamer1.0-dev
I am pretty confused and I am wondering if anybody can help me :)
Thank you for reading !
I have the entire build log here.
What version of GStreamer do you have installed? According to the documentation gst_rtsp_media_factory_set_enable_rtcp() is introduced with GStreamer 1.20 which has not yet been released.

How to stream an mp4 filesrc to a rtspsink using GStreamer 0.10

I have to use gstreamer 0.10 and try to stream a mp4 file.
For that I tried
gst-launch-0.10 filesrc location=./test.mp4 ! qtdemux ! queue ! h264parse ! video/x-h264,mapping=/stream ! udpsink rtsp://192.168.192.100:12345/test
and received a warning:
WARNING: erroneous pipeline: no element "h264parse"
How can I stream the file as rtsp stream?
To get h264parse plugin, run
"sudo apt install gstreamer1.0-plugins-bad"
Pipelines
Sender
gst-launch-1.0 filesrc location= ~/file.mp4 ! qtdemux ! queue ! h264parse ! rtph264pay config-interval=10 ! udpsink host=ip_address_to_stream_to port=9999 -v
Receiver
gst-launch-1.0 udpsrc port=9999 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, payload=(int)96, encoding-name=(string)H264" ! rtph264depay ! identity silent=0 ! avdec_h264 ! videoconvert ! ximagesink
Here are the steps that worked for me:
sudo apt-get install libgstrtspserver-1.0 libgstreamer1.0-dev
wget https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-launch.c
gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
./test-launch "filesrc location=<full-path-to-your-mp4-video-file> ! qtdemux ! queue ! h264parse ! rtph264pay name=pay0 pt=96"
At the client machine, to test, I run ffplay or VLC Player:
ffplay rtsp://<your-server-ip>:8554/test

How to rec video from v4l2 and decode to vp9 with gstreamer?

My pipeline
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=640,height=480 ! avdec_vp9 ! filesink location=vid.webm
It will error:
WARNING: erroneous pipeline: could not link v4l2src0 to avdec_vp9-0
Whats wrong?
Pipeline works:
gst-launch-1.0 -v v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! videoconvert ! vp9enc ! webmmux ! filesink location='raw_dual.webm' sync=false

capture image from IP camera through ffmpeg in command line or opencv getting a gray image

Now I have a IP camera. I tried to get a image through ffmpeg (like this : ffmpeg -rtsp_transport tcp -i "my rtsp stream address" -y -f image2 test.jpg ).That's OK! Or I tried to do this through opencv,no problem too.But when I open the stream in vlc,At the same time,I tried to capture the image ,oh,I just got a gray image.
why? if I open the stream in vlc two times,that's also OK! If capturing the image and view the rtsp stream together,just got a gray image.Is the reason of IP camera?normal imagegray image
Try this https://gist.github.com/jamek/1dda2add62b3f7ac415a
g++ -s -o ffmpeg_rtsp rtsp.cpp -lavcodec -lavutil -lswscale -lavformat
Run: ./ffmpeg_rtsp "your rtsp stream address"

Fortran unidentified reference to 'gplot_'

For the past several days I haven't been able to get some Fortran code to compile (note that I am not the author of this code, I downloaded it from the author's web page. It's open source). The main program is called multitaper.f95, and it uses modules called plot and spectra, as well as libraries called mwlib.a and gplot.a. I have multitaper.f95, mwlib.a, gplot.a, plot.mod, and spectra.mod all in the same directory for simplicity. The plot and spectra moduels are made from gplot.f90 and mtspec.f95, respectively, which are also in the same directory as everything else. However, the following command produces an error message:
gfortran multitaper.f95 mtspec.f95 gplot.f90 -o multitaper -L gplot.a mwlib.a
/tmp/ccBJzwYI.o: In function `MAIN__':
multitaper.f95:(.text+0x1111): undefined reference to `gplot_'
multitaper.f95:(.text+0x11af): undefined reference to `gplot_'
multitaper.f95:(.text+0x1246): undefined reference to `gplot_'
collect2: error: ld returned 1 exit status
The contents of gplot.f90 are
module plot
!
! Interface to allow for x or y to be a matrix, and plot each vector
! of y against x. The matrix is given by horizontal vectors, y(:,1) is
! the first vector.
! April 22 2005
! Allowing to also use real(4) and real(8) units.
!
!
! Interface
! dvv vector vs vector
! dvm vector vs matrix
! dmm matrix vs matrix
! rvv real(4) vector vs vector
! rvm real(4) vector vs matrix
! rmm real(4) matrix vs matrix
!
interface gnuplot
module procedure gnuplot_dvv, gnuplot_dvm, gnuplot_dmm, &
gnuplot_rvv, gnuplot_rvm, gnuplot_rmm, &
gnuplot_rv, gnuplot_rm
end interface gnuplot
! The subroutines
contains
!The NEW GNUPlot subroutines
include 'gnuplot.f90'
end module plot
!======================================================================
Gnuplot.f90 has 3700 lines of code, so I won't post it in here. I'm new to Fortran, so I apologize in advance if I'm simply doing something stupid. But, I've been combing the internet for days looking for a solution, but I didn't turn up much. I found this (Fortran compilation error - undefined reference), but multitaper.f95 has a use statement for both spectra and plot, and gplot and the subroutines of gnuplot.f90 are not private. According to https://gcc.gnu.org/wiki/GFortranGettingStarted and http://www.oceanographers.net/forums/showthread.php?378-How-to-make-a-FORTRAN-library my terminal incantation should work, to the best of my knowledge. Just to be sure, I went ahead and tried compiling gplot.f90 and mtspec.f95 separately and giving the object files to the gfortran command instead, but this changed nothing. I also tried changing the file extension of gplot.f90 and gnuplot.f90 to f95, since there shouldn't be anything in there that would result in a version conflict, but once again this produced the same error message. I also tried including the full path to the directory after the -L command, just in case, and got the same error message.
The Makefile doesn't work any better, and I admittedly don't know much about them and how they work. When I run the make command, I get the following error as when I try to compile it manually. The contents of the Makefile are as follows:
# Location of files
DIR = /N/u/rccaton/Quarry/EarthHum/mtspec/program
LIB = /N/u/rccaton/Quarry/EarthHum/mtspec/program
#LIB2 =
# Objects and Libraries
OBJS = $(LIB)/mwlib.a \
$(LIB)/gplot.a \
# /Applications/Absoft/lib/libU77.a
# Module locations
MODS = $(LIB)
MODS2 = $(LIB)
# Compiler
#FC = g95
#FC = f95
FC = gfortran
# Compiler flags
# none
FLAGS =
# debug
#FFLAGS = -g
# Module flag
# Sun Compiler
#MFLAG = -M
# Nag Compiler
#MFLAG = -i
MFLAG = -I
# Absoft Compiler
#MFLAG = -p
# g95 compiler
#MFLAG = -I
MODULE = $(MFLAG)$(MODS) # $(MFLAG)$(MODS2)
# Compile
all : multitaper
%: %.f95 $(OBJS)
$(FC) $(FFLAGS) $(MODULE) $< $(OBJS) -o $#
# Clean
clean :
rm multitaper
At the end of the day it makes to difference to me whether I end up compiling it with the makefile or with manual commands, I just need it to run. Sorry if this was verbose, I just want to provide as much relevant info as possible. Thank you for any assistance you can give.
I would suggest to find which symbol is exported from gplot.a
nm gplot.a | grep -i "gplot"
and change compilers flags accordingly, search for gfortran flags:
-fno-underscoring
-fsecond-underscore
-fcase-*
In case it does not help, ask the author to give you correct MakeFile.