[gst-devel] how to create a pipeline to record video from camera?

Santakivi Topi Topi.Santakivi at digia.com
Wed Dec 22 13:31:35 CET 2010


On 12/22/2010 12:18 PM, michael wrote:
> Now I can record the video to a AVI file with mpeg4 encoding by :
> gst-launch v4l2src ! 'video/x-raw-yuv,width=320,height=240,
> framerate=30/1' ! ffmpegcolorspace ! ffenc_mpeg4! avimux! filesink
> location=record.avi
>
> But I got two issues:
> 1: I want record as a MP4 file, I do it like this:
> gst-launch v4l2src ! 'video/x-raw-yuv,width=320,height=240,
> framerate=30/1' ! ffmpegcolorspace ! ffenc_mpeg4 ! mp4mux! filesink
> location=record.avi
> I can record the video , but when I playback it by mplayer, I got a error:
> Playing ./record.mp4.
> libavformat file format detected.
> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x8741640]moov atom not found
> LAVF_header: av_open_input_stream() failed
> ISO: File Type Major Brand: ISO/IEC 14496-1 (MPEG-4 system) v2

When recording, with the above gst-launch line, do you stop
the pipeline with Ctrl+C..?

It could be that the file container doesn't get fully written
in case of such an interrupt and that's why the clip doesn't play.

For example, if you use this pipeline and
stop it with Ctrl+C, the clip doesn't play:

gst-launch-0.10 videotestsrc ! 
'video/x-raw-yuv,width=320,height=240,framerate=30/1' ! ffmpegcolorspace 
! ffenc_mpeg4 ! mp4mux ! filesink location=test.mp4

But this pipeline produces a valid video file:

gst-launch-0.10 videotestsrc num-buffers=200 ! 
'video/x-raw-yuv,width=320,height=240,framerate=30/1' ! ffmpegcolorspace 
! ffenc_mpeg4 ! mp4mux ! filesink location=test.mp4

>
> 2: I want encode the video to H264, so I do like this:
> gst-launch v4l2src ! 'video/x-raw-yuv,width=320,height=240,
> framerate=30/1' ! ffmpegcolorspace ! x264enc! avimux ! filesink
> location=record.avi

How about adding the format to the caps, e.g .
v4l2src ! 'video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,
framerate=30/1' ! fmpegcolorspace ! x264enc! avimux ! filesink 
location=record.avi ?

BR,
Topi

> But when I run the pipeline I just get the error info like this:
> Setting pipeline to PAUSED ...
> Pipeline is live and does not need PREROLL ...
> Setting pipeline to PLAYING ...
> New clock: GstSystemClock
> ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal
> data flow error.
> Additional debug info:
> gstbasesrc.c(2550): gst_base_src_loop ():
> /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
> streaming task paused, reason not-negotiated (-4)
> Execution ended after 1727716724 ns.
> Setting pipeline to PAUSED ...
> Setting pipeline to READY ...
> Setting pipeline to NULL ...
> Freeing pipeline ...
>
> Some one can help me fix the issues? Tks :)
>
>
> On 12/22/10, Timothy Braun <braunsquared at gmail.com
> <mailto:braunsquared at gmail.com>> wrote:
>  > H264 is encoded with x264enc element.
>  >
>  > Sent from my iPhone
>  >
>  > On Dec 22, 2010, at 3:10 AM, wl2776 <wl2776 at gmail.com
> <mailto:wl2776 at gmail.com>> wrote:
>  >
>  >>
>  >>
>  >> michael young wrote:
>  >>>
>  >>> And now , I want to record the video to a MP4 file with the h264
> encoding
>  >>> format  ,  How can I do ?
>  >>>
>  >>> On Wed, Dec 22, 2010 at 2:26 PM, michael <mcygogo at gmail.com
> <mailto:mcygogo at gmail.com>> wrote:
>  >>>
>  >>>> tks, this is work:   gst-launch v4l2src device=/dev/video0 !
>  >>>> 'video/x-raw-yuv,width=640,height=480,framerate=30/1' ! xvimagesink
>  >>>
>  >>>
>  >>
>  >> Looks like you can't, because h264 encoder is unavailable.
>  >> gst-inspect | grep h264
>  >> doesn't show it.
>  >> However, general idea is to encode, then mux, and then save to a file.
>  >> gst-launch v4l2src device=/dev/video0 !
>  >> 'video/x-raw-yuv,width=640,height=480,framerate=30/1' !  ffenc_mpeg4 !
>  >> mp4mux !filesink location=/home/user/file.
>  >>
>  >> --
>  >> View this message in context:
>  >>
> http://gstreamer-devel.966125.n4.nabble.com/how-to-create-a-pipeline-to-record-video-from-camera-tp3134399p3160261.html
>  >> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>  >>
>  >>
> ------------------------------------------------------------------------------
>  >> Forrester recently released a report on the Return on Investment
> (ROI) of
>  >> Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
>  >> within 7 months.  Over 3 million businesses have gone Google with Google
>  >> Apps:
>  >> an online email calendar, and document program that's accessible
> from your
>  >>
>  >> browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
>  >> _______________________________________________
>  >> gstreamer-devel mailing list
>  >> gstreamer-devel at lists.sourceforge.net
> <mailto:gstreamer-devel at lists.sourceforge.net>
>  >> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>  >
>  >
> ------------------------------------------------------------------------------
>  > Forrester recently released a report on the Return on Investment (ROI) of
>  > Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
>  > within 7 months.  Over 3 million businesses have gone Google with Google
>  > Apps:
>  > an online email calendar, and document program that's accessible from
> your
>  > browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
>  > _______________________________________________
>  > gstreamer-devel mailing list
>  > gstreamer-devel at lists.sourceforge.net
> <mailto:gstreamer-devel at lists.sourceforge.net>
>  > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>  >




More information about the gstreamer-devel mailing list