Openai/6957d2e8-b738-8008-987a-09a5d9f29bc8
This conversation was exported from ChatGPT[1]
gpt-5-2-thinking[edit | edit source]
User: ffmpeg cut from video the timestamsp 01:02 - 02:13 + 03:17 - 05:26 + 09:21 - 09:28 + 09:44 - 10:04 into a single video[edit | edit source]
ffmpeg cut from video the timestamsp 01:02 - 02:13 + 03:17 - 05:26 + 09:21 - 09:28 + 09:44 - 10:04 into a single video
Assistant: Here are two good ways to do it.[edit | edit source]
Here are two good ways to do it.
This will cut exactly at those timestamps and stitch into one file.[edit | edit source]
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
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.[edit | edit source]
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
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.
User: actually i want them separate in order to check them[edit | edit source]
actually i want them separate in order to check them also, i want to be able to cut up to miliseconds, if needed
Assistant: Got it — make separate clips, and allow millisecond precision.[edit | edit source]
Got it — make separate clips, and allow millisecond precision.
Use -ss/-to with input seeking (accurate) and re-encode. Put -ss after -i.[edit | edit source]
=====
ffmpeg -i input.mp4 -ss 00:01:02.000 -to 00:02:13.000 \ =====
-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k \
-movflags +faststart clip_01_0102-0213.mp4
=====
ffmpeg -i input.mp4 -ss 00:03:17.000 -to 00:05:26.000 \ =====
-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k \
-movflags +faststart clip_02_0317-0526.mp4
=====
ffmpeg -i input.mp4 -ss 00:09:21.000 -to 00:09:28.000 \ =====
-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k \
-movflags +faststart clip_03_0921-0928.mp4
=====
ffmpeg -i input.mp4 -ss 00:09:44.000 -to 00:10:04.000 \ =====
-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k \
-movflags +faststart clip_04_0944-1004.mp4
Millisecond edits: just change .000 to whatever you need, e.g. 00:03:17.237.
If you must keep original video quality, the only way to be frame/ms-accurate without re-encoding is basically impossible — stream copy can only cut cleanly on keyframes and audio packet boundaries.[edit | edit source]
However, you can do “almost-original” by re-encoding only around cut points, but that’s more complex and usually not worth it unless quality is critical.
With -ss after -i (like above), -to is treated as an end timestamp in the input timeline (works well for human timestamps).[edit | edit source]
If you ever prefer “duration”, use -t instead:
# from 01:02 for 71 seconds
ffmpeg -i input.mp4 -ss 00:01:02.000 -t 00:01:11.000 ...
====
in="input.mp4" ====
ffmpeg -i "$in" -ss 00:01:02.000 -to 00:02:13.000 -c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart clip_01.mp4
ffmpeg -i "$in" -ss 00:03:17.000 -to 00:05:26.000 -c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart clip_02.mp4
ffmpeg -i "$in" -ss 00:09:21.000 -to 00:09:28.000 -c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart clip_03.mp4
ffmpeg -i "$in" -ss 00:09:44.000 -to 00:10:04.000 -c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart clip_04.mp4
If you tell me your input codecs (paste ffprobe -hide_banner -i input.mp4), I can adjust settings to either keep the same FPS/resolution, preserve 5.1 audio, or speed it up with hardware encoding (NVENC/QSV/VAAPI).
User: why are "-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart" needed?[edit | edit source]
why are "-c:v libx264 -crf 20 -preset medium -c:a aac -b:a 160k -movflags +faststart" needed?
Assistant: They’re not required to cut — they’re just the “safe defaults” that make the output widely playable and keep the cut ac…[edit | edit source]
They’re not required to cut — they’re just the “safe defaults” that make the output widely playable and keep the cut accurate.
Here’s what each one does, and what happens if you remove it:
Chooses the video encoder (H.264).[edit | edit source]
- If you don’t specify -c:v, ffmpeg will pick a default encoder for the output container (often still H.264, but not guaranteed).
- You could also use -c:v copy to avoid re-encoding, but then your cut won’t be millisecond-accurate (it’ll snap to keyframes / packet boundaries).
Quality target for x264 (“constant quality” mode). Lower = higher quality/bigger file; higher = lower quality/smaller file.[edit | edit source]
- Not required; if omitted, x264 uses its default CRF (commonly 23), which is a bit lower quality.
- Typical range: 18–23.
Encoding speed vs compression efficiency.[edit | edit source]
- Not required; x264 defaults to medium anyway.
- Slower presets = smaller file for same quality (but take longer).
Re-encodes audio to AAC at 160 kbps.[edit | edit source]
- Not required; ffmpeg might pick AAC anyway, but again not guaranteed.
- If your source audio is already AAC and you don’t need frame-accurate audio boundaries, you might do -c:a copy. But for “exact cuts”, re-encoding audio avoids weird edge cases (missing samples, bad timestamps, concat issues later).
Moves the MP4 “moov atom” to the beginning so the file can start playing before fully downloaded (web-friendly).[edit | edit source]
- Not required for local playback.
- It doesn’t change quality, only file layout.
You said: separate clips + millisecond precision if needed.[edit | edit source]
To cut with ms precision reliably, you generally need to decode and re-encode (at least video), because -c copy can only cut cleanly on keyframes and packet boundaries.
So the shortest “ms-accurate” version is basically:
ffmpeg -i input.mp4 -ss 00:01:02.000 -to 00:02:13.000 -c:v libx264 -c:a aac clip_01.mp4
Everything else (-crf, -preset, -b:a, +faststart) is tuning / compatibility / convenience.
This is still ms-accurate for video (because it re-encodes video), and keeps audio untouched:[edit | edit source]
ffmpeg -i input.mp4 -ss 00:01:02.000 -to 00:02:13.000 -c:v libx264 -crf 20 -preset medium -c:a copy clip_01.mp4
Caveat: if you later concatenate clips, audio-copy can sometimes make concat pickier depending on timestamps/codec parameters.
====
ffmpeg -ss 00:01:02.000 -to 00:02:13.000 -i input.mp4 -c copy clip_01.mp4 ====
Fast, no quality loss — but cuts may be off by up to a few seconds if keyframes are sparse.
If you tell me whether your priority is (1) perfect accuracy or (2) no re-encode / perfect quality, I’ll give you the best exact command for that.
User: i want to both preserve quality and be exact[edit | edit source]
i want to both preserve quality and be exact
Assistant: You can’t have both in the strict, literal sense unless your cut points land exactly on keyframes and audio packet boun…[edit | edit source]
You can’t have both in the strict, literal sense unless your cut points land exactly on keyframes (and audio packet boundaries). Reason: with -c copy ffmpeg is not allowed to invent new frames, so it can only start a clip on an existing keyframe; “millisecond exact” usually requires decoding frames and re-encoding the first GOP.
So you have two practical ways to get what you mean by “preserve quality”:
This is the only “no quality change” method:[edit | edit source]
ffmpeg -ss 00:01:02.000 -to 00:02:13.000 -i input.mp4 -c copy clip_01.mp4
But it will only be exact to the ms if there’s a keyframe exactly at 00:01:02.000 (rare).
You will re-encode, but you can make it lossless (or visually lossless).[edit | edit source]
Per clip:[edit | edit source]
ffmpeg -i input.mp4 -ss 00:01:02.000 -to 00:02:13.000 \
-c:v libx264 -qp 0 -preset veryslow \
-c:a copy \
clip_01_lossless.mkv
Notes:
- -qp 0 = lossless for x264.
- I used MKV because it’s more forgiving; MP4 can be pickier with some codec combos.
- -c:a copy keeps audio unchanged.
=====
ffmpeg -i input.mp4 -ss 00:01:02.000 -to 00:02:13.000 \ =====
-c:v libx264 -crf 16 -preset slow \
-c:a copy \
clip_01.mkv
(You can use CRF 14–18 depending on how paranoid you are.)
If you want the final clips to be -c copy and exact, you can first create a version that has keyframes exactly at your cut points:[edit | edit source]
=====
ffmpeg -i input.mp4 \ =====
-c:v libx264 -qp 0 -preset veryslow \
-force_key_frames "00:01:02.000,00:02:13.000,00:03:17.000,00:05:26.000,00:09:21.000,00:09:28.000,00:09:44.000,00:10:04.000" \
-c:a copy \
keyed.mkv
=====
ffmpeg -ss 00:01:02.000 -to 00:02:13.000 -i keyed.mkv -c copy clip_01.mkv =====
ffmpeg -ss 00:03:17.000 -to 00:05:26.000 -i keyed.mkv -c copy clip_02.mkv
ffmpeg -ss 00:09:21.000 -to 00:09:28.000 -i keyed.mkv -c copy clip_03.mkv
ffmpeg -ss 00:09:44.000 -to 00:10:04.000 -i keyed.mkv -c copy clip_04.mkv
This still “changes” the video once (step 1), but with -qp 0 it’s lossless, so quality is preserved.
If you tell me your source codec/pix_fmt (paste ffprobe -hide_banner -i input.mp4), I can adjust for 10-bit / HDR, H.265, or ensure audio stays compatible with MP4 if you really need MP4 outputs.
User: here is the original video.[edit | edit source]
here is the original video. change your answer to fit its format/properties (in case any change does any improvement)
Assistant: Your source is:[edit | edit source]
Your source is:
- Container: MKV
- Video: H.264 High, 1920×1080, 30 fps, yuv420p, BT.709 / TV range
- Audio: Opus, 48 kHz, stereo
So the “best fit” output (same kind of file) is: MKV + H.264 + Opus, keeping 1080p/30fps/pix_fmt and BT.709 metadata.
Because you want exact cuts and “preserve quality”, the most faithful option is lossless H.264 re-encode (x264 -qp 0). That guarantees exact timestamps (ms) and no generation loss (but files can be bigger).
###[edit | edit source]
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=62:end=133,setpts=PTS-STARTPTS[v];[0:a]atrim=start=62:end=133,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_01_0102-0213.mkv
=====
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \ =====
"[0:v]trim=start=197:end=326,setpts=PTS-STARTPTS[v];[0:a]atrim=start=197:end=326,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_02_0317-0526.mkv
=====
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \ =====
"[0:v]trim=start=561:end=568,setpts=PTS-STARTPTS[v];[0:a]atrim=start=561:end=568,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_03_0921-0928.mkv
=====
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \ =====
"[0:v]trim=start=584:end=604,setpts=PTS-STARTPTS[v];[0:a]atrim=start=584:end=604,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_04_0944-1004.mkv
Just use decimals in the start= / end= values, e.g.:[edit | edit source]
- trim=start=197.237:end=326.041
- atrim=start=197.237:end=326.041
Same commands, just replace -qp 0 -preset veryslow with:[edit | edit source]
- Very high quality: -crf 16 -preset slow
- Still excellent: -crf 18 -preset slow
Example swap:
-c:v libx264 -crf 16 -preset slow
With MKV + Opus (and your file starting at -0.007s), trim/atrim + setpts/asetpts reliably:[edit | edit source]
- cuts exactly (including ms),
- resets each clip to start at t=0 cleanly,
- avoids weird negative start timestamps.
If you want, tell me one clip where you need ms precision (start/end), and I’ll plug those exact values into the command for you.
User: note that i still might need to cut up to miliseconds[edit | edit source]
note that i still might need to cut up to miliseconds
Assistant: Yep — the approach I gave still works fine with milliseconds.[edit | edit source]
Yep — the approach I gave still works fine with milliseconds. You just put decimals on the cut points.
You can do it either as seconds with decimals:[edit | edit source]
- start=62.137:end=133.904
or as HH:MM:SS.mmm (ffmpeg accepts this format too, but inside trim it’s simplest to use seconds).
Say you decide clip 2 should be 03:17.237 → 05:26.041.[edit | edit source]
03:17.237 = 197.237 seconds 05:26.041 = 326.041 seconds
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=197.237:end=326.041,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=197.237:end=326.041,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_02_0317p237-0526p041.mkv
Your video is 30 fps, so frames are spaced about 33.333 ms apart.[edit | edit source]
That means:
- You can type millisecond timestamps,
- but the actual video cut can only land on a frame boundary (≈33ms steps).
- Audio can be trimmed much more finely (sample-level).
If you want, paste the exact ms cut points you end up with (like 01:02.153–02:13.087) and I’ll rewrite all 4 commands with those exact values.
User: first one is 01:02.2 till 02:13.2[edit | edit source]
first one is 01:02.2 till 02:13.2
Assistant: Cool — for clip 1 you want 00:01:02.200 → 00:02:13.200 i.e.[edit | edit source]
Cool — for clip 1 you want 00:01:02.200 → 00:02:13.200 (i.e. 62.2s → 133.2s).
=====
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \ =====
"[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \
-color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_01_0102p2-0213p2.mkv
Quick note: your video is 30 fps, so the video cut will land on the nearest frame boundary (~33.3 ms steps). Audio can still be trimmed more finely.
User: $ ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM P9gZEDOz9eE.mkv" -filtercomplex \[edit | edit source]
$ ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \ "[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \ -c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -profile:v high -level 4.0 \ -color_range tv -colorspace bt709 -color_trc bt709 -color_primaries bt709 \ -c:a libopus -b:a 160k -ar 48000 -ac 2 \ clip_01_0102p2-0213p2.mkv ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100
Input #0, matroska,webm, from 'NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv':
Metadata:
COMPATIBLE_BRANDS: iso6avc1mp41
MAJOR_BRAND : dash
MINOR_VERSION : 0
ENCODER : Lavf58.76.100
Duration: 00:25:49.28, start: -0.007000, bitrate: 2264 kb/s
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1k tbn, 60 tbc (default)
Metadata:
HANDLER_NAME : ISO Media file produced by Google Inc.
VENDOR_ID : [0][0][0][0]
DURATION : 00:25:49.266000000
Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
DURATION : 00:25:49.281000000
Stream mapping:
Stream #0:0 (h264) -> trim Stream #0:1 (opus) -> atrim setpts -> Stream #0:0 (libx264) asetpts -> Stream #0:1 (libopus)
Press [q] to stop, [?] for help x264 [error]: high profile doesn't support lossless [libx264 @ 0x5874e72a1640] Error setting profile high. [libx264 @ 0x5874e72a1640] Possible profiles: baseline main high high10 high422 high444 Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height [libopus @ 0x5874e739cb80] 1 frames left in the queue on closing Conversion failed!
Assistant: That error is because of this combo:[edit | edit source]
That error is because of this combo:
- -qp 0 = lossless
- -profile:v high = forces “High” profile
x264 refuses that: “high profile doesn't support lossless”. For lossless, x264 switches to a different profile (typically High 4:4:4 Predictive) automatically. When you force high, it can’t.
Use this:[edit | edit source]
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_01_0102p2-0213p2.mkv
That will cut exactly (including milliseconds) and keep video lossless.
Even though your pixel format stays yuv420p, a lossless x264 encode often signals a profile like High 4:4:4 Predictive. Some hardware players (TVs/phones) may not like that, even if VLC/mpv do.[edit | edit source]
If you want maximum compatibility while still being visually indistinguishable from the source, do this instead:
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -crf 16 -preset slow -pix_fmt yuv420p -profile:v high -level 4.0 \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_01_0102p2-0213p2.mkv
Just change 62.2 / 133.2 to e.g. 62.237 / 133.041.[edit | edit source]
If you send the ms-precise times for the other 3 clips, I’ll spit out all 4 final commands in the same style.
User: second is 03:17.10 to 05:26.20[edit | edit source]
second is 03:17.10 to 05:26.20
Assistant: Great — that’s:[edit | edit source]
Great — that’s:
- start 00:03:17.100 = 197.1 seconds
- end 00:05:26.200 = 326.2 seconds
Here’s the matching command (same settings as the fixed lossless version — no forced -profile:v high):
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=197.1:end=326.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=197.1:end=326.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_02_0317p10-0526p20.mkv
If you want the filename to reflect milliseconds more clearly, you can rename it after (or I can format it differently).
Send clip 3 + 4 ms times when ready.
User: 09:21:00 till 09:28:30[edit | edit source]
09:21:00 till 09:28:30
Assistant: That’s:[edit | edit source]
That’s:
- start 00:09:21.000 = 561.0 seconds
- end 00:09:28.300 = 568.3 seconds
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=561.0:end=568.3,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=561.0:end=568.3,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_03_0921p00-0928p30.mkv
Send the last interval (09:44–10:04 with ms) and I’ll format that one too.
User: 09:44:10 to 10:04:20[edit | edit source]
09:44:10 to 10:04:20
Assistant: That’s:[edit | edit source]
That’s:
- start 00:09:44.100 = 584.1 seconds
- end 00:10:04.200 = 604.2 seconds
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=584.1:end=604.2,setpts=PTS-STARTPTS[v]; \
[0:a]atrim=start=584.1:end=604.2,asetpts=PTS-STARTPTS[a]" \
-map "[v]" -map "[a]" \
-c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
clip_04_0944p10-1004p20.mkv
If you want, here are all four commands together (same settings) so you can paste once:
in="NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv"
ffmpeg -i "$in" -filter_complex "[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v];[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -c:a libopus -b:a 160k -ar 48000 -ac 2 clip_01_0102p20-0213p20.mkv
ffmpeg -i "$in" -filter_complex "[0:v]trim=start=197.1:end=326.2,setpts=PTS-STARTPTS[v];[0:a]atrim=start=197.1:end=326.2,asetpts=PTS-STARTPTS[a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -c:a libopus -b:a 160k -ar 48000 -ac 2 clip_02_0317p10-0526p20.mkv
ffmpeg -i "$in" -filter_complex "[0:v]trim=start=561.0:end=568.3,setpts=PTS-STARTPTS[v];[0:a]atrim=start=561.0:end=568.3,asetpts=PTS-STARTPTS[a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -c:a libopus -b:a 160k -ar 48000 -ac 2 clip_03_0921p00-0928p30.mkv
ffmpeg -i "$in" -filter_complex "[0:v]trim=start=584.1:end=604.2,setpts=PTS-STARTPTS[v];[0:a]atrim=start=584.1:end=604.2,asetpts=PTS-STARTPTS[a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryslow -qp 0 -pix_fmt yuv420p -c:a libopus -b:a 160k -ar 48000 -ac 2 clip_04_0944p10-1004p20.mkv
User: ok, now in a single ffmpeg command create the combined video of the cuts[edit | edit source]
ok, now in a single ffmpeg command create the combined video of the cuts
Assistant: Here’s a single ffmpeg command that cuts your 4 timestamp ranges with milliseconds and concats them into one output.[edit | edit source]
Here’s a single ffmpeg command that cuts your 4 timestamp ranges (with milliseconds) and concats them into one output.
Combined output (exact cuts, lossless video, MKV + H.264 + Opus)[edit | edit source]
ffmpeg -i "NEA MADALIN E DRAG QUEEN ACUM [P9gZEDOz9eE].mkv" -filter_complex \
"[0:v]trim=start=62.2:end=133.2,setpts=PTS-STARTPTS[v0]; \
[0:a]atrim=start=62.2:end=133.2,asetpts=PTS-STARTPTS[a0]; \
[0:v]trim=start=197.1:end=326.2,setpts=PTS-STARTPTS[v1]; \
[0:a]atrim=start=197.1:end=326.2,asetpts=PTS-STARTPTS[a1]; \
[0:v]trim=start=561.0:end=568.3,setpts=PTS-STARTPTS[v2]; \
[0:a]atrim=start=561.0:end=568.3,asetpts=PTS-STARTPTS[a2]; \
[0:v]trim=start=584.1:end=604.2,setpts=PTS-STARTPTS[v3]; \
[0:a]atrim=start=584.1:end=604.2,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 -preset veryslow -qp 0 -pix_fmt yuv420p \
-c:a libopus -b:a 160k -ar 48000 -ac 2 \
combined_cuts.mkv
If you decide “lossless” is overkill and you want maximum playback compatibility (High profile) while still looking identical to most eyes, swap the video settings to:
-c:v libx264 -crf 16 -preset slow -pix_fmt yuv420p -profile:v high -level 4.0
(Everything else can stay the same.)
User: how much will be duration of the new video?[edit | edit source]
how much will be duration of the new video?
Assistant: Let’s add up each kept segment:[edit | edit source]
Let’s add up each kept segment:
- 01:02.200 → 02:13.200 133.2 − 62.2 = 71.0 s
- 03:17.100 → 05:26.200 326.2 − 197.1 = 129.1 s
- 09:21.000 → 09:28.300 568.3 − 561.0 = 7.3 s
- 09:44.100 → 10:04.200 604.2 − 584.1 = 20.1 s
Total = 71.0 + 129.1 + 7.3 + 20.1 = 227.5 seconds = 3 minutes 47.5 seconds (i.e., 00:03:47.500)
User: do cummulative sum and also convert into minutes so i can see where the cuts are of the total[edit | edit source]
do cummulative sum (and also convert into minutes) so i can see where the cuts are of the total
Assistant: Sure — here are the segment lengths and the cumulative timeline in the new combined video.[edit | edit source]
Sure — here are the segment lengths and the cumulative timeline in the new combined video.
Segment durations[edit | edit source]
- S1 (01:02.200 → 02:13.200): 71.000 s = 1.1833 min = 01:11.000
- S2 (03:17.100 → 05:26.200): 129.100 s = 2.1517 min = 02:09.100
- S3 (09:21.000 → 09:28.300): 7.300 s = 0.1217 min = 00:07.300
- S4 (09:44.100 → 10:04.200): 20.100 s = 0.3350 min = 00:20.100
Cumulative positions in the combined output[edit | edit source]
| Segment | In source | Duration | Starts at (new) | Ends at (new) | End (minutes) | | ------- | ------------------- | --------- | --------------- | ------------- | ------------- | | S1 | 01:02.200–02:13.200 | 71.000 s | 00:00.000 | 01:11.000 | 1.1833 min | | S2 | 03:17.100–05:26.200 | 129.100 s | 01:11.000 | 03:20.100 | 3.3350 min | | S3 | 09:21.000–09:28.300 | 7.300 s | 03:20.100 | 03:27.400 | 3.4567 min | | S4 | 09:44.100–10:04.200 | 20.100 s | 03:27.400 | 03:47.500 | 3.7917 min |
Total combined duration: 227.500 s = 3.7917 min = 03:47.500
User: make the table ascii only[edit | edit source]
make the table ascii only
Assistant:[edit | edit source]
+---------+-------------------------+-----------+----------------+----------------+-------------+
| Segment | In source | Duration | Starts at (new) | Ends at (new) | End (min) |
+---------+-------------------------+-----------+----------------+----------------+-------------+
| S1 | 01:02.200 - 02:13.200 | 01:11.000 | 00:00.000 | 01:11.000 | 1.1833 min |
| S2 | 03:17.100 - 05:26.200 | 02:09.100 | 01:11.000 | 03:20.100 | 3.3350 min |
| S3 | 09:21.000 - 09:28.300 | 00:07.300 | 03:20.100 | 03:27.400 | 3.4567 min |
| S4 | 09:44.100 - 10:04.200 | 00:20.100 | 03:27.400 | 03:47.500 | 3.7917 min |
+---------+-------------------------+-----------+----------------+----------------+-------------+
| TOTAL | | 03:47.500 | | | 3.7917 min |
+---------+-------------------------+-----------+----------------+----------------+-------------+References[edit | edit source]
- ↑ "FFmpeg video cut guide". ChatGPT. Retrieved 2026-01-02.