Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/6957d2e8-b738-8008-987a-09a5d9f29bc8
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: Here are two good ways to do it. === Here are two good ways to do it. ==== This will cut exactly at those timestamps and stitch into one file. ==== <syntaxhighlight lang="bash">ffmpeg -i input.mp4 -filter_complex \ "[0:v]trim=start=62:end=133,setpts=PTS-STARTPTS[v0]; \ [0:a]atrim=start=62:end=133,asetpts=PTS-STARTPTS[a0]; \ [0:v]trim=start=197:end=326,setpts=PTS-STARTPTS[v1]; \ [0:a]atrim=start=197:end=326,asetpts=PTS-STARTPTS[a1]; \ [0:v]trim=start=561:end=568,setpts=PTS-STARTPTS[v2]; \ [0:a]atrim=start=561:end=568,asetpts=PTS-STARTPTS[a2]; \ [0:v]trim=start=584:end=604,setpts=PTS-STARTPTS[v3]; \ [0:a]atrim=start=584:end=604,asetpts=PTS-STARTPTS[a3]; \ [v0][a0][v1][a1][v2][a2][v3][a3]concat=n=4:v=1:a=1[v][a]" \ -map "[v]" -map "[a]" \ -c:v libx264 -crf 20 -preset medium \ -c:a aac -b:a 160k \ -movflags +faststart \ output.mp4 </syntaxhighlight> Timestamps converted to seconds: * 01:02β02:13 β 62β133 * 03:17β05:26 β 197β326 * 09:21β09:28 β 561β568 * 09:44β10:04 β 584β604 : ==== This tries to avoid re-encoding. Often works, but accuracy depends on keyframes. ==== <syntaxhighlight lang="bash">ffmpeg -ss 01:02 -to 02:13 -i input.mp4 -c copy -avoid_negative_ts 1 part1.mp4 ffmpeg -ss 03:17 -to 05:26 -i input.mp4 -c copy -avoid_negative_ts 1 part2.mp4 ffmpeg -ss 09:21 -to 09:28 -i input.mp4 -c copy -avoid_negative_ts 1 part3.mp4 ffmpeg -ss 09:44 -to 10:04 -i input.mp4 -c copy -avoid_negative_ts 1 part4.mp4 printf "file 'part1.mp4'\nfile 'part2.mp4'\nfile 'part3.mp4'\nfile 'part4.mp4'\n" > list.txt ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 </syntaxhighlight> If you tell me whether you want exact cuts (Option A) or fast/no re-encode (Option B), I can tailor the command for your codec/container constraints.
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)