Source is NTSC, and the audio track is in sync with the video track. File extension is .m2ts and duration is 01:45:32. File size is huge, and I want to transcode it, to reduce file size, but I encountered a problem.
While analyzing part of the source frame by frame in VirtualDub2, to check if it is interlaced or progressive, I noticed it is progressive and every 6th frame is a duplicate of the previous frame. So it was filmed PAL, and someone deinterlaced it, and then converted it to NTSC progressive.
After decimating and increasing speed from 24.98 fps to 25 fps, the video track duration is the same as the duration of the source audio track. But the audio is out of sync.
I extracted the audio with ffmpeg using these parameters:
This resulted in a .wav file with the duration 01:45:26. So the audio inside the .m2ts file, is 6 seconds shorter than the duration of the .m2ts file.Code:ffmpeg -i infile.m2ts -map 0:1 -codec:a pcm_s24le outfile.wav
I reversed PAL->NTSC telecining with this AviSynth+ script:
And encoded with x264 using that .avs script and these parameters:Code:SetFilterMTMode("DEFAULT_MT_MODE", 2) SetFilterMTMode("MPEG2Source", 3) MPEG2Source("index.d2v") tdecimate(cycle=6, cycler=1) AssumeFPS(25, 1, false) Spline64Resize(854, 480) Prefetch(4)
This resulted in a video file with the duration 01:45:26. The same duration as the audio, but audio is out of sync with this video file.Code:x264 --preset slower --tune film --crf 23 --colormatrix bt709 --min-keyint 25 --keyint 250 --output outfile.264 infile.avs
Then I used ffmpeg with these parameters to reverse PAL->NTSC:
This resulted in a video file with the duration 01:45:26. The same duration as the audio, but audio is out of sync with this video file.Code:ffmpeg -i infile.m2ts ^ -r 25 ^ -filter:v "decimate=cycle=6, setpts=N/(25*TB), zscale=854:480:f=spline36, setsar=1" ^ -codec:v libx264 -preset slower -tune film ^ -x264-params crf=23:min-keyint=25:keyint=250:colormatrix=bt709 ^ -an ^ outfile.mp4
FFmpeg filters produced the same result as the AviSynth+ filters: video track with same duration as audio, but out of sync with audio.
What else can I try, that should result in a video file that is in sync with the original audio?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 13 of 13
Thread
-
Last edited by codemaster; 11th Nov 2022 at 15:59.
-
The audio is out sync since it is 6 seconds shorter,you will have to shorten the audio as well.
I think,therefore i am a hamster. -
You sped up the video by 1.001, so you need to speed up the audio by 1.001.
For example using ffmpeg option:
Code:-af asetrate=48048,aresample=48000
Last edited by Luke M; 11th Nov 2022 at 19:04.
-
After decimating and increasing speed from 24.98 fps to 25 fps...
Much easier is to do the audio speed up within the AVISynth script. Then you can save out a WAV file.
But it begs the question - why keep it at PAL speed to begin with since it's so easy to slow it to film speed? -
I sped up audio 1.001 x with sox:
Code:sox infile.wav outfile.wav tempo -m 1.001
@manono: I chose pal speed because it was recorded at 25 fps or 50 fps, and slowed down 0.999x to make a ntsc bluray. If I slow it to film speed, I slow it 0.96 x. Content is live concert, and I confirmed that original speed is 25 fps by looking at the waveforms in kdenlive, using the live concert and the studio version of one of the songs. Studio song waveform matches with live song waveform at 25 fps speed, and doesn't match with live song waveform at 24 fps speed.Last edited by codemaster; 13th Nov 2022 at 03:14.
-
Since you're using AviSynth why not just adjust the audio length with AssumeFPS?
http://avisynth.nl/index.php/AssumeFPS#AssumeFPS
Code:AssumeFPS(25, 1, true) # adjusts length but leaves you with a non standard sample rate ResampleAudio(48000) # back to a standard sample rate, 44100, 48000, etc.
-
Because it doesn't allow me to use the best resampler. And because I choose high quality over simplicity. Also, I don't know how to change speed without changing pitch in AviSynth+, but I know how to do it in SoX, and I think that the person that slowed audio 0.999x to make ntsc bluray probably did it without changing pitch.
In the comparison of resamplers at src.infinitewave.ca i noticed that SoX resampler uses a higher quality algorithm than SSRC resampler from AviSynth+. SoX resampler is better than SSRC, and SSRC is better than ResampleAudio().Last edited by codemaster; 14th Nov 2022 at 01:29.
-
That seems unlikely, since if they didn't care about audio quality they would have done the video conversion by slowing down 4% (which looks better than duplicating frames). Anyway who cares. The pitch shift (if it's not fixing the pitch shift!) is insignificant.
And you keep talking about high quality resampling but _you're not doing resampling_..."tempo" change is a more complicated process, inherently lower quality than simple resampling.Last edited by Luke M; 13th Nov 2022 at 17:49.
-
I wasn't aware of this. Then I'll use the resample filter instead of the tempo filter, and let the pitch change. I used tempo because I assumed tempo automatically invokes the resample filter in order to do what it does. Now I realized that tempo uses a completely different algorithm than resample, and is not just an alias for the resample filter.
I think I did it properly this time:
Code:ffmpeg -i infile.m2ts ^ -map 0:1 ^ -filter:a "asetrate=48048, aresample=48000:resampler=soxr" ^ -codec:a pcm_f32le ^ outfile.wav
Last edited by codemaster; 14th Nov 2022 at 10:26.
-
Now I have two additional questions.
On this ntsc bluray, audio max amplitude is -0.1 dB, and my sped up audio max amplitude is 0.0 dB. I listened to parts of the sped up audio to check if there's clipping, and I don't hear clipping. And ffmpeg didn't display any warning in Windows Terminal about clipping when I sped up and resampled the audio.
In the filter list, would it be necessary (or recommended, or best practice) to normalize to -1 dB before changing speed to 48048 Hz and resampling to 48000 Hz?
Is the SoX resampler designed to automatically guard against clipping?Last edited by codemaster; 14th Nov 2022 at 11:01.
-
If the peak is exactly 0dB then it's a safe assumption that it's clipped. You don't need to normalize, just reduce the volume, e.g.:
Code:-af volume=-3dB
-
I think I finally did it properly:
Code:-filter:a "volume=-0.9dB, asetrate=48048, aresample=48000:resampler=soxr"
Code:[Parsed_volumedetect_0 @ 0000022cbfe9f540] n_samples: 606694586 [Parsed_volumedetect_0 @ 0000022cbfe9f540] mean_volume: -11.6 dB [Parsed_volumedetect_0 @ 0000022cbfe9f540] max_volume: -0.3 dB [Parsed_volumedetect_0 @ 0000022cbfe9f540] histogram_0db: 65212 [Parsed_volumedetect_0 @ 0000022cbfe9f540] histogram_1db: 2704238
Code:-filter:a "asetrate=48048, aresample=48000:resampler=soxr"
Code:[Parsed_volumedetect_0 @ 000002170b80f4c0] n_samples: 606694586 [Parsed_volumedetect_0 @ 000002170b80f4c0] mean_volume: -10.7 dB [Parsed_volumedetect_0 @ 000002170b80f4c0] max_volume: 0.0 dB [Parsed_volumedetect_0 @ 000002170b80f4c0] histogram_0db: 2418076
Last edited by codemaster; 15th Nov 2022 at 08:06.
Similar Threads
-
Complete newbie: help me converting PAL audio to NTSC on a Mac
By slowsoul in forum Newbie / General discussionsReplies: 12Last Post: 14th Sep 2022, 04:36 -
Can I get the hi-fi stereo audio from a PAL VHS tape in an NTSC player?
By ItaloFan in forum AudioReplies: 6Last Post: 18th Aug 2022, 20:52 -
How to sync audio from dvd pal with hd tv video
By ivicacevis in forum AudioReplies: 4Last Post: 13th Dec 2021, 17:47 -
NTSC to PAL audio pitch correction without speedup
By sebastiaaan in forum AudioReplies: 4Last Post: 22nd Aug 2021, 04:32 -
Converting NTSC->PAL Interlaced DVD Back To NTSC 24FPS???
By SegaSonic91 in forum DVD RippingReplies: 7Last Post: 2nd Oct 2020, 23:55