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

michael mcygogo at gmail.com
Wed Dec 22 14:17:42 CET 2010


Hi Santakivi:
    I have tried your method,
1: I run it like this:
gst-launch videotestsrc num-buffers=200  !
video/x-raw-yuv,width=640,height=480,framerate=30/1 ! ffmpegcolorspace !
ffenc_mpeg4 ! mp4mux ! filesink location=record.mp4
then, I can got a right MP4 file, and I can palyback it. But I record the
video from my capture like this:
gst-launch v4l2src num-buffers=200  !
video/x-raw-yuv,width=640,height=480,framerate=30/1 ! ffmpegcolorspace !
ffenc_mpeg4 ! mp4mux ! filesink location=record.mp4
I also got a file , But it cannot playback , I just get info like this:
Playing record.mp4.
libavformat file format detected.
[mpeg4 @ 0x9958c10]Error, header damaged or not MPEG4 header (f_code=0)
[mpeg4 @ 0x9958c10]header damaged
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9957640]Could not find codec parameters (Video:
mpeg4, yuv420p)
LAVF_header: av_find_stream_info() failed
ISO: File Type Major Brand: ISO/IEC 14496-1 (MPEG-4 system) v2
Quicktime/MOV file format detected.
[mov] Video stream found, -vid 0
VIDEO:  [mp4v]  640x480  24bpp    inf fps    0.0 kbps ( 0.0 kbyte/s)
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
[VO_TDFXFB] Can't open /dev/fb0: Permission denied.
[VO_3DFX] Unable to open /dev/3dfx.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Audio: no sound
Starting playback...
VDec: vo config request - 640 x 480 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
VO: [xv] 640x480 => 640x480 Planar YV12
V:   0.0 200/200 ??% ??% ??,?% 0 0

Exiting... (End of file)

2: I run this:
gst-launch v4l2src !
'video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=30/1' !
ffmpegcolorspace ! x264enc ! avimux ! filesink location=record.avi
But I just got error like this:
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not
negotiate format
Additional debug info:
gstbasesrc.c(2755): gst_base_src_start ():
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Check your filtered caps, if any
Setting pipeline to NULL ...
Freeing pipeline ...
I don't know the fourcc means what, then I modified it to this:
 gst-launch v4l2src !
'video/x-raw-yuv,format=I420,width=320,height=240,framerate=30/1' !
ffmpegcolorspace ! x264enc ! avimux ! filesink location=record.avi
But I just got warning like this:
WARNING: erroneous pipeline: could not link v4l2src0 to ffmpegcsp0
and cannot record the video. And I replaced the format I420 to others just
like YVU9 YV12 and
 so on what I found by: gst-inspect v4l2src, but there is no one can work :(


On Wed, Dec 22, 2010 at 8:31 PM, Santakivi Topi <Topi.Santakivi at digia.com>wrote:

> 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
> >  >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20101222/3c85b1c7/attachment.htm>


More information about the gstreamer-devel mailing list