News:

--

Main Menu

Audio synch 2.7.4

Started by mmmmna, November 30, 2019, 06:07:15 PM

Previous topic - Next topic

mmmmna

I use Linux (Currently Ubuntu Mate 18.04 LTS which is only 64 bit).

I've downloaded and use AVIDemux 2.7.2 App Image.

I'm transferring VHS tapes to digital format. NTSC, I'm sure.

To transfer, I'm using a device I bought from Amazon, shows on Amazon with
DM272 watermarked over the photo. It appears identical with EZ Cap 272, and the
printed manual was titled EZ Cap 272.

This is a stand alone device, meaning it does not require software for
conversions.

I deliberately chose a non-software conversion device because I do not possess
any Windows (nor a compatible Mac) computer. And am not interested in obtaining
such operating systems.

My truest editing needs are to simply trim excess lead in and lead out. This
editing is necessary since I cannot see when the VCR begins and ends sending
actual content to the EZ Cap 272.

I have attempted to use Linux apps Kino, Flowblade, KDENlive and OpenShot.
These are too featured for me to grasp, and exceed my needs.

My note today is because my audio is losing synch after AVIDemux trims the
endpoints.

I can get the audio into synch at one point in the output, but the audio loses
synch elsewhere.

Input format: .avi; output format: .avi. Yup, I'm that clueless and I do not wish to switch
formats unless to an MP4 format which is future-proof.

My guess for the cause of losing synch is there may be a frames per second
change which affects video but not audio.

If that is the issue, I would like to change the AVIDemux output frame rate to match
the input frame rate. I do not know either frame rate, so this is my guess.

Avidemux>File menu>Information:
A new popup window appears, is titled Properties.


=====================================================
Video
=====================================================
Codec 4CC:      XVID
Image Size:      800 x 592
Aspect Ratio:      1:1 (1:1)
Frame Rate:      30.000 fps
Total Duration:      02:30:00.333

=====================================================
Extra Video Properties
=====================================================
ExtraDataSize:      00

=====================================================
Audio
=====================================================
Codec:         MP3
Channels:      Stereo
Bitrate:      8000 Bps / 64 kbps
Frequency:      44100 Hz
Total Duration:      02:29:18.101





Q: how do I set the intended output frame rate in AVIDemus?


TIA.

eumagga0x2a

Quote from: mmmmna on November 30, 2019, 06:07:15 PM
I've downloaded and use AVIDemux 2.7.2 App Image.

2.7.2 or 2.7.4 as the topic title says? By all means, I'd recommend the latest nightly or building from source yourself, which is trivial on Ubuntu.

QuoteI'm transferring VHS tapes to digital format. NTSC, I'm sure.

If NTSC, then 30.000 FPS is most probably wrong.

QuoteTo transfer, I'm using a device I bought from Amazon, shows on Amazon with
DM272 watermarked over the photo. It appears identical with EZ Cap 272, and the
printed manual was titled EZ Cap 272.

This is a stand alone device, meaning it does not require software for
conversions.

It encodes video to Xvid and packs audio and video into AVI – both a poor choice nowadays. Sure, the manufacturer avoided paying for a H.264 licence, but anyway, a (too) high price for convenience. Does this device deinterlace video before compressing at least?

QuoteI deliberately chose a non-software conversion device because I do not possess
any Windows (nor a compatible Mac) computer.

There must be capture devices which output uncompressed video and which work on Linux, e.g. https://gordonlesti.com/digitize-a-vhs-tape-with-ffmpeg-and-easycap-on-linux/ or https://opensource.com/article/18/3/digitizing-vhs-fedora

QuoteMy guess for the cause of losing synch is there may be a frames per second
change which affects video but not audio.

Not a change (it is impossible with AVI, which is just a fixed time base multiplied with the current frame number), but 30.000 looks wrong for NTSC, it should be 30000/1001 (timebase = 30000 clock ticks per second, with a frame every 1001 ticks ~ 29,97002997 FPS).

QuoteIf that is the issue, I would like to change the AVIDemux output frame rate to match
the input frame rate.

You can easily do this by applying the "change fps" video filter, but this requires re-encoding the video stream once again = you lose quality. Doing such a trick without re-encoding should be possible with some codecs, but currenty it is not supported by Avidemux.

mmmmna

Well, as I am very much not able to purchase any more equipment, I'll work with what I have on hand and take your final statement as my solution:
QuoteYou can easily do this by applying the "change fps" video filter, but this requires re-encoding the video stream once again...

Thank you!

eumagga0x2a

There are still some strange things. Do the video properties you posted match the source video or an already edited one? Because the loss of A/V sync would happen with the source video as well if the FPS of the AVI was wrong, not just after editing.

Another open question is deinterlacing. If the video hasn't been deinterlaced prior to compression, the result is ruined, there is no use in proceeding.

mmmmna

#4
That info in my first post is for an input file that I wish to edit, intended to show what I was starting with coming from the EZ Cap 272 (see link below).

I checked the file data for a few edited avi files, they all state 30.000 FPS (per avidemux), before and after editing. Also, popped the same input file from my first post into VLC and the codec information in VLC shows 30 FPS. Maybe someone is rounding off?



Back to the point: as far as I can tell referencing a source and its fully edited file, the input file audio is definitely in synch before editing, as in less than about a hundred milliseconds of constant error (showing the same amount of error start to finish). In this case, the source file is a commercially transcribed family hour show from the 1960s, sent to retail channels on VHS somewhere around 1999. I suspect it is all public domain, but I digress.

The error after avidemux editing is to continuously go further out of synch.

Another view of the audio synch error is where I attempted to add a fixed audio shift for avidemux output audio. I can get audio in synch in pretty much ONE location in the output file, with the audio being too early in the beginning of the output file, audio is just right in the middle of the output file and audio is late at the end of the output file. If you need hard numbers, I can eventually get them by reediting the source file once more so as to have live data for you.

In my layman ears, it sure sounds like a 29.97 to 30.00 kind of error to me, but you decide. Maybe I'm pointing to the wrong end of the horse.

Deinterlacing? The manual for the capture box doesn't declare such. Target audience issue. Think gramma and grandpa: "Just plug it in and press record? Yayyy! Aren't we MODERN, hun?!".

Device website:  http://www.ezcap.com/article_list_98.html, listed on the right side.

I should do this...

Input file: 2019 07 23 RS 5 pack vol 3 VP 57 min.avi
Quote
=====================================================
Video
=====================================================
Codec 4CC:      XVID
Image Size:      800 x 592
Aspect Ratio:      1:1 (1:1)
Frame Rate:      30.000 fps
Total Duration:      01:00:53.733

=====================================================
Extra Video Properties
=====================================================
ExtraDataSize:      00

=====================================================
Audio
=====================================================
Codec:         MP3
Channels:      Stereo
Bitrate:      8000 Bps / 64 kbps
Frequency:      44100 Hz
Total Duration:      01:00:36.683


Output file: 2019 07 23 RS 5 pack vol 3 VP 57 min_edit plus 1300.avi
Quote

=====================================================
Video
=====================================================
Codec 4CC:      XVID
Image Size:      800 x 592
Aspect Ratio:      1:1 (1:1)
Frame Rate:      30.000 fps
Total Duration:      00:55:44.433

=====================================================
Extra Video Properties
=====================================================
ExtraDataSize:      00

=====================================================
Audio
=====================================================
Codec:         MP3
Channels:      Stereo
Bitrate:      8000 Bps / 64 kbps
Frequency:      44100 Hz
Total Duration:      00:55:28.701

The reference in the output file name to 'plus 1300' refers to a millisecond amount of delay I tried in hopes of seeing everything synch up. Nope.

eumagga0x2a

I don't think 30 fps is due to rounding. The device spec says they use a fixed fps value of 30, so they do exactly as advertised (which is wrong for NTSC input).

Quote from: mmmmna on December 07, 2019, 03:31:47 AM
I can get audio in synch in pretty much ONE location in the output file, with the audio being too early in the beginning of the output file, audio is just right in the middle of the output file and audio is late at the end of the output file.

This matches the effects of the wrong (too high) FPS. Please try re-encoding a portion of the source video with the changeFps filter applied (custom input frequency 30.00 to "29.97 (NTSC)") as a test. If the result is in sync, re-encode the entire video.

QuoteDeinterlacing? The manual for the capture box doesn't declare such. Target audience issue. Think gramma and grandpa: "Just plug it in and press record? Yayyy! Aren't we MODERN, hun?!".

Gramma and grandpa still posess eyesight, once they use such video conversion tools. They don't need to know what interlacing means. An interlaced video should be de-interlaced before compression (some codecs are capable of treating interlaced input in a special way, but don't rely on that). Otherwise jagged distorted shapes of moving objects are not correctable later.

mmmmna

I gave up on pursuing this. I have completed my efforts to transfer ~50 VHS tapes into .avi format. All have exhibited the same progressive audio skew, the source tapes and VCR have been discarded so there is no way to redo this effort.

My videos were created using default parameters of Avidemux.

Thanks!

dosdan

#7
Quote from: mmmmna on December 07, 2019, 03:31:47 AM
Another view of the audio synch error is where I attempted to add a fixed audio shift for avidemux output audio. I can get audio in synch in pretty much ONE location in the output file, with the audio being too early in the beginning of the output file, audio is just right in the middle of the output file and audio is late at the end of the output file. If you need hard numbers, I can eventually get them by reediting the source file once more so as to have live data for you.

You can't fix this with Shift. That's just an offset between the start of the video & audio streams.

This may be fixable in FFMPEG. It depends on whether it's due to sampling rate issues or dropped/added video frames.  To see if this is fixable:


  • Ensure that the two steams are in sync at the start.
  • Go to the End. Works out the timing difference.
  • Timestretch the audio stream inside the muxed clip using FFMEG: https://amiaopensource.github.io/ffmprovisr/#avsync_aresample
  • Check the processED clip, first ensuring it's NOW in sync at both the beginning & the end.
  • Now go to the mid-point of the clip and test the sync there. If it's in sync, great. If not, it means the mis-timing factor is not constant and you can't fix it easily.

Dan.

eumagga0x2a

The gradual loss of A/V sync due to bad frame grabber is (probably) fixable in Avidemux with the changeFps filter as described earlier.

Comb artifacts from the lack of deinterlacing step prior to compression are permanent.

dosdan

#9
Quote from: eumagga0x2a on March 22, 2020, 10:30:44 PM
The changeFps filter as described earlier.


mmmmna, that's going to reencode the video so there will be an video quality loss and it will take significant time.
Just working on the 64kbps audio stream would be quicker and the audio quality loss will potentially be less noticeable.

Working with an AVI source containing a Xvid (MPEG-4 ASP) video stream and an MP3 64kbps audio stream, the following FFMPEG command would increase the audio stream duration by 1%:

ffmpeg -i testfile.avi -af atempo=(100/101) -c:v copy  -c:a libmp3lame -b:a 64k -y testfile_fixed.avi

Another way to get a 1% longer audio stream is to set the 8000Hz sampling rate used in this clip to a slightly lower rate and then resample it back to a standard audio sampling rate (8000Hz).

ffmpeg -i testfile.avi -af asetrate=8000*(100/101),aresample=8000 -c:v copy  -c:a libmp3lame -b:a 64k -y testfile_fixed.avi

I'm not sure if the result will be any different from just using the atempo filter.

Note: if there was a issue due to a slight difference between the length of the video stream and the processed audio stream, I think including the -shortest option will set the clip duration to that of the shortest stream.

Dan.






eumagga0x2a

If the theory holds, the audio track would need to be sped up by 1001/1000.