Trimming mp4 video

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

Trimming mp4 video

Pascal Jacquemart

Hi everyone,

I am trying to trim a mp4 video file, but having some issues with
something that simple.

I am running the following pipeline:
  filesrc ! qtdemux ! h264parse ! mp4mux ! filesink

At this stage, it creates an exact clone of the original video

Then I figured out I should do the following:
 - Start the pipeline in PAUSED state
 - Issue a SEEK with FLUSH and KEY_UNIT flags
 - Put the pipeline to PLAYING state
 - Wait for the EOS message

This does not work. The created file seems to be the right size but it
does not play.

After few experiments, I can create the trimmed video but only when I
start the whole pipeline in PLAYING state. Then the file is valid but I
can see the very first few frames of the original video before the
trimmed part.

My sample code is in here: https://trinket.io/python/185bdb1678
I might be missing something obvious?

Thanks,           Pascal



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trimming mp4 video

Vinod Kesti
Reply | Threaded
Open this post in threaded view
|

Re: Trimming mp4 video

Pascal Jacquemart

Hi Vinod,

Thanks but I already read this page twice before posting ;-)

As far as I understand the SEEK call is working fine.
FLUSH is causing the corrupt mp4 file.
gst-discover says "This file contains no playable streams".

I think I need to start the pipeline with fakesink.
And plug the muxer once the seek is done.
But I am looking for guidance before going into something too
complicated.

Thanks,              Pascal


On Mon, 17 Feb 2020 22:20:30 -0600 (CST)
Vinod Kesti <[hidden email]> wrote:

> This has details of seek API.
>
> https://gstreamer.freedesktop.org/documentation/additional/design/seeking.html
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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: Trimming mp4 video

Nicolas Dufresne-5


Le mar. 18 févr. 2020 19 h 15, Pascal Jacquemart <[hidden email]> a écrit :

Hi Vinod,

Thanks but I already read this page twice before posting ;-)

As far as I understand the SEEK call is working fine.
FLUSH is causing the corrupt mp4 file.
gst-discover says "This file contains no playable streams".

I think I need to start the pipeline with fakesink.
And plug the muxer once the seek is done.
But I am looking for guidance before going into something too
complicated.

This method is pretty complicated, it's implemented in NLE elements which are part of gst-editing-services library.

If you are looking for something simpler, use two pipeline, one for the seeking, ending with appsink, and one for muxing, starting with appsrc. You can then operate the initial seek, without disturbing the muxing pipeline. Don't forget to push Eos on the muxing pipeline.


Thanks,              Pascal


On Mon, 17 Feb 2020 22:20:30 -0600 (CST)
Vinod Kesti <[hidden email]> wrote:

> This has details of seek API.
>
> https://gstreamer.freedesktop.org/documentation/additional/design/seeking.html
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trimming mp4 video

Thibault Saunier-4
In reply to this post by Pascal Jacquemart
Hello,

You can use GES[0] for that, or with master `nleurisource` has been fixed to work standalone and you can do:

  gst-launch-1.0 nleurisource uri=file://path/to/file inpoint=$(TRIMMING_POINT) caps=video/x-h264 duration=$(DURATION_YOU_WANT) ! h264parse ! mp4mux ! filesink

Regards,

Thibault


On Mon, Feb 17, 2020 at 11:50 PM Pascal Jacquemart <[hidden email]> wrote:

Hi everyone,

I am trying to trim a mp4 video file, but having some issues with
something that simple.

I am running the following pipeline:
  filesrc ! qtdemux ! h264parse ! mp4mux ! filesink

At this stage, it creates an exact clone of the original video

Then I figured out I should do the following:
 - Start the pipeline in PAUSED state
 - Issue a SEEK with FLUSH and KEY_UNIT flags
 - Put the pipeline to PLAYING state
 - Wait for the EOS message

This does not work. The created file seems to be the right size but it
does not play.

After few experiments, I can create the trimmed video but only when I
start the whole pipeline in PLAYING state. Then the file is valid but I
can see the very first few frames of the original video before the
trimmed part.

My sample code is in here: https://trinket.io/python/185bdb1678
I might be missing something obvious?

Thanks,           Pascal



_______________________________________________
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: Trimming mp4 video

Pascal Jacquemart-3
Great,

It seems to be exactly what I need.
But what if I have several audio tracks in the original file I want to trim?

Thanks,       Pascal

On 19 Feb 2020, at 13:13, Thibault Saunier <[hidden email]> wrote:

Hello,

You can use GES[0] for that, or with master `nleurisource` has been fixed to work standalone and you can do:

  gst-launch-1.0 nleurisource uri=file://path/to/file inpoint=$(TRIMMING_POINT) caps=video/x-h264 duration=$(DURATION_YOU_WANT) ! h264parse ! mp4mux ! filesink

Regards,

Thibault


On Mon, Feb 17, 2020 at 11:50 PM Pascal Jacquemart <[hidden email]> wrote:

Hi everyone,

I am trying to trim a mp4 video file, but having some issues with
something that simple.

I am running the following pipeline:
  filesrc ! qtdemux ! h264parse ! mp4mux ! filesink

At this stage, it creates an exact clone of the original video

Then I figured out I should do the following:
 - Start the pipeline in PAUSED state
 - Issue a SEEK with FLUSH and KEY_UNIT flags
 - Put the pipeline to PLAYING state
 - Wait for the EOS message

This does not work. The created file seems to be the right size but it
does not play.

After few experiments, I can create the trimmed video but only when I
start the whole pipeline in PLAYING state. Then the file is valid but I
can see the very first few frames of the original video before the
trimmed part.

My sample code is in here: https://trinket.io/python/185bdb1678
I might be missing something obvious?

Thanks,           Pascal



_______________________________________________
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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trimming mp4 video

Thibault Saunier-4
Hi,

Good to hear, you will need to add one nleurisource per tracks, this is how nle works.

Regards,

- Thibault

On Wed, Feb 19, 2020 at 5:11 PM Pascal Jacquemart <[hidden email]> wrote:
Great,

It seems to be exactly what I need.
But what if I have several audio tracks in the original file I want to trim?

Thanks,       Pascal

On 19 Feb 2020, at 13:13, Thibault Saunier <[hidden email]> wrote:

Hello,

You can use GES[0] for that, or with master `nleurisource` has been fixed to work standalone and you can do:

  gst-launch-1.0 nleurisource uri=file://path/to/file inpoint=$(TRIMMING_POINT) caps=video/x-h264 duration=$(DURATION_YOU_WANT) ! h264parse ! mp4mux ! filesink

Regards,

Thibault


On Mon, Feb 17, 2020 at 11:50 PM Pascal Jacquemart <[hidden email]> wrote:

Hi everyone,

I am trying to trim a mp4 video file, but having some issues with
something that simple.

I am running the following pipeline:
  filesrc ! qtdemux ! h264parse ! mp4mux ! filesink

At this stage, it creates an exact clone of the original video

Then I figured out I should do the following:
 - Start the pipeline in PAUSED state
 - Issue a SEEK with FLUSH and KEY_UNIT flags
 - Put the pipeline to PLAYING state
 - Wait for the EOS message

This does not work. The created file seems to be the right size but it
does not play.

After few experiments, I can create the trimmed video but only when I
start the whole pipeline in PLAYING state. Then the file is valid but I
can see the very first few frames of the original video before the
trimmed part.

My sample code is in here: https://trinket.io/python/185bdb1678
I might be missing something obvious?

Thanks,           Pascal



_______________________________________________
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
_______________________________________________
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