LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-22-2021, 03:14 AM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Debian (MX)
Posts: 198

Rep: Reputation: Disabled
To extract and get some parts/clips out of a MP4 file to be concatenated into another


How to extract/get some parts/clips out of a MP4 file to be concatenated into another new MP4 file

tried to get/extract out only first 19 seconds, also a part beginning from 32th up to its next 37 seconds, and finally part beginning from 2 min 29th s up to its next 99 seconds, by this:

Code:
$ ffmpeg -t 19 -i Example.mp4 -ss 0:0:32 -t 37 -i Example.mp4 -ss 0:2:29 -t 99 -i Example.mp4  -ss 0:0:0 -c copy ~/Downloads/ExampleOut.mp4
to no avail

Please help out guide the correct one

Last edited by BudiKusasi; 07-22-2021 at 03:21 AM.
 
Old 07-22-2021, 07:40 AM   #2
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a regularly changing third
Posts: 548

Rep: Reputation: Disabled
I would use avidemux to cut the bits you don't want and save the bits left with the new file name. You'd be left with the original file and your new file usually in mkv format.

edit: you need to cut at an i-frame (shown below the screen) to get a good join.

Last edited by petelq; 07-22-2021 at 07:42 AM.
 
Old 07-22-2021, 08:32 AM   #3
mjolnir
Member
 
Registered: Apr 2003
Posts: 774

Rep: Reputation: 87
Quote:
Originally Posted by BudiKusasi View Post
Code:
$ ffmpeg -t 19 -i Example.mp4 -ss 0:0:32 -t 37 -i Example.mp4 -ss 0:2:29 -t 99 -i Example.mp4  -ss 0:0:0 -c copy ~/Downloads/ExampleOut.mp4
to no avail
What results do you get? Error msg, etc.?
 
Old 07-22-2021, 08:23 PM   #4
SW64
Member
 
Registered: May 2014
Distribution: Slackware
Posts: 48

Rep: Reputation: 16
https://trac.ffmpeg.org/wiki/Concatenate

https://superuser.com/questions/1644...oding-using-ff

The inpoint/outpoint examples in the 2nd link are in total seconds. That worked for some situations but it's better if you use 00:00:00.00, which is hh:mm:ss.ms. You can also drop off the hour and just use 00:00.00 (mm:ss.ms), too.

Last edited by SW64; 07-22-2021 at 08:38 PM.
 
Old 07-23-2021, 05:10 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,426
Blog Entries: 10

Rep: Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249Reputation: 5249
Quote:
Originally Posted by BudiKusasi View Post
How to extract/get some parts/clips out of a MP4 file to be concatenated into another new MP4 file

tried to get/extract out only first 19 seconds, also a part beginning from 32th up to its next 37 seconds, and finally part beginning from 2 min 29th s up to its next 99 seconds, by this:

Code:
$ ffmpeg -t 19 -i Example.mp4 -ss 0:0:32 -t 37 -i Example.mp4 -ss 0:2:29 -t 99 -i Example.mp4  -ss 0:0:0 -c copy ~/Downloads/ExampleOut.mp4
to no avail

Please help out guide the correct one
I don't think you can do it all in one command.
Instead:
  • extract separate clips one by one, with -ss and -t
  • use -concat to concatenate the separate clips
  • remember to use '-c copy' if you do not want to re-encode the clips

Also see:
Quote:
Trim first - example:

$ ffmpeg -i output2.mkv -t 00:02:36 -acodec copy -vcodec copy output2-a.mkv

It starts at zero by default (if not, use the -ss option) and uses the first 2min 36s.

Next one needs to create a text file (let's call it list.txt) with a list of files to be concatenated:

file 'output1-a.mkv'
file 'output2-a.mkv'

and then concatenate like this:

$ ffmpeg -f concat -safe 0 -i list.txt -c copy output-full.mkv
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Redirecting output from a file that has been concatenated to a csv file linux_nerd Linux - Software 2 12-03-2015 03:57 PM
recover individual files concatenated with gzip dandini Linux - Software 7 09-04-2011 02:12 PM
adding NULL to a 3 part files that is concatenated..... abharsair Linux - Newbie 10 09-17-2009 07:22 AM
converter for mp4, I-Pods and other portable mp4's ? stefan_rogin2000 Linux - Software 5 03-26-2008 02:43 AM
Validating concatenated cin inputs (C++) Swakoo Programming 5 05-17-2007 09:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration