VideoHelp Forum




+ Reply to Thread
Results 1 to 5 of 5
  1. 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:
    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                                   : No
    And here's the command that I'm using:
    Code:
    ffmpeg -i "C:\FFmpeg\bin\input.mkv" -ss 01:47:49 -to 01:54:52 -codec copy output.mkv
    However, 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.

    Can somebody please help me figure out the right command to do this properly without messing up everything. Thanks, in advance!
    Quote Quote  
  2. 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.
    Quote Quote  
  3. Originally Posted by ProWo View Post
    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
    The frame rate is still displayed incorrectly, so is the Bits/(Pixel*Frame) value...it's supposed to be 0.152. The duration for the audio and video tracks too is incorrect here. Even if I'm cutting out a large file to around 4~ minutes, by this method, the output should have the metadata of the original file from which it was cut. I then ran the following command to correct the frame rate:
    Code:
    ffmpeg -i input.mkv -r 59.94 -vcodec copy output.mkv
    Not only does this not adjust the frame rate, but it also transcodes the DTS-HD MA track down to Opus. Adding "-acodec copy" to the command changes nothing.
    Last edited by simon744; 8th Jan 2024 at 03:03. Reason: +
    Quote Quote  
  4. 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.
    Quote Quote  
  5. Originally Posted by ProWo View Post
    Your source file seems to have incorrect framerate info.
    I think it is 29.970 fps, not 59.940 fps.
    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.
    Originally Posted by ProWo View Post
    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.
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!