Merge video and audio to file

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

Merge video and audio to file

schousda
Hello,

i'm creating a timelapse video. It's a h.264 MP4 Video. To do this i use the following code:
___________________________________________________________________________
sudo gst-launch-1.0 multifilesrc location=/home/pi/Timelapse/image_%04d.jpg index=0 \
caps="image/jpeg,framerate=\(fraction\)24/1" ! \
jpegdec ! \
queue ! \
omxh264enc target-bitrate=15000000 control-rate=variable ! \
video/x-h264,width=1920,height=1080,framerate=24/1,profile=high ! \
h264parse ! \
mp4mux faststart=true ! \
filesink location=/home/pi/Timelapse/video.mp4
___________________________________________________________________________

Later i want to add some audio, for example from a mp3file, but i can make the source the format you recommend, to this video. But i have no idea how i can do this.

As i'm useing a Raspberry Pi i use h.264 because the hardware supports this to do the job fast.

Please help me to find the correct pipeline. Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

Vivia Nikolaidou
[...] ! mp4mux name=m faststart=true !\
 filesink location=/home/pi/Timelapse/video.mp4 \
filesrc location=/home/pi/Timelapse/audio.mp3 !\
 queue !\
 mpegaudioparse !\
 m.    (including the dot)

Note that there's a space, not an exclamation mark, between filesink
and the other filesrc.

On 2 September 2016 at 18:47, schousda <[hidden email]> wrote:

> Hello,
>
> i'm creating a timelapse video. It's a h.264 MP4 Video. To do this i use the
> following code:
> ___________________________________________________________________________
> sudo gst-launch-1.0 multifilesrc location=/home/pi/Timelapse/image_%04d.jpg
> index=0 \
> caps="image/jpeg,framerate=\(fraction\)24/1" ! \
> jpegdec ! \
> queue ! \
> omxh264enc target-bitrate=15000000 control-rate=variable ! \
> video/x-h264,width=1920,height=1080,framerate=24/1,profile=high ! \
> h264parse ! \
> mp4mux faststart=true ! \
> filesink location=/home/pi/Timelapse/video.mp4
> ___________________________________________________________________________
>
> Later i want to add some audio, for example from a mp3file, but i can make
> the source the format you recommend, to this video. But i have no idea how i
> can do this.
>
> As i'm useing a Raspberry Pi i use h.264 because the hardware supports this
> to do the job fast.
>
> Please help me to find the correct pipeline. Thanks.
>
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Merge-video-and-audio-to-file-tp4679383.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
Hello,

Thanks for your help.
I added your lines, so it looks like this:

sudo gst-launch-1.0 multifilesrc location=/home/pi/Timelapse/image_%04d.jpg index=0 \
caps="image/jpeg,framerate=\(fraction\)24/1" ! \
jpegdec ! \
queue ! \
omxh264enc target-bitrate=15000000 control-rate=variable ! \
video/x-h264,width=1920,height=1080,framerate=24/1,profile=high ! \
h264parse ! \
mp4mux faststart=true ! \
filesink location=/home/pi/Timelapse/video.mp4 \
filesrc location=/home/pi/Timelapse/example_short.mp3 ! \
queue ! \
mpegaudioparse ! \
m.

But when i run it, i get this error:

No sink-element named "null" - omitting link

Could you please help again?
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

Vivia Nikolaidou
Hi,

If you notice, you have to give a name to mp4mux:

mp4mux name=m faststart=true

That's the meaning of the last "m." line: this should link to the
element that we named m. The last dot basically means "try to
automatically find a sink to use". In more complicated use cases,
you'd specify a sink name, like m.audio_0, but here you can leave it
blank as "m."

Hope it helps!

On 3 September 2016 at 00:22, schousda <[hidden email]> wrote:

> Hello,
>
> Thanks for your help.
> I added your lines, so it looks like this:
>
> sudo gst-launch-1.0 multifilesrc location=/home/pi/Timelapse/image_%04d.jpg
> index=0 \
> caps="image/jpeg,framerate=\(fraction\)24/1" ! \
> jpegdec ! \
> queue ! \
> omxh264enc target-bitrate=15000000 control-rate=variable ! \
> video/x-h264,width=1920,height=1080,framerate=24/1,profile=high ! \
> h264parse ! \
> mp4mux faststart=true ! \
> filesink location=/home/pi/Timelapse/video.mp4 \
> filesrc location=/home/pi/Timelapse/example_short.mp3 ! \
> queue ! \
> mpegaudioparse ! \
> m.
>
> But when i run it, i get this error:
>
> No sink-element named "null" - omitting link
>
> Could you please help again?
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Merge-video-and-audio-to-file-tp4679383p4679392.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
Sorry, i did'nt notice the change in this line.
Now it works.

Thank you a lot for your help.
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
In reply to this post by Vivia Nikolaidou
Hello,
as i wrote, the video with sound is creating now.
but at the bottom of the video i get a green bar of about 40-60 pixels height.
Why does this happen and is there a solution for that?

Thanks again.
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

Vivia Nikolaidou
Hello,

What are the dimensions of your original pictures? Are they 1920x1080?
If not, you'll need to add a videoscale element into your pipeline.

Best regards,

Vivia

On 4 September 2016 at 02:51, schousda <[hidden email]> wrote:

> Hello,
> as i wrote, the video with sound is creating now.
> but at the bottom of the video i get a green bar of about 40-60 pixels
> height.
> Why does this happen and is there a solution for that?
>
> Thanks again.
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Merge-video-and-audio-to-file-tp4679383p4679403.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
Hello,

my pictures are 1920x1080, so this should not be a problem.
In the meantime i found out, that there is maybe an issue with the omx encoder because 1080 is not ratio to 16 1080/16=67.5).
Tonight i will test the pipeline with source pictures of 1920x1088 (1088/16=68). Maybe this helps.
But of course this is not a standard video format, so i will run into further problems maybe.

Is there an alternative h.264 encoder?

Thanks a lot for your help.
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

Vivia Nikolaidou
Hi,

Which platform are you running it on? You can use x264enc, but it
isn't hardware-accelerated - if you are running your pipeline on a
Raspberry Pi, for example, it will be too slow.

On 5 September 2016 at 15:53, schousda <[hidden email]> wrote:

> Hello,
>
> my pictures are 1920x1080, so this should not be a problem.
> In the meantime i found out, that there is maybe an issue with the omx
> encoder because 1080 is not ratio to 16 1080/16=67.5).
> Tonight i will test the pipeline with source pictures of 1920x1088
> (1088/16=68). Maybe this helps.
> But of course this is not a standard video format, so i will run into
> further problems maybe.
>
> Is there an alternative h.264 encoder?
>
> Thanks a lot for your help.
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Merge-video-and-audio-to-file-tp4679383p4679427.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
Hello,

yes, im running it on my Raspberry Pi. The hardware acceleration is the reason why i want to use gstreamer.
I already tried other tools before, but they worked way to slow or had problems with the limited ressources.
Reply | Threaded
Open this post in threaded view
|

Re: Merge video and audio to file

schousda
In reply to this post by Vivia Nikolaidou
I changed the image and video resolution to 1920x1088.
Now it works. But of course its not a standard video resolution. Still better than nothing.