I always been looking for a possibility to make a mp3 and image file to a mp4. I just realized this could easily be done with gstreamer. Thanks for your detailed mail!!<div><br></div><div><br><br><div class="gmail_quote"> On Fri, Mar 2, 2012 at 10:43 AM, Jan Spurný <span dir="ltr"><<a href="mailto:JSpurny@seznam.cz">JSpurny@seznam.cz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I was doing similar thing yesterday - I was trying to overlay a logo on<br>
output from one of ours videofilters. I had several mp4 files with h264 video<br>
and no audio. I finally found 2 solutions, which had worked fine when playing<br>
to xvimagesink, but which failed to stop (and also made everything in video<br>
look somehow slowed) so I was unable to store the resulting video in another<br>
video file.<br>
<br>
Here's what I had:<br>
<br>
* video-input.mp4:<br>
- 640x480, 30000/1001 fps h264 stream in mp4 container with no audio<br>
* logo.png:<br>
- a color 640x480 png image with transparency<br>
(mostly fully transparent, only in top left corner small logo)<br>
<br>
What I wanted:<br>
1) to see if it works using some videosink - and it did<br>
2) to store the result in a file - it worked but it worked forever..<br>
<br>
1) to see if it works (I left out our company's filter)<br>
(a) variant using multifilesrc with caps:<br>
<br>
caps="video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480,framerate=(fraction)30000/1001"<br>
caps_png="image/png,framerate=(fraction)30000/1001"<br>
<br>
logo=logo.png<br>
vid=video-input.mp4<br>
<div class="im"><br>
gst-launch \<br>
videomixer name=mix \<br>
! ffmpegcolorspace \<br>
</div> ! xvimagesink sync=false \<br>
multifilesrc location = $logo caps = $caps_png \<br>
! pngdec \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix. \<br>
filesrc location = $vid \<br>
! qtdemux \<br>
! ffdec_h264 \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix.<br>
<br>
There's probably more 'ffmpegcolorspace's than needed, but it shouldn't<br>
hurt anything.<br>
<br>
(b) variant using imagefreeze:<br>
<br>
caps="video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480,framerate=(fraction)30000/1001"<br>
<br>
logo=logo.png<br>
vid=video-input.mp4<br>
<div class="im"><br>
gst-launch \<br>
videomixer name=mix \<br>
! ffmpegcolorspace \<br>
</div> ! xvimagesink sync=false \<br>
filesrc location = $logo \<br>
! pngdec \<br>
! imagefreeze \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix. \<br>
filesrc location = $vid \<br>
! qtdemux \<br>
! ffdec_h264 \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix.<br>
<br>
And it works too.<br>
<br>
<br>
2) Here comes the problem - storing the result. If you're fine with just<br>
displaying - feel free to ignore the rest. But if anyone sees where my problem<br>
lies I'd be grateful for any help or suggestions.<br>
<br>
So I'm trying to store the video. The pipeline is almost the same (I'll use<br>
the (a) variant):<br>
<br>
caps="video/x-raw-yuv,format=(fourcc)AYUV,width=640,height=480,framerate=(fraction)30000/1001"<br>
caps_png="image/png,framerate=(fraction)30000/1001"<br>
<br>
logo=logo.png<br>
vid=video-input.mp4<br>
res=video-result.mp4<br>
<div class="im"><br>
gst-launch \<br>
videomixer name=mix \<br>
! ffmpegcolorspace \<br>
</div> ! x264enc \<br>
! mp4mux \<br>
! filesink location = $res<br>
multifilesrc location = $logo caps = $caps_png \<br>
! pngdec \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix. \<br>
filesrc location = $vid \<br>
! qtdemux \<br>
! ffdec_h264 \<br>
! ffmpegcolorspace \<br>
! $caps \<br>
! mix.<br>
<br>
It looks fine, it works, but it works forever - the png image part keeps<br>
sending images even after the video part ends. I came up with only one<br>
solution - limiting nuber of frames sent by multifilesrc, so i changed the<br>
line:<br>
multifilesrc location = $logo caps = $caps_png \<br>
to:<br>
multifilesrc location = $logo caps = $caps_png num-buffers = $frames \<br>
<br>
where '$frames' is number of frames in 'video-input.mp4' I have calculated<br>
earlier.<br>
<br>
I was hoping that when both sources have the same framerate it must work.<br>
Well.. it didn't. I got video which was rouhgly 2.6 times longer and part<br>
where mixer's video input was still working was strangely slowed in some<br>
places and then there was just 1 minute of plain png with transparency<br>
(checkerboard almost all over the place). That was differen than it was when I<br>
was using the 'xvimagesink' - with 'xvimagesink' I got the last video-input's<br>
frame "freezed" and even though it was going forever, it at least looked<br>
normal.<br>
<br>
Here are some things that I tried before I gave up and reencoded the<br>
resulting video with mencoder's 'bmovl' feature:<br>
<br>
* queue<br>
- I had put queues everywhere - no effect<br>
<br>
* qos<br>
- I had turned qos everywhere (qos=false) - no effect<br>
<br>
* I tried queues and no-qos with all combinations also with freezeframe<br>
variant - still no effect<br>
<br>
I guess it could work if I just wrote small python program and disconnected<br>
png mixer input on video's eof.. but I didn't had enough time, so I sticked<br>
with mencoder and worse quality (because of another re-encoding).<br>
<br>
I hope it may help someone or someone could help me :)<br>
<br>
<br>
sincerely,<br>
Jan Spurny<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
><br>
> Ok, I added a trailing dot.<br>
> But I got:<br>
><br>
> gstpngdec.c(550): gst_pngdec_task (): /GstPipeline:pipeline0/GstPngDec:pngdec0:<br>
> stream stopped, reason error<br>
><br>
> with the impossibility to make the "preroll".<br>
><br>
> Cheers,<br>
> K.<br>
> -----Messaggio originale-----<br>
> Da: Tim-Philipp Müller <<a href="mailto:t.i.m@zen.co.uk">t.i.m@zen.co.uk</a>><br>
> Inviato il: 01 Mar 2012 - 19:50<br>
> A: <a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
><br>
><br>
> On Thu, 2012-03-01 at 11:40 -0800, kususe wrote:<br>
><br>
> > I want to code a pipeline to overlay an image on a video.<br>
> > First I would like to understand how to implement this one and then to code<br>
> > it.<br>
> > So I attemped with this:<br>
> ><br>
> > gst-launch filesrc location=/home/boss/test/video.mpg ! decodebin2 !<br>
> > vid<br>
> eomixer name=mix ! xvimagesink filesrc location =<br>
> > /home/boss/test/image.png ! pngdec ! ffmpegcolorspace ! mix<br>
> ><br>
> > but I got: "pipeline wrong. No element called mix"<br>
><br>
> I believe the syntax you're looking for is mix. with a trailing dot,<br>
> this basically means "a suitable pad on the element named 'mix'".<br>
><br>
> Cheers<br>
> -Tim<br>
><br>
> _______________________________________________<br>
> gstreamer-devel mailing list<br>
> <a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
><br>
><br>
><br>
> -------------------------------------------------------------------------------<br>
> Valore legale alle tue mail<br>
> InterfreePEC - la tua Posta Elettronica Certificata<br>
> <a href="http://pec.interfree.it" target="_blank">http://pec.interfree.it</a><br>
> -------------------------------------------------------------------------------<br>
><br>
><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><font color="#333333" face="georgia, serif"><b>Michael Niemand</b></font><div><font color="#333333" face="georgia, serif"><b><br></b></font><div><font face="georgia, serif" color="#999999">Albusstr. 17</font></div>
<div><font face="georgia, serif" color="#999999">60313 Frankfurt/M</font></div><div><font face="georgia, serif" color="#999999">Germany</font></div><div><font face="georgia, serif" color="#999999"><br></font></div></div><div>
<div><font face="georgia, serif" color="#999999">Tel.: +49 (0) 69 200 130 60</font></div></div><div><div><font face="georgia, serif" color="#999999">Mobile: +49 (0) 171 645 29 07</font></div><div><font face="georgia, serif" color="#999999"><br>
</font></div><div><font face="georgia, serif"><font color="#999999">eMail: </font><a href="mailto:michael.niemand@gmail.com" target="_blank"><font color="#666666">michael.niemand@gmail.com</font></a></font></div><div><font face="georgia, serif" color="#999999"><a href="mailto:sip%3A1406283@sipgate.de" target="_blank">sip:1406283@sipgate.de</a></font></div>
</div><br>
</div>