Hi, everyone! I have an MKV file that I want to cut a small portion from, using ffmpeg. Here's the MediaInfo log of it:
And here's the command that I'm using:Code:Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High 4:2:2@L4.1 Format settings : CABAC / 2 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 2 frames Format settings, GOP : M=1, N=36 Codec ID : V_MPEG4/ISO/AVC Duration : 2 h 47 min Bit rate mode : Constant Bit rate : 18.9 Mb/s Nominal bit rate : 20.9 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 59.940 (60000/1001) FPS Original frame rate : 29.970 (30000/1001) FPS Color space : YUV Chroma subsampling : 4:2:2 Bit depth : 8 bits Scan type : Interlaced Scan type, store method : Separated fields Scan order : Top Field First Bits/(Pixel*Frame) : 0.152 Stream size : 22.1 GiB (83%) Default : Yes Forced : No Audio ID : 2 Format : DTS XLL Format/Info : Digital Theater Systems Commercial name : DTS-HD Master Audio Codec ID : A_DTS Duration : 2 h 47 min Bit rate mode : Variable Bit rate : 3 725 kb/s Channel(s) : 6 channels Channel layout : C L R Ls Rs LFE Sampling rate : 48.0 kHz Frame rate : 93.750 FPS (512 SPF) Bit depth : 24 bits Compression mode : Lossless Stream size : 4.37 GiB (16%) Language : English Default : Yes Forced : NoHowever, after cutting, ffmpeg changes the framerate value from the original 59.940 (60000/1001) FPS to 1 428.238 FPS. It adds a full second delay to the audio, and it also changes the Bits/(Pixel*Frame) value from 0.152 to 0.006.Code:ffmpeg -i "C:\FFmpeg\bin\input.mkv" -ss 01:47:49 -to 01:54:52 -codec copy output.mkv
Can somebody please help me figure out the right command to do this properly without messing up everything. Thanks, in advance!
+ Reply to Thread
Results 1 to 5 of 5
-
-
You don't know, where the keyframes are.
You can cut with streamcopy on keyframes only.
Cutting with the ffmpeg command line is extremely tricky, even if you know the exact keyframes.
Use avidemux or clever FFmpeg-GUI for this, the complicated calculations are done by the program. -
Thanks so much, but the thing is that keyframes are exactly what am trying to cut with. I get the exact same result with Clever FFmpeg-GUI that I get with FFmpeg's CLI. Except the file outputted by FFmpeg has worse audio delay (1s+ against -25ms) than the one by Clever FFmpeg-GUI. Here's the MediaInfo log:
Code:Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High 4:2:2@L4.1 Format settings : CABAC / 2 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 2 frames Format settings, GOP : M=1, N=36 Codec ID : V_MPEG4/ISO/AVC Duration : 7 min 3 s Bit rate mode : Constant Bit rate : 18.9 Mb/s Nominal bit rate : 20.9 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 1 428.238 FPS Original frame rate : 29.970 (30000/1001) FPS Color space : YUV Chroma subsampling : 4:2:2 Bit depth : 8 bits Scan type : Interlaced Scan type, store method : Separated fields (2 fields per block) Scan order : Top Field First Bits/(Pixel*Frame) : 0.006 Stream size : 22.1 GiB Default : Yes Forced : No Audio ID : 2 Format : DTS XLL Format/Info : Digital Theater Systems Commercial name : DTS-HD Master Audio Codec ID : A_DTS Duration : 7 min 3 s Bit rate mode : Variable Bit rate : 3 725 kb/s Channel(s) : 6 channels Channel layout : C L R Ls Rs LFE Sampling rate : 48.0 kHz Frame rate : 93.750 FPS (512 SPF) Bit depth : 24 bits Compression mode : Lossless Delay relative to video : -25 ms Stream size : 4.37 GiB Language : English Default : Yes Forced : No
Code:ffmpeg -i input.mkv -r 59.94 -vcodec copy output.mkv
Last edited by simon744; 8th Jan 2024 at 03:03. Reason: +
-
Your source file seems to have incorrect framerate info.
I think it is 29.970 fps, not 59.940 fps.
try the following:
Load it in clever Ffmpeg-GUI, click main, click extract streams, select the videostream only, click extract, set export raw stream, not container.
Then click source, drag & drop the new raw file, enter 29.970 in the fps field.
click multiplex, drag & drop the original source, set the blue videostream and the imported audiostream and click muliplex.
Finally repeat the cut with the new generated file. -
Well, I think that might actually be the field rate, not frame, since the source is interlaced. MediaInfo just happens to usually refer to fields in such cases.
Thanks so much, but doesn't that sound like a little too much work for this? I would've given it a shot, but I don't have 22+ GBs of free hard disk space in my possession at the moment.
Similar Threads
-
Video Editor That Allows Both Cutting on Keyframes and Viewing Waveform
By Spiralagnus in forum Newbie / General discussionsReplies: 0Last Post: 11th Jun 2022, 12:15 -
Cutting untranslated A/V movies scenes without keyframes
By ilrobbi in forum EditingReplies: 2Last Post: 21st Nov 2021, 16:45 -
Clipping Video Using FFMPEG and KeyFrames - Need More KeyFrames?
By Alan2106 in forum EditingReplies: 1Last Post: 3rd Jun 2021, 08:31 -
Cutting Open-GOP H264 videos properly
By andiandi in forum EditingReplies: 14Last Post: 7th Sep 2020, 10:38 -
FFmpeg, and keyframes in vide files
By 2di in forum Video ConversionReplies: 2Last Post: 31st Jul 2020, 02:36