VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Hello , recently i have a problem in encoding some videos and i use staxrip latest version to encode it and i tried ffmpeg in cmd too but i got nothing.
    at the end of the encode , some videos is not synced with the audio , i tought the problem is the audio but after more trying i found out that the problem is the movie and the framerate then i tried with staxrip and i tried some custom framerate but i wasnt successful and i tried ffmpeg but i got this message "Past duration x.xxxxxx too large" for many times and in the main i got some errors in b frames but the movie and the audio was synced but i got some glitches in movie that after it you have to start movie 20 seconds after the glitch to watch it

    *the source is fine , no glitches , no problem with the audio or video , everything is fine
    please help me with that , thank you
    Quote Quote  
  2. i checked the source mediainfo and the original framerate was 24 and the framerate was 23.762 , when i used -r 23.762 in ffmpeg the movie and the audio was synced but i got glitch/es in movie
    Quote Quote  
  3. Provide audio duration and number of video frames... (so we can deduct video duration)...
    Quote Quote  
  4. Originally Posted by pandy View Post
    Provide audio duration and number of video frames... (so we can deduct video duration)...
    Frame Count: 145340
    Audio Duration from mediainfo:
    Duration : 6116252.000000
    Duration : 1 h 41 min
    Duration : 1 h 41 min 56 s 252 ms
    Duration : 1 h 41 min
    Duration : 01:41:56.252
    Duration : 01:41:46:22
    Duration : 01:41:56.252 (01:41:46:22)
    General

    Count : 325
    Count of stream of this kind: 1
    Kind of stream : General
    Kind of stream : General
    Stream identifier : 0
    Unique ID :
    Unique ID :
    Count of video streams : 1
    Count of audio streams : 2
    Video_Format_List : AVC
    Video_Format_WithHint_List: AVC
    Codecs Video : AVC
    Video_Language_List : English
    Audio_Format_List : AAC / AAC
    Audio_Format_WithHint_List: AAC / AAC
    Audio codecs : AAC LC / AAC LC-SBR
    Audio_Language_List : / English
    Complete name :
    Folder name :
    File name :
    File extension : mkv
    Format : Matroska
    Format : Matroska
    Format/Url : http://packs.matroska.org/
    Format/Extensions usually used: mkv mk3d mka mks
    Commercial name : Matroska
    Format version : Version 4 / Version 2
    Codec : Matroska
    Codec : Matroska
    Codec/Url : http://packs.matroska.org/
    Codec/Extensions usually used: mkv mk3d mka mks
    File size : 4883250132
    File size : 4.55 GiB
    File size : 5 GiB
    File size : 4.5 GiB
    File size : 4.55 GiB
    File size : 4.548 GiB
    Duration : 6116499
    Duration : 1 h 41 min
    Duration : 1 h 41 min 56 s 499 ms
    Duration : 1 h 41 min
    Duration : 01:41:56.499
    Duration : 01:40:55:20
    Duration : 01:41:56.499 (01:40:55:20)
    Overall bit rate : 6386987
    Overall bit rate : 6 387 kb/s
    Frame rate : 23.762
    Frame rate : 23.762 FPS
    Frame count : 145340
    Stream size : 2474239
    Stream size : 2.36 MiB (0%)
    Stream size : 2 MiB
    Stream size : 2.4 MiB
    Stream size : 2.36 MiB
    Stream size : 2.360 MiB
    Stream size : 2.36 MiB (0%)
    Proportion of this stream: 0.00051
    IsStreamable : Yes
    Encoded date : UTC 2018-07-18 13:16:19
    File creation date : UTC 2018-07-19 14:22:20.535
    File creation date (local): 2018-07-19 07:22:20.535
    File last modification date: UTC 2018-07-19 14:23:16.340
    File last modification date (local): 2018-07-19 07:23:16.340
    Writing application : mkvmerge v8.3.0 ('Over the Horizon') 64bit
    Writing application : mkvmerge v8.3.0 ('Over the Horizon') 64bit
    Writing library : libebml v1.3.1 + libmatroska v1.4.2
    Writing library : libebml v1.3.1 + libmatroska v1.4.2

    Video

    Count : 338
    Count of stream of this kind: 1
    Kind of stream : Video
    Kind of stream : Video
    Stream identifier : 0
    StreamOrder : 0
    ID : 1
    ID : 1
    Unique ID :
    Format : AVC
    Format/Info : Advanced Video Codec
    Format/Url : http://developers.videolan.org/x264.html
    Commercial name : AVC
    Format profile : High@L5.1
    Format settings : CABAC / 3 Ref Frames
    Format settings, CABAC : Yes
    Format settings, CABAC : Yes
    Format settings, RefFrames: 3
    Format settings, RefFrames: 3 frames
    Internet media type : video/H264
    Codec ID : V_MPEG4/ISO/AVC
    Codec ID/Url : http://ffdshow-tryout.sourceforge.net/
    Codec : V_MPEG4/ISO/AVC
    Codec : AVC
    Codec/Family : AVC
    Codec/Info : Advanced Video Codec
    Codec/Url : http://ffdshow-tryout.sourceforge.net/
    Codec profile : High@L5.1
    Codec settings : CABAC / 3 Ref Frames
    Codec settings, CABAC : Yes
    Codec_Settings_RefFrames : 3
    Duration : 6116416.000000
    Duration : 1 h 41 min
    Duration : 1 h 41 min 56 s 416 ms
    Duration : 1 h 41 min
    Duration : 01:41:56.416
    Duration : 01:40:55:20
    Duration : 01:41:56.416 (01:40:55:20)
    Bit rate : 6132482
    Bit rate : 6 132 kb/s
    Width : 3840
    Width : 3 840 pixels
    Height : 1608
    Height : 1 608 pixels
    Stored_Height : 1616
    Sampled_Width : 3840
    Sampled_Height : 1608
    Pixel aspect ratio : 1.000
    Display aspect ratio : 2.388
    Display aspect ratio : 2.40:1
    Frame rate mode : VFR
    Frame rate mode : Variable
    Frame rate : 23.762
    Frame rate : 23.762 FPS
    Original frame rate : 24.000
    Original frame rate : 24.000 FPS
    Frame count : 145340
    Resolution : 8
    Resolution : 8 bits
    Colorimetry : 4:2:0
    Color space : YUV
    Chroma subsampling : 4:2:0
    Chroma subsampling : 4:2:0
    Bit depth : 8
    Bit depth : 8 bits
    Scan type : Progressive
    Scan type : Progressive
    Interlacement : PPF
    Interlacement : Progressive
    Bits/(Pixel*Frame) : 0.042
    Delay : 83
    Delay : 83 ms
    Delay : 83 ms
    Delay : 83 ms
    Delay : 00:00:00.083
    Delay, origin : Container
    Delay, origin : Container
    Stream size : 4688601509
    Stream size : 4.37 GiB (96%)
    Stream size : 4 GiB
    Stream size : 4.4 GiB
    Stream size : 4.37 GiB
    Stream size : 4.367 GiB
    Stream size : 4.37 GiB (96%)
    Proportion of this stream: 0.96014
    Default : Yes
    Default : Yes
    Forced : No
    Forced : No
    Color range : Limited
    colour_description_present: Yes
    Color primaries : BT.709
    Transfer characteristics : BT.709
    Matrix coefficients : BT.709

    Audio #1

    Count : 275
    Count of stream of this kind: 2
    Kind of stream : Audio
    Kind of stream : Audio
    Stream identifier : 0
    Stream identifier : 1
    StreamOrder : 1
    ID : 2
    ID : 2
    Unique ID : 11870632932990354875
    Format : AAC
    Format/Info : Advanced Audio Codec
    Commercial name : AAC
    Format profile : LC
    Codec ID : A_AAC-2
    Codec : AAC LC
    Codec : AAC LC
    Codec/Family : AAC
    Duration : 6116252.000000
    Duration : 1 h 41 min
    Duration : 1 h 41 min 56 s 252 ms
    Duration : 1 h 41 min
    Duration : 01:41:56.252
    Duration : 01:41:46:22
    Duration : 01:41:56.252 (01:41:46:22)
    Bit rate : 192000
    Bit rate : 192 kb/s
    Channel(s) : 2
    Channel(s) : 2 channels
    Channel positions : Front: L R
    Channel positions : 2/0/0
    ChannelLayout : L R
    Samples per frame : 1024
    Sampling rate : 44100
    Sampling rate : 44.1 kHz
    Samples count : 269726720
    Frame rate : 43.066
    Frame rate : 43.066 FPS (1024 SPF)
    Frame count : 262580
    Compression mode : Lossy
    Compression mode : Lossy
    Delay : 0
    Delay : 00:00:00.000
    Delay, origin : Container
    Delay, origin : Container
    Delay relative to video : -83
    Delay relative to video : -83 ms
    Delay relative to video : -83 ms
    Delay relative to video : -83 ms
    Delay relative to video : -00:00:00.083
    Video0 delay : -83
    Video0 delay : -83 ms
    Video0 delay : -83 ms
    Video0 delay : -83 ms
    Video0 delay : -00:00:00.083
    Stream size : 144608923
    Stream size : 138 MiB (3%)
    Stream size : 138 MiB
    Stream size : 138 MiB
    Stream size : 138 MiB
    Stream size : 137.9 MiB
    Stream size : 138 MiB (3%)
    Proportion of this stream: 0.02961
    Title : 粤语
    Default : Yes
    Default : Yes
    Forced : No
    Forced : No

    Audio #2

    Count : 275
    Count of stream of this kind: 2
    Kind of stream : Audio
    Kind of stream : Audio
    Stream identifier : 1
    Stream identifier : 2
    StreamOrder : 2
    ID : 3
    ID : 3
    Unique ID : 1679659930148292742
    Format : AAC
    Format/Info : Advanced Audio Codec
    Commercial name : AAC
    Format profile : HE-AAC / LC
    Format settings : Implicit
    Format settings, SBR : Yes (Implicit)
    Format settings, SBR : Yes (Implicit)
    Codec ID : A_AAC-2
    Codec : AAC LC-SBR
    Codec : AAC LC-SBR
    Codec/Family : AAC
    Duration : 6116321.000000
    Duration : 1 h 41 min
    Duration : 1 h 41 min 56 s 321 ms
    Duration : 1 h 41 min
    Duration : 01:41:56.321
    Duration : 01:38:42:19
    Duration : 01:41:56.321 (01:38:42:19)
    Bit rate : 62214
    Bit rate : 62.2 kb/s
    Channel(s) : 2
    Channel(s) : 2 channels
    Channel positions : Front: L R
    Channel positions : 2/0/0
    ChannelLayout : L R
    Samples per frame : 1024
    Sampling rate : 44100 / 22050
    Sampling rate : 44.1 kHz / 22.05 kHz
    Samples count : 269729760
    Frame rate : 21.533
    Frame rate : 21.533 FPS (1024 SPF)
    Frame count : 130303
    Compression mode : Lossy
    Compression mode : Lossy
    Delay : 0
    Delay : 00:00:00.000
    Delay, origin : Container
    Delay, origin : Container
    Delay relative to video : -83
    Delay relative to video : -83 ms
    Delay relative to video : -83 ms
    Delay relative to video : -83 ms
    Delay relative to video : -00:00:00.083
    Video0 delay : -83
    Video0 delay : -83 ms
    Video0 delay : -83 ms
    Video0 delay : -83 ms
    Video0 delay : -00:00:00.083
    Stream size : 47565461
    Stream size : 45.4 MiB (1%)
    Stream size : 45 MiB
    Stream size : 45 MiB
    Stream size : 45.4 MiB
    Stream size : 45.36 MiB
    Stream size : 45.4 MiB (1%)
    Proportion of this stream: 0.00974
    Title :
    Default : No
    Default : No
    Forced : No
    Forced : No
    Quote Quote  
  5. IMHO your video probably lost some video frames (corrupted during transfer/transmission) - to match your audio duration video framerate shall be 145340000/6116252 (i.e. 23.7629188594584 fps) but this is not standard framerate and decoders may try to "workaround" this framerate to match one of common (standard) framerates...
    You can or try to find correct video source or you can try to change audio duration to match fake video duration - so for example you can change audio duration by resampling audio from 44100Hz to 43708.027767659Hz ((44100*(145340*(24000/1001))/6116252) and later set samplerate to 44100Hz - relatively easy by using one of common audio editors also SoX offer such functionality, then encode audio and mux with video (at the same you must set your video framerate to 24000/1001 i.e approx 23.976fps).

    I think that glitch is related to corrupted video not framerate but...

    I assume scenario was like this: someone used corrupted video and reencoded it (to fix issues?) thus perhaps some corrupted frames was discarded, now video duration with standard framerate is too short when compared with standardised framerates thus you need to use non standard framerates and this may introduce another group of issues. Changing audio duration looks like most appropriate approach.

    Instead 24000/1001 you should be able to use 24 fps - audio resampling rate should be then 43664.3634042548Hz - this will even simplify further calculation and overall result should be still acceptable.
    Last edited by pandy; 19th Jul 2018 at 10:08.
    Quote Quote  
  6. Originally Posted by pandy View Post
    IMHO your video probably lost some video frames (corrupted during transfer/transmission) - to match your audio duration video framerate shall be 145340000/6116252 (i.e. 23.7629188594584 fps) but this is not standard framerate and decoders may try to "workaround" this framerate to match one of common (standard) framerates...
    You can or try to find correct video source or you can try to change audio duration to match fake video duration - so for example you can change audio duration by resampling audio from 44100Hz to 43708.027767659Hz ((44100*(145340*(24000/1001))/6116252) and later set samplerate to 44100Hz - relatively easy by using one of common audio editors also SoX offer such functionality, then encode audio and mux with video (at the same you must set your video framerate to 24000/1001 i.e approx 23.976fps).

    I think that glitch is related to corrupted video not framerate but...

    I assume scenario was like this: someone used corrupted video and reencoded it (to fix issues?) thus perhaps some corrupted frames was discarded, now video duration with standard framerate is too short when compared with standardised framerates thus you need to use non standard framerates and this may introduce another group of issues. Changing audio duration looks like most appropriate approach.

    Instead 24000/1001 you should be able to use 24 fps - audio resampling rate should be then 43664.3634042548Hz - this will even simplify further calculation and overall result should be still acceptable.
    thank you for your help, the source video doesnt have any glitch and the glitch appeared after the encoding video with 23.762 framerate , i have another question how can i calculate this ((44100*(145340*(24000/1001))/6116252 --> i got this 25,125.54777307767 ) or how to calculate the audio sample rate for syncing , imagine i have another video and the same problem i wanna learn the solution , thank you
    Quote Quote  
  7. Hm,

    maybe it helps if you set input framerate of the video to 145340000/6116252 and output framerate to 24?

    Audio can be stretched or squeezed with the help of the ffmpeg atempo filter, too.

    E.g.:
    ffmpeg -i audio.mp4 -filter: a "atempo=..." -y audio_new_length.mp4

    Where ... = duration of audio in milliseconds/duration of video in milliseconds
    Quote Quote  
  8. Originally Posted by fornit View Post
    Hm,

    maybe it helps if you set input framerate of the video to 145340000/6116252 and output framerate to 24?

    Audio can be stretched or squeezed with the help of the ffmpeg atempo filter, too.

    E.g.:
    ffmpeg -i audio.mp4 -filter: a "atempo=..." -y audio_new_length.mp4

    Where ... = duration of audio in milliseconds/duration of video in milliseconds
    hi , thank you for your help , not working on the 24 fps and 24000/1001
    Quote Quote  
  9. Originally Posted by m00511 View Post
    I think that glitch is related to corrupted video not framerate but...
    Perhaps - don't know your source but my educated guess lead me to conclusion this that it may be related to lost some frames.

    Originally Posted by m00511 View Post
    thank you for your help, the source video doesnt have any glitch and the glitch appeared after the encoding video with 23.762 framerate , i have another question how can i calculate this ((44100*(145340*(24000/1001))/6116252 --> i got this 25,125.54777307767 ) or how to calculate the audio sample rate for syncing , imagine i have another video and the same problem i wanna learn the solution , thank you
    Perhaps i've lost something during writing reply - apologies

    Will try to make this simpler.
    AudioSourceSampleRate (ASSR)=44100(Hz)
    NumberofVideoFrames (NVF)=145340
    FrameRate (FR)=24 ; (our assumed - new video frame rate)
    AudioSourceDuration (ASD)=6116252(ms)
    AudioTargetSampleRate (ATSR)=(ASSR*NVF*1000)/(FR*ASD)=(44100*145340*1000)/(24*6116252)=43664.3634042548Hz

    (general idea is: ratio between real audio duration and calculated video duration is used to modify audio sample rate in a way that audio duration matching calculated video duration) - hope now it is without errors

    More or less all automatic 'tempo' work on similar principle - idea is to play audio faster or slower depend if it longer or shorter than calculated video duration - of course this will shift frequencies proportionally but when change is not so significant this may be unnoticeable - to prevent frequency shift and change 'tempo' at the same time more fancy signal processing is required and frequently perceived result may be worse than small frequency shift.
    Quote Quote  
  10. Originally Posted by pandy View Post
    Originally Posted by m00511 View Post
    I think that glitch is related to corrupted video not framerate but...
    Perhaps - don't know your source but my educated guess lead me to conclusion this that it may be related to lost some frames.

    Originally Posted by m00511 View Post
    thank you for your help, the source video doesnt have any glitch and the glitch appeared after the encoding video with 23.762 framerate , i have another question how can i calculate this ((44100*(145340*(24000/1001))/6116252 --> i got this 25,125.54777307767 ) or how to calculate the audio sample rate for syncing , imagine i have another video and the same problem i wanna learn the solution , thank you
    Perhaps i've lost something during writing reply - apologies

    Will try to make this simpler.
    AudioSourceSampleRate (ASSR)=44100(Hz)
    NumberofVideoFrames (NVF)=145340
    FrameRate (FR)=24 ; (our assumed - new video frame rate)
    AudioSourceDuration (ASD)=6116252(ms)
    AudioTargetSampleRate (ATSR)=(ASSR*NVF*1000)/(FR*ASD)=(44100*145340*1000)/(24*6116252)=43664.3634042548Hz

    (general idea is: ratio between real audio duration and calculated video duration is used to modify audio sample rate in a way that audio duration matching calculated video duration) - hope now it is without errors

    More or less all automatic 'tempo' work on similar principle - idea is to play audio faster or slower depend if it longer or shorter than calculated video duration - of course this will shift frequencies proportionally but when change is not so significant this may be unnoticeable - to prevent frequency shift and change 'tempo' at the same time more fancy signal processing is required and frequently perceived result may be worse than small frequency shift.
    thanks again , i tried SoX but i got nothing because cant support m4a and tried ffmpeg too but i got the same result and it didnt support the 43664hz
    i tried another way and i encoded the video in 24 fps and i changed the 44100hz to 48000hz and the both video and the audio was synced , how is that possible?
    is there a relationship between the audio sample rate and the movie framerate , if the answer is yes how can i know this? means what is the sample rate with the 30 fps?
    i'm confused right now and i cant resample it to test it and in the same i was successful with changing 44100 to 48000 , i wanna learn a stable solution to solve the problems

    thank u
    Quote Quote  
  11. Originally Posted by m00511 View Post
    thanks again , i tried SoX but i got nothing because cant support m4a and tried ffmpeg too but i got the same result and it didnt support the 43664hz
    i tried another way and i encoded the video in 24 fps and i changed the 44100hz to 48000hz and the both video and the audio was synced , how is that possible?
    is there a relationship between the audio sample rate and the movie framerate , if the answer is yes how can i know this? means what is the sample rate with the 30 fps?
    i'm confused right now and i cant resample it to test it and in the same i was successful with changing 44100 to 48000 , i wanna learn a stable solution to solve the problems

    thank u
    Ok, SoX will not understand many codecs thus you need to use PCM (wav) and later re-encode wav to some usable form.
    For SoX trick with sample rate may look like this:

    Code:
    @sox --buffer 131072 -S -V "%1" "%1.sox" rate -v -s -I 43664
    @sox --buffer 131072 -S -V -r 44100 "%1.sox" "%1_.wav"
    But instead doing such things with SoX try to use ffmpeg (support SoX sample rate converter and by definition way more codecs)

    so i would give a chance to for example atempo=6116252/6055833.33333333 then audio duration should match video duration (24fps), for 23.976 it will be something like: atempo=6116252/6061889.16666667

    --
    Ok, now i've realised that we talking about Variable Frame Rate Video... have no clue how to deal with such thing - my first shot will be converting VFR video to CFR... - VFR is abomination in CFR world!
    http://forum.doom9.org/showthread.php?t=173383
    https://forum.videohelp.com/threads/378898-VFR-to-CFR
    Quote Quote  
  12. Originally Posted by pandy View Post
    Ok, now i've realised that we talking about Variable Frame Rate Video... have no clue how to deal with such thing - my first shot will be converting VFR video to CFR... - VFR is abomination in CFR world!
    http://forum.doom9.org/showthread.php?t=173383
    https://forum.videohelp.com/threads/378898-VFR-to-CFR
    MediaInfo has the tendency to report videos as VFR, if there is something wrong with the time codes.

    At the following post, Jerome Martinez (developer of MediaInfo) explains, how it works:
    https://sourceforge.net/p/mediainfo/discussion/297610/thread/b2a2708d/#8ba8

    If there is a single time code difference at the beginning of a video, that differs from the rest, and all the others are equal, then it will be reported as VFR.

    He also says, that MediaInfo reports an "Original frame rate", if there is an info in the fixed_frame_rate field.

    Above an Original frame rate of 24 fps is reported. I would try to get the video back to that frame rate.

    Maybe "-vsync 1" will help (it will duplicate missing frames making the video CFR).
    Quote Quote  
  13. Originally Posted by fornit View Post
    MediaInfo has the tendency to report videos as VFR, if there is something wrong with the time codes.

    At the following post, Jerome Martinez (developer of MediaInfo) explains, how it works:
    https://sourceforge.net/p/mediainfo/discussion/297610/thread/b2a2708d/#8ba8

    If there is a single time code difference at the beginning of a video, that differs from the rest, and all the others are equal, then it will be reported as VFR.

    He also says, that MediaInfo reports an "Original frame rate", if there is an info in the fixed_frame_rate field.

    Above an Original frame rate of 24 fps is reported. I would try to get the video back to that frame rate.

    Maybe "-vsync 1" will help (it will duplicate missing frames making the video CFR).
    I don't use mediainfo (unreliable) - you could parse file trough ffprobe and analyse PTS delta (should be constant) - this will give answer for question if there CFR or VFR there...
    Code:
    ffprobe -select_streams v -i %1 -show_entries "frame=pkt_duration_time" -pretty -print_format csv -of csv > "%~n1.csv"
    Quote Quote  
  14. Originally Posted by pandy View Post
    I don't use mediainfo (unreliable) - you could parse file trough ffprobe and analyse PTS delta (should be constant) - this will give answer for question if there CFR or VFR there...
    Code:
    ffprobe -select_streams v -i %1 -show_entries "frame=pkt_duration_time" -pretty -print_format csv -of csv > "%~n1.csv"
    Yes. And if you want to be sure about frame count and video duration you should also parse the video:

    Code:
    ffmpeg -i %s -map 0:v:0 -f null -
    Of course the same applies to the audio...
    Quote Quote  



Similar Threads

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