VideoHelp Forum

+ Reply to Thread
Results 1 to 30 of 30
Thread
  1. Hi everyone, I'm recording video and audio for my podcast and I'm in the process of automating all the steps I can to make it easier for the editor in post production.

    We're 4 animators in different studios. We're streaming the live recording on my Twitch channel to profit visibility so we're using OBS to create virtual cameras used in OBS Ninja for the live stream. We're recording locally x264 video stream with pcm_s24le lossless audio in a MKV container. Both editors are using Premiere Pro and Audition. Since MKV isn't supported in Premiere I created this batch file to split the audio stream and remux the video stream in a mp4 container.

    Code:
    @echo off & setlocal enabledelayedexpansion
    for %%v in ("*.mkv") do (
      set FileName=%%v
      set name=!FileName:~0,-4!
    
      set outname=C:\Users\Freeman\Videos\!name!
      echo Remuxing: !name! to !outname!
    
      ffmpeg -i "!FileName!" -map 0:v -c copy "!outname!.mp4" -map 0:a:0 -c copy "!outname!_0.wav"
    )
    pause
    It's almost working but I'm getting the following error

    [mp4 @ 0000024ee3b2f040] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
    Image
    [Attachment 60505 - Click to enlarge]


    As you can see on the screenshot above the audio stream is longer than the video. How can I fix this?

    Thanks!

    * I'm using the latest ffmpeg build as of today.
    Don't lose your nights, they're half your life.
    Quote Quote  
  2. I suspect the cause is variable frame rate (VFR)

    Even if you recorded CFR in OBS, the container timebase between MKV and MP4 is different and that can lead to jitter in the timestamps.

    Newer PP versions handle VFR better, but it's still not great

    (Some point releases of PP could actually import MKV)


    1) check that you recorded CFR in the original. An easy check method is mediainfo view=>text, or you can use ffmpeg vfrdet

    If not, you need to re-encode and convert to CFR . If you start with VFR, and it's more than minimally VFR (min/max deviations are more than tiny), it's not really "fixable" because you're missing frames. Converting to CFR inserts duplicate frames at approximately the correct places to keep everything in sync and duration matched up

    2) check what framerate PP "thinks" the imported MP4 framerate is - e.g. if it was supposed to be 30.0 FPS, and it's 29.564 or some weird number, the issue is likely VFR interpretation in the remuxed MP4

    2b) if that's the case use mp4fpsmod to fix the timestamps to make it CFR, reimport (that is, if your case was the minimally variable case, such as timestamp jitter. If it was the massive deviations and frame drop VFR, then you need to re-encode)
    Quote Quote  
  3. Originally Posted by poisondeathray View Post
    Even if you recorded CFR in OBS, the container timebase between MKV and MP4 is different and that can lead to jitter in the timestamps.
    Is there another container that wouldn't cause timebase misinterpretation?

    Originally Posted by poisondeathray View Post
    1) check that you recorded CFR in the original. An easy check method is mediainfo view=>text, or you can use ffmpeg vfrdet
    As you can see the remuxed file is VBR instead of CBR, why does ffmpeg doesn't keep it as a CBR file? Can I add something in my command to force CBR? Also it's really strange that to get 60 FPS I need to set 59.94 FPS in the OBS options. If I set 60 FPS in OBS options I get 60.119 FPS. I still have the error in ffmepg and it's still not synced in Premiere.

    Here's the MediaInfo for a 15 seconds test

    General
    Unique ID : 199157449624611465003073718188215867930 (0x95D4545FE0C8DCF98A3B20DA8FE39A1A)
    Complete name : C:\Users\Freeman\Videos\2021-08-31 15-22-02.mkv
    Format : Matroska
    Format version : Version 4
    File size : 23.5 MiB
    Duration : 15 s 449 ms
    Overall bit rate : 12.7 Mb/s
    Writing application : Lavf58.29.100
    Writing library : Lavf58.29.100
    ErrorDetectionType : Per level 1

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : V_MPEG4/ISO/AVC
    Duration : 15 s 449 ms
    Bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 60.000 FPS
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.080
    Stream size : 18.8 MiB (80%)
    Writing library : x264 core 161 r3020 d198931
    Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=24 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=10000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Default : Yes
    Forced : No
    Color range : Limited
    Color primaries : BT.709
    Transfer characteristics : BT.709
    Matrix coefficients : BT.709

    Audio
    ID : 2
    Format : PCM
    Format settings : Little / Signed
    Codec ID : A_PCM/INT/LIT
    Duration : 15 s 82 ms
    Bit rate mode : Constant
    Bit rate : 2 304 kb/s
    Channel(s) : 2 channels
    Sampling rate : 48.0 kHz
    Bit depth : 24 bits
    Stream size : 4.14 MiB (18%)
    Default : Yes
    Forced : No
    MediaInfo of the same file remuxed by ffmpeg

    General
    Complete name : C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4
    Format : MPEG-4
    Format profile : Base Media
    Codec ID : isom (isom/iso2/avc1/mp41)
    File size : 19.3 MiB
    Duration : 15 s 465 ms
    Overall bit rate : 10.5 Mb/s
    Writing application : Lavf59.4.102

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 15 s 465 ms
    Source duration : 15 s 430 ms
    Bit rate : 10 000 kb/s
    Maximum bit rate : 10.5 Mb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Variable
    Frame rate : 59.940 (59940/1000) FPS
    Minimum frame rate : 31.250 FPS
    Maximum frame rate : 16 000.000 FPS
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.080
    Stream size : 19.3 MiB (100%)
    Source stream size : 19.3 MiB (100%)
    Writing library : x264 core 161 r3020 d198931
    Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=24 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=10000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Color range : Limited
    Color primaries : BT.709
    Transfer characteristics : BT.709
    Matrix coefficients : BT.709
    mdhd_Duration : 15465
    Codec configuration box : avcC
    Originally Posted by poisondeathray View Post
    2b) if that's the case use mp4fpsmod to fix the timestamps to make it CFR, reimport (that is, if your case was the minimally variable case, such as timestamp jitter. If it was the massive deviations and frame drop VFR, then you need to re-encode)
    Reading this link it seems complicated to me. Any help would be greatly appreciated to add a line of code to my actual code. I can add PATH for qaac64.exe and refalac64.exe but I don't understand the command to add in my .bat file.

    Is there a way to add MKV codec in Premiere Pro? I remember I've successfully added Prores codecs in my install of PP.

    Thanks for helping!
    Don't lose your nights, they're half your life.
    Quote Quote  
  4. Originally Posted by G22 View Post
    As you can see the remuxed file is VBR instead of CBR, why does ffmpeg doesn't keep it as a CBR file? Can I add something in my command to force CBR?
    VFR = variable frame rate
    VBR = variable bit rate

    We're talking about VFR here

    First try adding
    -video_track_timescale 60

    The timebase ffmpeg uses for mp4 when you remux a 60/1 fps input is 16k for some reason . This should make it 60K . On a small 60/1 FPS test, it corrected the issue for me


    Originally Posted by G22 View Post
    Originally Posted by poisondeathray View Post
    Even if you recorded CFR in OBS, the container timebase between MKV and MP4 is different and that can lead to jitter in the timestamps.
    Is there another container that wouldn't cause timebase misinterpretation?

    I don't know what the options are in obs, bit a transport stream (.ts, .m2ts, .mts) or MOV would be ideal because you can store the uncompressed audio as well. You wouldn't have to remux anything, or import 2 streams. Open source MP4 muxers do not support uncompressed audio


    Is there a way to add MKV codec in Premiere Pro? I remember I've successfully added Prores codecs in my install of PP.
    No, but Adobe added it for a few versions, then took it away

    (There are workaround, where you can frameserve in, but more hassle than you probably want to do, because it's decoded in another application, and there's lots of overhead)


    If the -video_track_timescale 60 does not solve the issue for you (and check in PP) , I'll walk you through mp4fpsmod
    Quote Quote  
  5. Originally Posted by poisondeathray View Post
    First try adding
    -video_track_timescale 60

    The timebase ffmpeg uses for mp4 when you remux a 60/1 fps input is 16k for some reason . This should make it 60K . On a small 60/1 FPS test, it corrected the issue for me
    Not sure I added the parameter correctly, is that correct? Looks like it's correcting something but it's not working.

    ffmpeg -i "!FileName!" -video_track_timescale 60 -map 0:v -c copy "!outname!.mp4" -map 0:a:0 -c copy "!outname!_0.wav"
    Still having the same issue, here's the remuxing log https://pastebin.com/UD6u4gyw

    Originally Posted by poisondeathray View Post
    I don't know what the options are in obs, bit a transport stream (.ts, .m2ts, .mts) or MOV would be ideal because you can store the uncompressed audio as well. You wouldn't have to remux anything, or import 2 streams. Open source MP4 muxers do not support uncompressed audio
    The .ts, .m2ts, .mts and .mov formats gets corrupted if OBS crash. MKV have the advantage to protect the file from breaking upon crash.

    And yes I really don't like the MP4 container especially for podcasting where you need uncompressed audio for post-prod.

    https://www.autokroma.com/Influx/Download

    I've found out this software in beta, I'll try it to see.
    Don't lose your nights, they're half your life.
    Quote Quote  
  6. Maybe slightly different input test files, but my input MKV was 60/1 fps CFR, and the streamcopy output MP4 was VFR too, but less deviation between min/max

    Frame rate mode : Variable
    Frame rate : 60.000 FPS
    Minimum frame rate : 57.762 FPS
    Maximum frame rate : 62.500 FPS

    So that suggests timestamp jitter on my file, and that's correctable by replacing the timestamps using mp4fpsmod

    But you have some massive deviation with the max fps, usually that indicates some other problems, so I'm not sure if it will work for you but you should try mp4fpsmod anyways
    Minimum frame rate : 31.250 FPS
    Maximum frame rate : 16 000.000 FPS


    For mp4fpsmod, the author used to have binaries compiled on old homepage, but I think they took google sites down

    I attached a mirror

    You'd use it like this

    Code:
    "mp4fpsmod" --fps 0:60 -o "output.mp4" "input.mp4"
    It supports inplace editing (overwrite input file, instead of a 2nd file), but I wouldn't recommend it when you're just testing things out
    Image Attached Files
    Quote Quote  
  7. If it still does not work, another option is to skip ffmpeg. Use mkvextract, mp4box or lsmash in a batch
    Quote Quote  
  8. Originally Posted by poisondeathray View Post
    Code:
    "mp4fpsmod" --fps 0:60 -o "output.mp4" "input.mp4"
    It supports inplace editing (overwrite input file, instead of a 2nd file), but I wouldn't recommend it when you're just testing things out
    I'm not tech enough to add it to my batch file. I've tried many combinations but it's not working. Can you guide me? I've tried that

    Code:
    @echo off & setlocal enabledelayedexpansion
    for %%v in ("*.mkv") do (
      set FileName=%%v
      set name=!FileName:~0,-4!
    
      set outname=C:\Users\Freeman\Videos\!name!
      echo Remuxing: !name! to !outname!
    
      mp4fpsmod --fps 0:60 -o "!outname!.mp4" "!name!.mp4"
    
    )
    pause
    The google site seems still up https://sites.google.com/site/qaacpage/
    Last edited by G22; 3rd Sep 2021 at 00:00.
    Don't lose your nights, they're half your life.
    Quote Quote  
  9. qaac is an audio encoder

    qaac - CLI QuickTime AAC/ALAC encoder
    https://github.com/nu774/qaac

    The original cabinet page is down - and you want mp4fpsmod.exe, not qaac64.exe

    eg. you can check the wayback machine , it looks very different and has compiled binaries

    https://web.archive.org/web/20191008021708/https://sites.google.com/site/qaacpage/cabinet
    Quote Quote  
  10. Originally Posted by poisondeathray View Post
    qaac is an audio encoder

    qaac - CLI QuickTime AAC/ALAC encoder
    https://github.com/nu774/qaac

    The original cabinet page is down - and you want mp4fpsmod.exe, not qaac64.exe

    eg. you can check the wayback machine , it looks very different and has compiled binaries

    https://web.archive.org/web/20191008021708/https://sites.google.com/site/qaacpage/cabinet
    Sorry I've noticed after replying and I edited my message but too late. I've succesfully installed it and added the path to windows.

    I've tried the code like that

    Code:
    @echo off & setlocal enabledelayedexpansion
    for %%v in ("*.mkv") do (
    set FileName=%%v
    set name=!FileName:~0,-4!
    
    set outname=C:\Users\Freeman\Videos\!name!
    echo Remuxing: !name! to !outname!
    
    mp4fpsmod --fps 0:60 -o "!outname!.mp4" "!name!.mp4"
    
    )
    pause
    I'm getting this output error

    Remuxing: 2021-08-31 15-22-02 to C:\Users\Freeman\Videos\2021-08-31 15-22-02
    Reading MP4 stream...
    Done reading
    Saving MP4 stream...
    libmp4v2: mp4v2::impl::MP4File::Open: open(C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4) failed (..\..\mp4v2\src\mp4file.cpp,371)
    Press any key to continue . . .
    Thanks for your help, I really appreciate it. The other podcast animators appreciate it too!
    Don't lose your nights, they're half your life.
    Quote Quote  
  11. I do not see ffmpeg in that command . mp4fpsmod cannot read a mkv . How are you taking the mkv and remuxing to mp4 in that current version ?

    Before you waste time writing a batch. Try 1 file first with that workflow. I don't have high hopes when the mix/max fps deviation rates when processed with ffmpeg are so large
    Quote Quote  
  12. Originally Posted by poisondeathray View Post
    I do not see ffmpeg in that command . mp4fpsmod cannot read a mkv . How are you taking the mkv and remuxing to mp4 in that current version ?

    Before you waste time writing a batch. Try 1 file first with that workflow. I don't have high hopes when the mix/max fps deviation rates when processed with ffmpeg are so large
    Well I've made 2 batch files, one for remuxing the MKV to MP4

    Code:
    @echo off & setlocal enabledelayedexpansion
    for %%v in ("*.mkv") do (
      set FileName=%%v
      set name=!FileName:~0,-4!
    
      set outname=C:\Users\Freeman\Videos\!name!
      echo Remuxing: !name! to !outname!
    
      ffmpeg -i "!FileName!" -map 0:v -c copy "!outname!.mp4" -map 0:a:0 -c copy "!outname!.wav"
    
    )
    pause
    and one for fixing the mp4 timebase

    Code:
    @echo off & setlocal enabledelayedexpansion
    for %%v in ("*.mkv") do (
      set FileName=%%v
      set name=!FileName:~0,-4!
    
      set outname=C:\Users\Freeman\Videos\!name!
      echo Remuxing: !name! to !outname!
    
      mp4fpsmod --fps 0:60 -o "!outname!.mp4" "!name!.mp4"
    
    )
    pause
    Thanks for your help!
    Don't lose your nights, they're half your life.
    Quote Quote  
  13. Should the 2nd one be *.mp4 ? for %%v in ("*.mkv") looks for mkv, not mp4. mp4fpsmod only works on mp4
    Quote Quote  
  14. Originally Posted by poisondeathray View Post
    Should the 2nd one be *.mp4 ? for %%v in ("*.mkv") looks for mkv, not mp4. mp4fpsmod only works on mp4
    Damn I feel stupid. I changed it and still getting an error

    Code:
    Remuxing: 2021-08-31 15-22-02 to C:\Users\Freeman\Videos\2021-08-31 15-22-02
    Reading MP4 stream...
    Done reading
    Saving MP4 stream...
    libmp4v2: mp4v2::impl::MP4File::Open: open(C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4) failed (..\..\mp4v2\src\mp4file.cpp,371)
    Press any key to continue . . .
    Don't lose your nights, they're half your life.
    Quote Quote  
  15. Originally Posted by G22 View Post

    Code:
    Remuxing: 2021-08-31 15-22-02 to C:\Users\Freeman\Videos\2021-08-31 15-22-02
    Reading MP4 stream...
    Done reading
    Saving MP4 stream...
    libmp4v2: mp4v2::impl::MP4File::Open: open(C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4) failed (..\..\mp4v2\src\mp4file.cpp,371)
    Press any key to continue . . .
    Not sure

    Check if "C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4" is a valid file

    Try it from the commandline on a single file first

    Code:
    "mp4fpsmod" --fps 0:60 -o ""C:\Users\Freeman\Videos\output.mp4" "C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4"

    This simple batch works for me

    Code:
    for %%a in ("*.mp4") do "mp4fpsmod" --fps 0:60 -o "mp4fpsmod_%%~na.mp4" "%%a"
    
    pause
    Quote Quote  
  16. Originally Posted by poisondeathray View Post
    Originally Posted by G22 View Post

    Code:
    Remuxing: 2021-08-31 15-22-02 to C:\Users\Freeman\Videos\2021-08-31 15-22-02
    Reading MP4 stream...
    Done reading
    Saving MP4 stream...
    libmp4v2: mp4v2::impl::MP4File::Open: open(C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4) failed (..\..\mp4v2\src\mp4file.cpp,371)
    Press any key to continue . . .
    Not sure

    Check if "C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4" is a valid file

    Try it from the commandline on a single file first

    Code:
    "mp4fpsmod" --fps 0:60 -o ""C:\Users\Freeman\Videos\output.mp4" "C:\Users\Freeman\Videos\2021-08-31 15-22-02.mp4"

    This simple batch works for me

    Code:
    for %%a in ("*.mp4") do "mp4fpsmod" --fps 0:60 -o "mp4fpsmod_%%~na.mp4" "%%a"
    
    pause
    Finally got mp4fpsmod to work but unfortunately it's not fixing it correctly as you though it would. At least now MediaInfo sees it as a 60 FPS timecode instead of the 59.94 FPS from the .mp4 remux file.

    The remux.mp4 file is the one created by ffmpeg from the .mkv and the output.mp4 file is the files outputted by mp4fpsmod.

    Image
    [Attachment 60614 - Click to enlarge]


    Thank you for helping!
    Don't lose your nights, they're half your life.
    Quote Quote  
  17. When posting my last comment I though that the results didn't made any sense. How could a MKV file at 60 fps remuxed in MP4 could become a 59.94 FPS file. So I went and recorded 4 short clips with OBS Studio and found out the MKV encoder acting strangely. I'll paste the MediaInfo interesting informations and what was the original recording format.

    MKV(x264/pcm_s24le) - 59.94 FPS
    https://www110.zippyshare.com/v/QvLQStGn/file.html

    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : V_MPEG4/ISO/AVC
    Duration : 1 min 0 s
    Bit rate : 9 374 kb/s
    Nominal bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 60.000 FPS

    Full MediaInfo https://pastebin.com/Ctkv1vAw
    MKV(x264/pcm_s24le) - 60 FPS
    https://www84.zippyshare.com/v/N44PIPZS/file.html

    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : V_MPEG4/ISO/AVC
    Duration : 1 min 0 s
    Bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 60.119 FPS

    Full MediaInfo https://pastebin.com/zSRRccYZ
    MP4(x264/aac) - 59.94 FPS
    https://www84.zippyshare.com/v/wMcyNFeY/file.html

    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 1 min 0 s
    Bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 59.940 (60000/1001) FPS

    Full MediaInfo https://pastebin.com/BkshFD6N
    MP4(x264/aac) - 60 FPS
    https://www84.zippyshare.com/v/Fh3sKuzq/file.html

    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 1 min 0 s
    Bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 60.000 FPS

    Full MediaInfo https://pastebin.com/GcwJSZPU
    As you can see the framerate isn't respected recording in MKV format where 59.94 FPS ends up as 60 FPS and 60 FPS ends up as 60.119 FPS.

    That's maybe a reason that when I remux those MKV files with ffmpeg they get back at 59.94 FPS or 60 FPS.

    What the h*** is going on!?

    -> Post on OBS forum asking what is going on
    Last edited by G22; 6th Sep 2021 at 16:22.
    Don't lose your nights, they're half your life.
    Quote Quote  
  18. I think your 1st link is wrong ; it's the same link as the 3rd video

    Are the MP4 versions remuxed with ffmpeg, default settings ?
    Quote Quote  
  19. Originally Posted by poisondeathray View Post
    I think your 1st link is wrong ; it's the same link as the 3rd video

    Are the MP4 versions remuxed with ffmpeg, default settings ?
    Sorry I've just edited the first link.

    The 4 files are untouched recordings from OBS. Nothing have been remuxed in ffmpeg.
    Don't lose your nights, they're half your life.
    Quote Quote  
  20. Looking at mkv-60.mkv, if your clip is 1min , why is the audio longer ? You can verify in PP, and audio editors

    If you extract the elementary streams (e.g. mkvextract) this will discard the buggy timecodes completely. You can then remux with MP4box with the proper framerate.

    But you don't even have to do that , PP can import elementary AVC stream directly

    When you do that, you can see the audio is longer than the video, but it looks in sync. But you need a longer test sample to check for drift and sync. If it's in sync for a 3-4 hours sample, that's all you really need, right ? Unless you're doing longer recordings, then check that duration

    3604 is the last frame in PP, which checks with elementary stream parsers - so it's correct.
    Quote Quote  
  21. Originally Posted by poisondeathray View Post
    Looking at mkv-60.mkv, if your clip is 1min , why is the audio longer ? You can verify in PP, and audio editors

    If you extract the elementary streams (e.g. mkvextract) this will discard the buggy timecodes completely. You can then remux with MP4box with the proper framerate.

    But you don't even have to do that , PP can import elementary AVC stream directly

    When you do that, you can see the audio is longer than the video, but it looks in sync. But you need a longer test sample to check for drift and sync. If it's in sync for a 3-4 hours sample, that's all you really need, right ? Unless you're doing longer recordings, then check that duration

    3604 is the last frame in PP, which checks with elementary stream parsers - so it's correct.
    This makes sense. I'm currently trying to record a 3 hours test and will import it in PP and let you know if there's a desync.

    In the meantime could you explain me the whole 60.119 FPS thing? Why is this?

    Thank you!
    Don't lose your nights, they're half your life.
    Quote Quote  
  22. Originally Posted by G22 View Post

    In the meantime could you explain me the whole 60.119 FPS thing? Why is this?
    Normally it's jitter in the timestamps, because of the MKV timebase 1/1000. ie. It's not precise enough . 1ms

    If you extract the timestamps, the delta PTS varies between frame. You cannot divide 1/60 (~ 0.0166666...) evenly into that timebase resulting in an exact value each frame. So each entry rounds up or down.

    A "normal" 60/1 FPS CFR in MP4 looks like this: the delta PTS is constant, and predictable

    Code:
    # timecode format v2
    0.00
    16.67
    33.33
    50.00
    66.67
    83.33
    100.00
    116.67
    133.33
    150.00
    166.67
    183.33
    200.00
    216.67
    .
    .

    MKV container specs only allow 1ms, so values are rounded to the nearest ms . So you get a delta PTS of 16 or 17, and that is variable.

    Code:
    0
    17
    33
    50
    67
    83
    100
    117
    133
    I'm not sure how mediainfo calculates how it declares "constant", but in actual recordings, sometimes at the beginning or end, there are duplicate frames as recording "warms up" so that can cause deviation. Also, frame drops can cause deviation from the constant pattern . Any deviation is technically variable frame rate



    But of we take mkv-60.mkv, track 1 timestamps are really buggy, it looks like this

    Code:
    # timestamp format v2
    0
    21
    43
    64
    85
    107
    128
    149
    171
    192
    213
    235
    256
    .
    .
    delta is 21,22.. etc. and at the end there are repeats. But ~ 21 delta PTS average means the fps is ~47 , not 60

    1/60 =~ 0.016666.. . So you should be seeing 16.7 ms for each entry (again round up, round down) , but the point 21 suggests a different framerate

    There might be something else going on with the audio timestamps, but this is abnormal
    Last edited by poisondeathray; 6th Sep 2021 at 18:24.
    Quote Quote  
  23. Originally Posted by poisondeathray View Post
    Originally Posted by G22 View Post

    In the meantime could you explain me the whole 60.119 FPS thing? Why is this?
    Normally it's jitter in the timestamps, because of the MKV timebase 1/1000. ie. It's not precise enough . 1ms

    If you extract the timestamps, the delta PTS varies between frame. You cannot divide 1/60 (~ 0.0166666...) evenly into that timebase resulting in an exact value each frame. So each entry rounds up or down.

    A "normal" 60/1 FPS CFR in MP4 looks like this: the delta PTS is constant, and predictable

    Code:
    # timecode format v2
    0.00
    16.67
    33.33
    50.00
    66.67
    83.33
    100.00
    116.67
    133.33
    150.00
    166.67
    183.33
    200.00
    216.67
    .
    .

    MKV container specs only allow 1ms, so values are rounded to the nearest ms . So you get a delta PTS of 16 or 17, and that is variable.

    Code:
    0
    17
    33
    50
    67
    83
    100
    117
    133
    I'm not sure how mediainfo calculates how it declares "constant", but in actual recordings, sometimes at the beginning or end, there are duplicate frames as recording "warms up" so that can cause deviation. Also, frame drops can cause deviation from the constant pattern . Any deviation is technically variable frame rate



    But of we take mkv-60.mkv, track 1 timestamps are really buggy, it looks like this

    Code:
    # timestamp format v2
    0
    21
    43
    64
    85
    107
    128
    149
    171
    192
    213
    235
    256
    .
    .
    delta is 21,22.. etc. and at the end there are repeats. But ~ 21 delta PTS average means the fps is ~47 , not 60

    1/60 =~ 0.016666.. . So you should be seeing 16.7 ms for each entry (again round up, round down) , but the point 21 suggests a different framerate

    There might be something else going on with the audio timestamps, but this is abnormal
    Hi and sorry for the late reply, I've been busy with work and the process of buying a house.

    To be honest I'm not sure about all of the technical data you've talked about in your latest reply. I'm not sure I have to understand it anyway as I believe that you're right.

    I've tried recording a 10 hour file and it was broken. Audio track unreadable and video track only had 6 hours of data.

    I've tried a shorter record of 4 hours and it's working. My batch file copy the video in a mp4 container and my audio is copied in a wav container which all import great in Premiere Pro and plays back without A/V desync.

    Here's a MediaInfo of the MKV file

    General
    Unique ID : 283030676027590313016091945283295180801 (0xD4EDB9B4BE37AE417C871C69AB74F801)
    Complete name : C:\Users\Freeman\Videos\MediaTrans\2021-09-09 12-20-00.mkv
    Format : Matroska
    Format version : Version 4
    File size : 21.5 GiB
    Duration : 4 h 38 min
    Overall bit rate : 11.0 Mb/s
    Writing application : Lavf58.29.100
    Writing library : Lavf58.29.100
    ErrorDetectionType : Per level 1

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : V_MPEG4/ISO/AVC
    Duration : 4 h 38 min
    Bit rate : 9 289 kb/s
    Nominal bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Constant
    Frame rate : 60.119 FPS
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.075
    Stream size : 18.1 GiB (84%)
    Writing library : x264 core 161 r3020 d198931
    Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=24 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=10000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Default : Yes
    Forced : No
    Color range : Limited
    Color primaries : BT.709
    Transfer characteristics : BT.709
    Matrix coefficients : BT.709

    Audio
    ID : 2
    Format : PCM
    Format settings : Little / Signed
    Codec ID : A_PCM/INT/LIT
    Duration : 4 h 38 min
    Bit rate mode : Constant
    Bit rate : 1 536 kb/s
    Channel(s) : 2 channels
    Sampling rate : 48.0 kHz
    Bit depth : 16 bits
    Stream size : 2.99 GiB (14%)
    Default : Yes
    Forced : No
    Here's the MediaInfo of the remuxed MP4 file

    General
    Complete name : C:\Users\Freeman\Videos\MediaTrans\2021-09-09 12-20-00.mp4
    Format : MPEG-4
    Format profile : Base Media
    Codec ID : isom (isom/iso2/avc1/mp41)
    File size : 18.5 GiB
    Duration : 4 h 38 min
    Overall bit rate : 9 512 kb/s
    Writing application : Lavf59.4.102

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L4.2
    Format settings : CABAC / 4 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 4 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 4 h 38 min
    Source duration : 4 h 38 min
    Bit rate : 9 503 kb/s
    Nominal bit rate : 10 000 kb/s
    Width : 1 920 pixels
    Height : 1 080 pixels
    Display aspect ratio : 16:9
    Frame rate mode : Variable
    Frame rate : 60.000 FPS
    Minimum frame rate : 31.250 FPS
    Maximum frame rate : 16 000.000 FPS
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 0.076
    Stream size : 18.5 GiB (100%)
    Source stream size : 18.5 GiB (100%)
    Writing library : x264 core 161 r3020 d198931
    Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=24 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=abr / mbtree=1 / bitrate=10000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Color range : Limited
    Color primaries : BT.709
    Transfer characteristics : BT.709
    Matrix coefficients : BT.709
    mdhd_Duration : 16712449
    Codec configuration box : avcC
    Here's a MediaInfo of the wav file

    General
    Complete name : C:\Users\Freeman\Videos\MediaTrans\2021-09-09 12-20-00.wav
    Format : Wave
    File size : 2.99 GiB
    Duration : 4 h 38 min
    Overall bit rate mode : Constant
    Overall bit rate : 1 536 kb/s
    Writing application : Lavf59.4.102

    Audio
    Format : PCM
    Format settings : Little / Signed
    Codec ID : 1
    Duration : 4 h 38 min
    Bit rate mode : Constant
    Bit rate : 1 536 kb/s
    Channel(s) : 2 channels
    Sampling rate : 48.0 kHz
    Bit depth : 16 bits
    Stream size : 2.99 GiB (100%)
    I'll try to record a 3 hour video file in 30 FPS instead of 60 FPS as you're saying that in fact it's not 60 FPS anyway.

    In the meantime if you have additionnal hints, information or constatation please share it with me!

    Thank you a lot!
    Don't lose your nights, they're half your life.
    Quote Quote  
  24. New information. On this thread on the OBS forum, someone said that information explaining why the MKV file is like that.

    Unfortunately, small precision is set in the FFmpeg (OBS uses it to write the files)... and this way it works everywhere:

    FFmpeg: libavformat/matroskaenc.c Source File


    Code:
    Code:
    // ms precision is the de-facto standard timescale for mkv files
    avpriv_set_pts_info(s->streams[i], 64, 1, 1000);
    Nothing to fix on OBS side.
    I'm not sure what does it mean in all honesty. We're recording our first podcast this Monday and hope the best!

    Thank you for all your help!
    Don't lose your nights, they're half your life.
    Quote Quote  
  25. For the precision issue - it's not ffmpeg/libavformat's fault, they are just following MKV container specs . To code more precision would break specifications

    But the timestamps are buggy regardless of the precision issue - There is more than 1 issue at play here

    Is lossless audio that important? Or using MKV container (are you expecting interruptions or technical difficulties) ? I'd think sync would be highest priority
    Quote Quote  
  26. Originally Posted by poisondeathray View Post
    But the timestamps are buggy regardless of the precision issue - There is more than 1 issue at play here
    Any ideas on how to fix this? I may have done a mistake configuring ffmpeg custom recording in OBS. Could it be the keyframe interval?

    Image
    [Attachment 60703 - Click to enlarge]


    Originally Posted by poisondeathray View Post
    Is lossless audio that important? Or using MKV container (are you expecting interruptions or technical difficulties) ? I'd think sync would be highest priority
    Yes lossless audio is important as it's impossible to edit audio efficiently when it's compressed.
    Don't lose your nights, they're half your life.
    Quote Quote  
  27. Originally Posted by G22 View Post

    Any ideas on how to fix this? I may have done a mistake configuring ffmpeg custom recording in OBS. Could it be the keyframe interval?
    Not the keyframe interval. That only affects max distance IDR frame placement for libx264 ; it does not affect timestamps
    Quote Quote  
  28. Originally Posted by poisondeathray View Post
    Originally Posted by G22 View Post

    Any ideas on how to fix this? I may have done a mistake configuring ffmpeg custom recording in OBS. Could it be the keyframe interval?
    Not the keyframe interval. That only affects max distance IDR frame placement for libx264 ; it does not affect timestamps
    Then is there anything I could try in Muxer Settings or in Video Encoder Settings or OBS is just broken at making MKV files?

    Thank you for your help it's really appreciated.
    Don't lose your nights, they're half your life.
    Quote Quote  
  29. Originally Posted by G22 View Post

    Then is there anything I could try in Muxer Settings or in Video Encoder Settings or OBS is just broken at making MKV files?

    There is a --force-cfr switch in x264, but I doubt it will help because the issue definitely is not the encoder
    Quote Quote  
  30. Originally Posted by poisondeathray View Post
    Originally Posted by G22 View Post

    Then is there anything I could try in Muxer Settings or in Video Encoder Settings or OBS is just broken at making MKV files?

    There is a --force-cfr switch in x264, but I doubt it will help because the issue definitely is not the encoder
    And where should I search for the issue? Report on OBS Github?
    Don't lose your nights, they're half your life.
    Quote Quote  



Similar Threads