Issue with filesink video writing

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with filesink video writing

Aswin
Hi,

I am using  gstreamer command to create a streamer pipeline & write that to
a video file using filesink. File is being created but the size of the file
is 350 MB for just 20 secs of streaming.  When viewed the mp4 file in VLC,
it dosen't contains any information.

Command used for gstreamer :

/*gst-launch-1.0 v4l2src
extra-controls=c,exposure_auto=1,exposure_absolute=166 ! filesink
location=./test.mp4*/

ffprobe <filename> shows the error as /"Invalid data found when processing
input"/

/*[mov,mp4,m4a,3gp,3g2,mj2 @ 0x555ec27e1080] moov atom not found
test.mp4: Invalid data found when processing input
*/

Please refer to the screenshot attached below for detailed information:

<http://gstreamer-devel.966125.n4.nabble.com/file/t379864/Screenshot_from_2021-02-02_23-31-39.png>



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

gotsring
GStreamer is not like FFMPEG in that you can't set the video format by just
typing the desired file extension. What your current pipeline is doing is
saving the raw camera data into a file, which is why the file is so large
and probably nothing can play it.

What you probably want is this:
gst-launch-1.0 v4l2src extra-controls=c, exposure_auto=1,
exposure_absolute=166 ! videoconvert ! x264enc ! h264parse ! mp4mux !
filesink location=./test.mp4 -e

Explanation:
 - v4l2src
      The source of the video, in this case from an attached webcam or
something?
 - extra-controls=c, exposure_auto=1, exposure_absolute=166
      extra parameters used by v4l2src
 - videoconvert
       I have no idea what the color format of the camera is. It could be
YUV, RGB, grayscale, etc. This says to automatically convert the color to
something that the H.264 encoder (x264enc) can use
 - x264enc
      A software H.264 encoder. If your machine has support for hardware
encoders, you can swap it out here. Just check the output of
"gst-inspect-1.0 | grep 264"
 - h264parse
      Depending on what's using the H.264 stream coming out of the H.264
encoder, it might have to be in a specific format. This tries to format it
so that mp4mux can use it. This might not be necessary.
 - mp4mux
      The muxer that puts the H.264 stream into an MP4 container file
 - filesink location=test.mp4
      The element that actually saves the data to a file on your computer
 - -e
    The option '-e' tells the command line launcher (gst-launch-1.0) to send
an EOS signal through the pipeline when you type ctrl+c. This is because the
MP4 file needs to finalize before it closes. Otherwise, you won't be able to
play the file at all. Some muxers don't require this, like matroskamux
(.mkv). You can swap mp4mux for matroskamux and get the same result,
basically.

I suggest you go through the tutorials before you do anything else. They are
available in c and python.
https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

Aswin
HI,

Thanks for the guidance.

*Using the command : gst-launch-1.0 v4l2src
extra-controls=c,exposure_auto=1,exposure_absolute=330 ! videoconvert !
x264enc ! h264parse ! mp4mux ! filesink location=./test.mp4 -e*

Although this command works, I still have issues with the video file
generated.

This command produces a video of few mb's but still the video file is not
playable/viewable despite using " - -e"  in the end of the command.

Can you please explain how to solve this problem ?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

Aswin
In reply to this post by gotsring
Hi ,

Even though i am able to view the file, the FPS of the of the video file is
too low.

When checked in OPENCV, FPS is only 5.

*
>>> import cv2
cap = cv2.VideoCapture("./test.mp4")
print(cap.get(cv2.CAP_PROP_FPS))

5.169714336356385


print(cap.get(cv2.CAP_PROP_FRAME_COUNT))
350.0*

Any idea why this might be ??



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

gotsring
What is your video source and what is your environment? If you are capturing
a high-resolution camera on something like a raspberry pi, it'll probably be
slow because of limited bandwidth and processing capability.

Does the video play smoothly when just viewing the live feed? Do this with
gst-launch-1.0 v4l2src
extra-controls=c,exposure_auto=1,exposure_absolute=330 ! videoconvert !
autovideosink

You can also try specifying the framerate by adding the framerate cap, as in
gst-launch-1.0 v4l2src
extra-controls=c,exposure_auto=1,exposure_absolute=330 !
video/x-raw,framerate=20/1 ! videoconvert ! autovideosink



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

Aswin
Hi ,

My Video source is : Logitech 310 USB Webcam

Environment  Hardware : JETSON NANO 2 GB DEVELOPER KIT

Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic


autovideosink doesnt works but xvimagesink works fine without any issue and
i am able to control frame rate as well.

autovideosink command that i use :

gst-launch-1.0 v4l2src
extra-controls=c,exposure_auto=1,exposure_absolute=330 ! videoconvert !
autovideosink

produces following error:

Setting pipeline to PAUSED ...
DRM_IOCTL_I915_GEM_APERTURE failed: Invalid argument
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
Pipeline is live and does not need PREROLL ...
Got context from element 'autovideosink0-actual-sink-vaapi':
gst.vaapi.Display=context,
gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\
vaapidisplayglx1";
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstVaapiSink:autovideosink0-actual-sink-vaapi:
Allocation failed
Additional debug info:
../gst/vaapi/gstvaapipluginbase.c(1146):
gst_vaapi_plugin_base_get_input_buffer ():
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstVaapiSink:autovideosink0-actual-sink-vaapi:
failed to bind dma_buf to VA surface buffer
Execution ended after 0:00:00.482486967
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...







--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

gotsring
I think this is a limitation with the Jetson Nano. Cameras that use the MIPI
port are much faster in my experience.

At least for now, you can lower the camera resolution until you get the FPS
you need, like 1280x720 or 640x480. If you have JetPack version 4.4 or
above, you can use nvv4l2camerasrc instead of v4l2src. Also, you might as
well take advantage of the hardware encoders on the Jetson Nano.

This is the pipeline I tested with. I have JetPack 4.3, so I can't use
nvv4l2camerasrc. You might have to change the source device to /dev/video0.
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw, width=640,
height=480 ! nvvidconv ! omxh264enc ! mp4mux ! filesink location=test.mp4 -e


See FAQ here: https://forums.developer.nvidia.com/t/jetson-nano-faq/82953
For more help, you should probably ask in the Nvidia Developer forums.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Issue with filesink video writing

Ardimarines
In reply to this post by Aswin
I'm so excited about the "Back to School" season! It's a fantastic time to reconnect with friends, meet new teachers, and dive into fresh subjects. The energy and enthusiasm that come with starting a new school year are truly invigorating. I'm particularly looking forward to the new challenges and opportunities to learn. For those of us who need a bit of extra help with our assignments, resources like https://essaypro.com/term-paper-help are invaluable. They make the transition back to school smoother and help us stay on top of our studies. Here's to a great year ahead!