Joining Two Video Streams using GNonLin

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

Joining Two Video Streams using GNonLin

Sandeep Prakash
Hi All,

I am writing a simple gst application to cut and join 2 video files (both mp4/mpeg-4) using GNonLin.
The pipeline I am constructing in my application goes like this:

gnlcomposition \(name=comp
                 gnlfilesource \(name=video1 start=0 duration=10 media-start=25 media-duration=10        
                                      location=file1.mp4 \)
                 gnlfilesource \(name=video2 start=10 duration=10 media-start=0 media-duration=10
                                      location=file2.mp4 \) \)
comp.src ! ffmpegcolorspace ! tee name=videotee videotee.src0 ! queue ! xvimagesink videotee.src1 !
queue ! identity single-segment=true ! videoscale !
"video/x-raw-yuv, width=(int)800, height=(int)480" ! videorate !
ffenc_mpeg4 ! mux. ffmux_3gp name=mux ! filesink location=out.3gp

This pipeline joins 2 video streams each of 10 seconds. A 10 second chunk is cut in the middle
of each of the files from 25th sec to 35th sec of the 1st file and 0th sec to 10th sec of the 2nd file.

In the above pipeline I am facing an issue like this:
-> When file1.mp4 and file2.mp4 are same or have the same FPS, then the resulting out.3gp
     is properly encoded.
-> When file1.mp4 and file2.mp4 have different FPS, then in the resulting out.3gp, the frames from
     file1.mp4 is encoded properly, but the frames from file2.mp4 is corrupted.
     When played in mplayer following is the o/p:
        [mpeg4 @ 0x18bffe0]hmm, seems the headers are not complete, trying to guess
                                      time_increment_bits
        [mpeg4 @ 0x18bffe0]my guess is 14 bits ;)
        [mpeg4 @ 0x18bffe0]hmm, seems the headers are not complete, trying to guess
                                      time_increment_bits
        [mpeg4 @ 0x18bffe0]my guess is 11 bits ;)
        [mpeg4 @ 0x18bffe0]Error, header damaged or not MPEG4 header (qscale=0)
        [mpeg4 @ 0x18bffe0]header damaged
        Error while decoding frame!
        [mpeg4 @ 0x18bffe0]Error, header damaged or not MPEG4 header (qscale=0)
        [mpeg4 @ 0x18bffe0]header damaged
        Error while decoding frame!
        ****************For all the Frames*****************

Could anyone help me out in this regard and suggest some alternatives.

Other Details:
Gst Version:        0.10.25
GNonLin Version: 0.10.13

Thanks in advance
Sandeep Prakash
Reply | Threaded
Open this post in threaded view
|

Re: Joining Two Video Streams using GNonLin

Edward Hervey
Administrator
On Tue, 2010-06-22 at 23:47 -0700, Sandeep Prakash wrote:

> Hi All,
>
> I am writing a simple gst application to cut and join 2 video files (both
> mp4/mpeg-4) using GNonLin.
> The pipeline I am constructing in my application goes like this:
>
> gnlcomposition \(name=comp
>                  gnlfilesource \(name=video1 start=0 duration=10
> media-start=25 media-duration=10        
>                                       location=file1.mp4 \)
  Remove the '(' ')' after gnlfilesource, they're just properties of
gnlfilesource.
  Also all the start/duration properties are in nanoseconds, so unless
you want to only play 10nanoseconds I'd suggest multiplying those values
by 1 000 000 000

>                  gnlfilesource \(name=video2 start=10 duration=10
> media-start=0 media-duration=10
>                                       location=file2.mp4 \) \)

  Same comment as above

> comp.src ! ffmpegcolorspace ! tee name=videotee videotee.src0 ! queue !
> xvimagesink videotee.src1 !
> queue ! identity single-segment=true ! videoscale !
> "video/x-raw-yuv, width=(int)800, height=(int)480" ! videorate !
> ffenc_mpeg4 ! mux. ffmux_3gp name=mux ! filesink location=out.3gp

  Use mp4mux instead of ffenc_mpeg4.

>
> This pipeline joins 2 video streams each of 10 seconds. A 10 second chunk is
> cut in the middle
> of each of the files from 25th sec to 35th sec of the 1st file and 0th sec
> to 10th sec of the 2nd file.
>
> In the above pipeline I am facing an issue like this:
> -> When file1.mp4 and file2.mp4 are same or have the same FPS, then the
> resulting out.3gp
>      is properly encoded.
> -> When file1.mp4 and file2.mp4 have different FPS, then in the resulting
> out.3gp, the frames from
>      file1.mp4 is encoded properly, but the frames from file2.mp4 is
> corrupted.
>      When played in mplayer following is the o/p:
> [mpeg4 @ 0x18bffe0]hmm, seems the headers are not complete, trying to guess
>                                       time_increment_bits
> [mpeg4 @ 0x18bffe0]my guess is 14 bits ;)
> [mpeg4 @ 0x18bffe0]hmm, seems the headers are not complete, trying to guess
>                                       time_increment_bits
> [mpeg4 @ 0x18bffe0]my guess is 11 bits ;)
> [mpeg4 @ 0x18bffe0]Error, header damaged or not MPEG4 header (qscale=0)
> [mpeg4 @ 0x18bffe0]header damaged
> Error while decoding frame!
> [mpeg4 @ 0x18bffe0]Error, header damaged or not MPEG4 header (qscale=0)
> [mpeg4 @ 0x18bffe0]header damaged
> Error while decoding frame!
>         ****************For all the Frames*****************
>
> Could anyone help me out in this regard and suggest some alternatives.
>
> Other Details:
> Gst Version:        0.10.25
> GNonLin Version: 0.10.13
>
> Thanks in advance
> Sandeep Prakash



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Joining Two Video Streams using GNonLin

Sandeep Prakash
Hi Edward,

Thanks for the quick reply. In fact I have missed some details:
-> I have written a gst application that will simulate the pipeline that I have mentioned.
     (So the brackets were used just to indicate the gnlgnonlin-tutorial-sample5.ccomposition as a bin)
-> The times (start, duration....) are given in nano seconds.

I removed ffmux_3gp from the pipeline, so now I am saving only the elementary stream.
Even now the result is the same, frames from the 2nd file is getting corrupted as
mentioned in my previous post.

Also one more query....Will the order of the elements (identity, ffmpegcolorspace, videorate,
videoscale) matter before the encoder matter in the final outcome??

I have attached the sample application that I am using for this purpose.

Thanks in Advance.
Sandeep Prakash