Copying sections of an mp4 by time stamp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Copying sections of an mp4 by time stamp

James Sundquist
I'm looking to copy sections of example.mp4

Ideally this would be by time stamp.  Perhaps the time stamps are noted in
a text file.

Example as minutes:second
0:20 - 0:40 as a an mp4 with title "Exercise 1"
0:40 - 0:59 as an mp4 with title "Exercise 2"
0:20 - 0:59 as an mp4 with title "Primary Exercises"

Any suggestions appreciated.  I'm hoping to repeat this process with a
dozen movies. Thanks.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Copying sections of an mp4 by time stamp

Jim DeLaHunt-2
On 2020-08-26 19:50, James Sundquist wrote:

> I'm looking to copy sections of example.mp4
>
> Ideally this would be by time stamp.  Perhaps the time stamps are noted in
> a text file.
>
> Example as minutes:second
> 0:20 - 0:40 as a an mp4 with title "Exercise 1"
> 0:40 - 0:59 as an mp4 with title "Exercise 2"
> 0:20 - 0:59 as an mp4 with title "Primary Exercises"
>
Hello, James. Fortunately, this is pretty easy to do. Have you read the
FFmpeg documentation[1] yet?

Look up the main command line options `-ss` and `-to` [2]. If your input
file is `example.mp4`, then the commands will be like:

ffmpeg -i example.mp4 -ss 0:20 -to 0:40 exercise_1.mp4
ffmpeg -i example.mp4 -ss 0:40 -to 0:59 exercise_2.mp4
ffmpeg -i example.mp4 -ss 0:20 -to 0:59 primary_exercises.mp4

Note that `-i example.mp4` says that `example.mp4` is the input video.
The extension `.mp4` tells FFmpeg that the file is MP4 format. `-ss
0:20` means, "discard the input video until 0 minutes, 20 seconds in,
then start copying to the output video from there. `-to 0:40` means stop
copying to the output video when the input video is 0 minutes, 40
seconds in.  There is documentation on this time duration syntax[3].

I do not know of a convenient way to do all these cuts in one invocation
of FFmpeg. There may be a way I don't know about. When I had to solve a
similar problem, I invoked FFmpeg once for each cut.  I suggest you use
a spreadsheet to generate this command invocation from your list of
start time durations, end time durations, and output file names. Then
paste the command invocations from the spreadsheet into the command
line. The command line will run them one after the other.

When you say "time stamps", I assume you mean the elapsed time from the
start of the input video to your desired moment in the video. The
documentation calls them "time durations", and means something else by
"time stamps".

[1] http://ffmpeg.org/documentation.html
[2] http://ffmpeg.org/ffmpeg-all.html#Main-options
[3] http://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax

Does this work for you?
        —Jim DeLaHunt, software engineer, Vancouver, Canada


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Copying sections of an mp4 by time stamp

Toni Cambronero Garcia
This link will explain to you all the secrets of coping sections of videos:
https://youtu.be/hElDsyuAQDA?t=729

Gracias por su atención.

[image: foto+carn%C3%A9+copy.png]
Antonio Cambronero García
46470 Catarroja (Valencia)

[hidden email]
*☎** 696 01 41 41*




El jue., 27 ago. 2020 a las 6:53, Jim DeLaHunt (<[hidden email]>)
escribió:

> On 2020-08-26 19:50, James Sundquist wrote:
> > I'm looking to copy sections of example.mp4
> >
> > Ideally this would be by time stamp.  Perhaps the time stamps are noted
> in
> > a text file.
> >
> > Example as minutes:second
> > 0:20 - 0:40 as a an mp4 with title "Exercise 1"
> > 0:40 - 0:59 as an mp4 with title "Exercise 2"
> > 0:20 - 0:59 as an mp4 with title "Primary Exercises"
> >
> Hello, James. Fortunately, this is pretty easy to do. Have you read the
> FFmpeg documentation[1] yet?
>
> Look up the main command line options `-ss` and `-to` [2]. If your input
> file is `example.mp4`, then the commands will be like:
>
> ffmpeg -i example.mp4 -ss 0:20 -to 0:40 exercise_1.mp4
> ffmpeg -i example.mp4 -ss 0:40 -to 0:59 exercise_2.mp4
> ffmpeg -i example.mp4 -ss 0:20 -to 0:59 primary_exercises.mp4
>
> Note that `-i example.mp4` says that `example.mp4` is the input video.
> The extension `.mp4` tells FFmpeg that the file is MP4 format. `-ss
> 0:20` means, "discard the input video until 0 minutes, 20 seconds in,
> then start copying to the output video from there. `-to 0:40` means stop
> copying to the output video when the input video is 0 minutes, 40
> seconds in.  There is documentation on this time duration syntax[3].
>
> I do not know of a convenient way to do all these cuts in one invocation
> of FFmpeg. There may be a way I don't know about. When I had to solve a
> similar problem, I invoked FFmpeg once for each cut.  I suggest you use
> a spreadsheet to generate this command invocation from your list of
> start time durations, end time durations, and output file names. Then
> paste the command invocations from the spreadsheet into the command
> line. The command line will run them one after the other.
>
> When you say "time stamps", I assume you mean the elapsed time from the
> start of the input video to your desired moment in the video. The
> documentation calls them "time durations", and means something else by
> "time stamps".
>
> [1] http://ffmpeg.org/documentation.html
> [2] http://ffmpeg.org/ffmpeg-all.html#Main-options
> [3] http://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
>
> Does this work for you?
>         —Jim DeLaHunt, software engineer, Vancouver, Canada
>
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Copying sections of an mp4 by time stamp

James Sundquist
Thank you Jim and Toni,

This is awesome.  Thank you both for the fantastic links.  Really helpful.
Excited to wrap my head around this.

On Thu, Aug 27, 2020 at 2:22 AM Toni Cambronero García <[hidden email]>
wrote:

> This link will explain to you all the secrets of coping sections of videos:
> https://youtu.be/hElDsyuAQDA?t=729
>
> Gracias por su atención.
>
> [image: foto+carn%C3%A9+copy.png]
> Antonio Cambronero García
> 46470 Catarroja (Valencia)
>
> ✉ [hidden email]
> *☎** 696 01 41 41*
>
>
>
>
> El jue., 27 ago. 2020 a las 6:53, Jim DeLaHunt (<[hidden email]
> >)
> escribió:
>
> > On 2020-08-26 19:50, James Sundquist wrote:
> > > I'm looking to copy sections of example.mp4
> > >
> > > Ideally this would be by time stamp.  Perhaps the time stamps are noted
> > in
> > > a text file.
> > >
> > > Example as minutes:second
> > > 0:20 - 0:40 as a an mp4 with title "Exercise 1"
> > > 0:40 - 0:59 as an mp4 with title "Exercise 2"
> > > 0:20 - 0:59 as an mp4 with title "Primary Exercises"
> > >
> > Hello, James. Fortunately, this is pretty easy to do. Have you read the
> > FFmpeg documentation[1] yet?
> >
> > Look up the main command line options `-ss` and `-to` [2]. If your input
> > file is `example.mp4`, then the commands will be like:
> >
> > ffmpeg -i example.mp4 -ss 0:20 -to 0:40 exercise_1.mp4
> > ffmpeg -i example.mp4 -ss 0:40 -to 0:59 exercise_2.mp4
> > ffmpeg -i example.mp4 -ss 0:20 -to 0:59 primary_exercises.mp4
> >
> > Note that `-i example.mp4` says that `example.mp4` is the input video.
> > The extension `.mp4` tells FFmpeg that the file is MP4 format. `-ss
> > 0:20` means, "discard the input video until 0 minutes, 20 seconds in,
> > then start copying to the output video from there. `-to 0:40` means stop
> > copying to the output video when the input video is 0 minutes, 40
> > seconds in.  There is documentation on this time duration syntax[3].
> >
> > I do not know of a convenient way to do all these cuts in one invocation
> > of FFmpeg. There may be a way I don't know about. When I had to solve a
> > similar problem, I invoked FFmpeg once for each cut.  I suggest you use
> > a spreadsheet to generate this command invocation from your list of
> > start time durations, end time durations, and output file names. Then
> > paste the command invocations from the spreadsheet into the command
> > line. The command line will run them one after the other.
> >
> > When you say "time stamps", I assume you mean the elapsed time from the
> > start of the input video to your desired moment in the video. The
> > documentation calls them "time durations", and means something else by
> > "time stamps".
> >
> > [1] http://ffmpeg.org/documentation.html
> > [2] http://ffmpeg.org/ffmpeg-all.html#Main-options
> > [3] http://ffmpeg.org/ffmpeg-utils.html#time-duration-syntax
> >
> > Does this work for you?
> >         —Jim DeLaHunt, software engineer, Vancouver, Canada
> >
> >
> > _______________________________________________
> > ffmpeg-user mailing list
> > [hidden email]
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > [hidden email] with subject "unsubscribe".
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Copying sections of an mp4 by time stamp

Moritz Barsnick
In reply to this post by James Sundquist
On Wed, Aug 26, 2020 at 19:50:31 -0700, James Sundquist wrote:
> I'm looking to copy sections of example.mp4
>
> Ideally this would be by time stamp.  Perhaps the time stamps are noted in
> a text file.
>
> Example as minutes:second
> 0:20 - 0:40 as a an mp4 with title "Exercise 1"
> 0:40 - 0:59 as an mp4 with title "Exercise 2"
> 0:20 - 0:59 as an mp4 with title "Primary Exercises"

In addition to the other answers, I have also had good success with the
"segment" muxer and its "segment_times" option, which takes a list of
cut ("segmentation") points in time. (I also add the "-reset_timestamps
1" option, to make each individual file's timestamps begin at 0.)

$ ffmpeg -i input.mp4 -c copy -f segment -segment_times 20,40,59,... -reset_timestamps 1 output.%02d.mp4

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".