Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
20th December 2017, 23:30 | #1 | Link |
Registered User
Join Date: Aug 2009
Posts: 17
|
Audio sync help
I've been wrestling with this the whole day.
I have a video that's perfectly synced when being played with MPC-HC which i'm trying to trim and encode and it's always out of sync no matter what i've tried. I've indexed it with ffms, lsmash, used fpsnum and fpsden, audiodelay without succes. The only thing that trims and encodes it with audio synced is xvid4psp but i wanna add some filters that it doesn't support so i wanna do it on my own. Can anyone try and help me with this? Here's the MediaInfo output: Code:
Video Count : 338 Count of stream of this kind : 1 Kind of stream : Video Kind of stream : Video Stream identifier : 0 StreamOrder : 0 Inform : 15.0 Mb/s, 3840*2160 (16:9), at 23.844 FPS, AVC (Main@L5.1) (CABAC / 3 Ref Frames) ID : 1 ID : 1 Unique ID : 1 Format : AVC Format/Info : Advanced Video Codec Format/Url : http://developers.videolan.org/x264.html Commercial name : AVC Format profile : Main@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 : Main@L5.1 Codec settings : CABAC / 3 Ref Frames Codec settings, CABAC : Yes Codec_Settings_RefFrames : 3 Duration : 4545534.000000 Duration : 1 h 15 min Duration : 1 h 15 min 45 s 534 ms Duration : 1 h 15 min Duration : 01:15:45.534 Duration : 01:15:15:23 Duration : 01:15:45.534 (01:15:15:23) Bit rate mode : CBR Bit rate mode : Constant Bit rate : 14999552 Bit rate : 15.0 Mb/s Width : 3840 Width : 3 840 pixels Height : 2160 Height : 2 160 pixels Sampled_Width : 3840 Sampled_Height : 2160 Pixel aspect ratio : 1.000 Display aspect ratio : 1.778 Display aspect ratio : 16:9 Frame rate mode : VFR Frame rate mode : Variable Frame rate : 23.844 Frame rate : 23.844 FPS Original frame rate : 23.976 Original frame rate : 23.976 (24000/1001) FPS FrameRate_Original_Num : 24000 FrameRate_Original_Den : 1001 Frame count : 108383 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.076 Delay : 291 Delay : 291 ms Delay : 291 ms Delay : 291 ms Delay : 00:00:00.291 Delay, origin : Container Delay, origin : Container Stream size : 8479208897 Stream size : 7.90 GiB (99%) Stream size : 8 GiB Stream size : 7.9 GiB Stream size : 7.90 GiB Stream size : 7.897 GiB Stream size : 7.90 GiB (99%) Proportion of this stream : 0.98694 Default : Yes Default : Yes Forced : No Forced : No Buffer size : 30000000 Audio Count : 275 Count of stream of this kind : 1 Kind of stream : Audio Kind of stream : Audio Stream identifier : 0 StreamOrder : 1 Inform : 192 kb/s, 44.1 kHz, 2 channels, AAC (LC) ID : 2 ID : 2 Unique ID : 2 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 : 4545676.000000 Duration : 1 h 15 min Duration : 1 h 15 min 45 s 676 ms Duration : 1 h 15 min Duration : 01:15:45.676 Duration : 01:15:44:17 Duration : 01:15:45.676 (01:15:44:17) 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 : 200464304 Frame rate : 43.066 Frame rate : 43.066 FPS (1024 SPF) Frame count : 195409 Compression mode : Lossy Compression mode : Lossy Delay : 0 Delay : 00:00:00.000 Delay, origin : Container Delay, origin : Container Delay relative to video : -291 Delay relative to video : -291 ms Delay relative to video : -291 ms Delay relative to video : -291 ms Delay relative to video : -00:00:00.291 Video0 delay : -291 Video0 delay : -291 ms Video0 delay : -291 ms Video0 delay : -291 ms Video0 delay : -00:00:00.291 Stream size : 110799774 Stream size : 106 MiB (1%) Stream size : 106 MiB Stream size : 106 MiB Stream size : 106 MiB Stream size : 105.7 MiB Stream size : 106 MiB (1%) Proportion of this stream : 0.01290 Default : Yes Default : Yes Forced : No Forced : No |
21st December 2017, 00:04 | #3 | Link |
Registered User
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
|
I think of the following, extract the audio and convert it to WAV, then join it to the video and do the trim, the audio that is going to be left should be synchronized. These problems happen when working with variable audio.
|
21st December 2017, 05:13 | #6 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
You could try below BAT file
Code:
setlocal REM Where to Find ffmpeg set FFMPEG="C:\BIN\ffmpeg.exe" REM Where to get input file, No terminating Backslash, "." = current directory set INDIR="." REM Where to place output file, No terminating Backslash. set OUTDIR="D:" FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM *.mkv *.TS *.ogv) DO ( %FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI" ) Pause REM lines are comments Output UT_Video video and PCM audio. Perhaps something like this afterwards in avs Script Code:
AssumeFPS(24000,1001,True) ReSampleAudio(44100) # or 48000
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
21st December 2017, 20:02 | #7 | Link |
Registered User
Join Date: Aug 2009
Posts: 17
|
Indexing the original video with DSS2 i get an Wait for FrameReady error.
Converting the video to utvideo with ffmpeg and loading it with DSS2 (which shows frame rate as 23.000) with the wav attached works but it's also out of sync when i try to trim it even with manually setting the fps either in DSS2 or via AssumeFPS. It doesn't matter, thanks for your help guys. |
21st December 2017, 21:27 | #8 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Did you try with AviSource (always good idea to try first with AVI lossless), followed by the given script ?
EDIT: I thought ffmpeg as in given bat, converts to constant framerate (inserting frames as needed). EDIT: Might also be worth trying VirtualDubFilterMod, and save as AVI with UT_Video and PCM audio (with Fast Recompress).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 21st December 2017 at 21:33. |
21st December 2017, 21:52 | #9 | Link |
Registered User
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
|
darkelf5, try what TinMan tells you, in the past I solved problems of desynchronization with AVI with audio in MP3 VBR.
EDIT: did you use DDS2 or DSS2 Mod as I suggested? Last edited by GMJCZP; 21st December 2017 at 23:31. |
22nd December 2017, 02:22 | #13 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
You would need to convert to CFR before editing. This is true for almost everything (other video editing applications), not just avisynth
I'm guessing you already did that with xvid4psp, the only thing that "worked" for you Quote:
Have a look at the script it used . Look at the log files. I bet it was something like DirectShowSource("video.ext" , fps=23.976, convertfps=true) But it's not "safe" to use temporal filters with directshow . So if you were planning on those types of filters, I would use that to encode an intermediate first |
|
22nd December 2017, 02:33 | #14 | Link |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
That mediainfo you posted looks very confusing to me. By VFR it usually means that the video change frame rate something like 30fps to 24fps on playback, 23.844 to 23.976 is probably some false alarm.
You'll have to play the original file and check it yourself. For example, play it with media player classic, turn on view->statistics, jump around in the video and look at the playback rate. |
22nd December 2017, 03:55 | #16 | Link | ||
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
Quote:
It doesn't matter. It's still the right answer and source filter if you want to edit and use avisynth . The other methods are slightly less accurate and can have slight problems with frame placement. But this assumes your directshow system is configured correctly. In fact, you can just check it really quickly in MPCHC , jump around a bit. If it's in sync there (assuming you can playback UHD in realtime), then it's almost 100% guarenteed to work if you encode an intermediate first before editing / other filters What lansing is probably suggesting by "false alarm" , is that there is a small chance you can just assume a CFR framerate by overwriting timecodes, e.g. with mp4fpsmod. Because it looks like it's minimally variable if you assume mediainfo is correct. You would have to extract the timecodes and examine it to be sure. The benefit would be no large intermediate file, and you could use "normal" source filter like lsmashvideosource) |
||
22nd December 2017, 03:56 | #17 | Link | |
Registered User
Join Date: Sep 2006
Posts: 1,657
|
Quote:
Then did a quick convert of the video to create a test video, like encode it with ultrafast mode in x264 and resolution 640x360, and then play that test video with the wav, use the same delay you found before. If they're in sync and the whole time, then the problem should be just the audio delay. If they're out of sync, the problem is the video. |
|
22nd December 2017, 11:44 | #18 | Link |
Moderator
Join Date: Feb 2005
Location: Spain
Posts: 6,915
|
I can try other approach to preserve A/V sync. For that I need:
1) I don't know your source container from the initial MediaInfo. Please obtain a Source.mkv from it, renaming or converting with MkvToolNix. 2) Extract the timestamps from video and audio tracks of Source.mkv: ..."mkvextract.exe" "Source.mkv" timestamps_v2 0:"Source.mkv_ 0.txt" 1:"Source.mkv_ 1.txt" zip "Source.mkv_ 0.txt" and "Source.mkv_ 1.txt" and upload here (Attach) 3) Put here your avs, at least with Trim's an any other function than change fps.
__________________
BeHappy, AviSynth audio transcoder. |
22nd December 2017, 13:02 | #19 | Link | |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Quote:
E.g.: Code:
a=ffaudiosource("source.mkv") v=ffvideosource("source.mkv", fpsnum=24000, fpsden=1001) AudioDub(v, a) |
|
22nd December 2017, 13:07 | #20 | Link |
Registered User
Join Date: Aug 2009
Posts: 17
|
Manually adjusting the sync works although it gets desynced near the end.
Code:
v = LWLibavVideoSource("video.mkv", fpsnum=24000, fpsden=1001) a = WAVSource("audio.wav") AudioDub(v, a) Dissolve(Trim(0, 19478), Trim(25962, 55793), 18) FadeIO(1) Code:
http://www12.zippyshare.com/v/d7CYgXUP/file.html I've tried importing both external wav and internal audio. The results are the same. Last edited by darkelf5; 22nd December 2017 at 13:14. |
Thread Tools | Search this Thread |
Display Modes | |
|
|