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.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 5th July 2020, 18:19   #2061  |  Link
jlw_4049
Registered User
 
Join Date: Sep 2018
Posts: 391
Quote:
Originally Posted by lordalibaski View Post
Why do I have this out of sync problem all the time when trying a new beta and this is a fresh install.

Small clip of the original file
https://fromsmash.com/QKXLk4kKHN-bt

Converted file out of sync (this is the full file conversion)
https://fromsmash.com/UumR.w.GNn-bt

No matter what format I try to convert it to it goes out of sync.

ok it will keep that small file in sync but won't keep the full file in sync!!

Here is the full file if anyone wants to see if they have the same problem I'm using the latest beta.

https://fromsmash.com/7clueZsqO.-bt
Send me the file if you can and the process. Ill see what I can figure out.

Sent from my SM-G986U1 using Tapatalk
jlw_4049 is offline  
Old 5th July 2020, 18:36   #2062  |  Link
lordalibaski
Registered User
 
Join Date: May 2016
Posts: 88
Hi jlw

I've uploaded it mate it's in the above post bottom link that's the original file.
lordalibaski is offline  
Old 5th July 2020, 19:06   #2063  |  Link
jlw_4049
Registered User
 
Join Date: Sep 2018
Posts: 391
Quote:
Originally Posted by lordalibaski View Post
Hi jlw

I've uploaded it mate it's in the above post bottom link that's the original file.
You need to extract the .mpg file from the VOB, encode that, then after words you can put it all back together in a .mkv or .mp4 or what ever else.

EDIT: I've encoded/muxed several different ways. EVERY way left the audio out of sync. For what ever reason, I'm assuming there is an issue with your source.

Last edited by jlw_4049; 5th July 2020 at 19:38.
jlw_4049 is offline  
Old 5th July 2020, 22:28   #2064  |  Link
lordalibaski
Registered User
 
Join Date: May 2016
Posts: 88
That's my conclusion as well jlw

No matter what you do with the full show it sends it out of sync, though if you trim a 5min segment and convert it's perfectly fine it's only when you try to convert the whole show then it goes out of sync.
lordalibaski is offline  
Old 5th July 2020, 22:59   #2065  |  Link
lordalibaski
Registered User
 
Join Date: May 2016
Posts: 88
Right I've just tried the exact same source in handbrake and the conversion was completely in sync so this is not a source fault.
lordalibaski is offline  
Old 6th July 2020, 00:49   #2066  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by lordalibaski View Post
Right I've just tried the exact same source in handbrake and the conversion was completely in sync so this is not a source fault.
Well, it is a source fault. More specifically, the frame rate of the video stream is irregular: there are dropped frames in the video stream.

MediaInfo (and MediaInfo.NET) shows (incorrectly) that it has 23.976 (24000/1001) fps, but if you look into the file using ffprobe, you get the following info:

Quote:
Input #0, mpeg, from 'Test.vob':
Duration: 00:19:20.00, start: 0.280633, bitrate: 4296 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], Closed Captions, 6000 kb/s, 29.58 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Side data:
cpb: bitrate max/min/avg: 6000000/0/0 buffer size: 1835008 vbv_delay: N/A
Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Therefore, if you encode this file using FFmpeg (or other FFmpeg based apps like Handbrake, etc.), the video encoder automatically fills in the dropped frames by duplicating frames appropriately.

In reality, if you run the following simple FFmpeg command in CMD, you'll verify it in the real time log message of FFmpeg.

Code:
ffmpeg -hide_banner -i Test.vob -c:v libx264 -crf 22.0 -preset medium -c:a aac -ac 2 -b:a 128k -sn -map_metadata -1 -map_chapters -1 -y Test.mp4
[Log]

Quote:
......
More than 1000 frames duplicated 20992kB time=00:02:45.60 bitrate=1038.4kbits/s dup=992 drop=0 speed=5.18x
frame=34796 fps=134 q=-1.0 Lsize= 156058kB time=00:19:20.92 bitrate=1101.2kbits/s dup=6953 drop=0 speed=4.47x
video:146096kB audio:9063kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.579034%
......
In StaxRip (and other AVS based apps), the video stream frame rate info differs depending on what kind of source filter you use for this file (29.97 for DGSource, 24 for FFVideoSource, etc.), and that's what makes the problem complicated in this case.


Then, how can we make StaxRip fill in dropped frames by duplicating frames?

Well, in theory, putting ChangeFPS(30000, 1001) in the AVS script is expected to solve this out-of-sync problem, but in reality, it doesn't. Since StaxRip splits video and audio and deals with them separately, video/audio sync is not tackled appropriately by this method.

In my experience, piping via FFmpeg along with a forced frame rate seems to be more effective for out-of-sync problems.

Suppose you want to encode an HEVC video stream via NVEnc, but you want to fix this dropped frame issue as well.
In this case, instead of piping via avs2pipemod, select Command Line encoder and edit the code like this:

Quote:
"%app:ffmpeg%" -hwaccel dxva2 -i "%source_file%" -f yuv4mpegpipe -strict -1 -pix_fmt yuv420p -loglevel fatal -hide_banner -r 30000/1001 - | "%app:NVEnc%" --vbrhq 0 --codec h265 --preset quality --vbr-quality 30 --aq --ref 4 --lookahead 32 --y4m -i - -o "%temp_dir%%target_name%_out.h265"
You can force the frame rate by using this -r option in ffmpeg.

(This is why you need to create a Command Line encoder profile instead of choosing ffmpeg (DXVA2) decoder in NVEnc options.
Technically, choosing ffmpeg (DXVA2) decoder in NVEnc options is exactly the same as the above Command Line encoder code except for the -r option.
I think it'd be good if @stax76 implemented this additional item in NVEnc ffmpeg (DXVA2) decoder option. )

Choose your own audio encoding.

After muxing is done, you will see the final sync is a little bit off: video is a little delayed behind audio. But as ffprobe tells us, the video starts at 0.280633 second, i.e., about 281 milliseconds.

So, you need to remux video (hevc) and audio by delaying the audio by 281 milliseconds.



Now you'll see the output is fully in sync.

Last edited by JKyle; 6th July 2020 at 03:57.
JKyle is offline  
Old 6th July 2020, 03:43   #2067  |  Link
Disturbance
Registered User
 
Join Date: Mar 2007
Posts: 26
Quote:
Originally Posted by sneaker_ger View Post
@Disturbance:
Unlike for mp4, Matroska timestamps aren't exact for 24/1.001 fps. So with a very short file like yours MediaInfo might display such unexpected fps. It is not a bug in mkvmerge. My guess is for files longer than a few seconds MediaInfo will show fps as you expect.
I spent about 3 days working on this to try getting it to work and this ended up being the solution, that my clips needed to be longer and then they would display the correct fps, thank you to everyone else as well that commented and helped me. It is good to have the issue fixed, it just doesn't feel good it took me so long to realise it was as usual, user error.
Disturbance is offline  
Old 6th July 2020, 07:19   #2068  |  Link
jlw_4049
Registered User
 
Join Date: Sep 2018
Posts: 391
Quote:
Originally Posted by JKyle View Post
Well, it is a source fault. More specifically, the frame rate of the video stream is irregular: there are dropped frames in the video stream.

MediaInfo (and MediaInfo.NET) shows (incorrectly) that it has 23.976 (24000/1001) fps, but if you look into the file using ffprobe, you get the following info:



Therefore, if you encode this file using FFmpeg (or other FFmpeg based apps like Handbrake, etc.), the video encoder automatically fills in the dropped frames by duplicating frames appropriately.

In reality, if you run the following simple FFmpeg command in CMD, you'll verify it in the real time log message of FFmpeg.

Code:
ffmpeg -hide_banner -i Test.vob -c:v libx264 -crf 22.0 -preset medium -c:a aac -ac 2 -b:a 128k -sn -map_metadata -1 -map_chapters -1 -y Test.mp4
[Log]



In StaxRip (and other AVS based apps), the video stream frame rate info differs depending on what kind of source filter you use for this file (29.97 for DGSource, 24 for FFVideoSource, etc.), and that's what makes the problem complicated in this case.


Then, how can we make StaxRip fill in dropped frames by duplicating frames?

Well, in theory, putting ChangeFPS(30000, 1001) in the AVS script is expected to solve this out-of-sync problem, but in reality, it doesn't. Since StaxRip splits video and audio and deals with them separately, video/audio sync is not tackled appropriately by this method.

In my experience, piping via FFmpeg along with a forced frame rate seems to be more effective for out-of-sync problems.

Suppose you want to encode an HEVC video stream via NVEnc, but you want to fix this dropped frame issue as well.
In this case, instead of piping via avs2pipemod, select Command Line encoder and edit the code like this:



You can force the frame rate by using this -r option in ffmpeg.

(This is why you need to create a Command Line encoder profile instead of choosing ffmpeg (DXVA2) decoder in NVEnc options.
Technically, choosing ffmpeg (DXVA2) decoder in NVEnc options is exactly the same as the above Command Line encoder code except for the -r option.
I think it'd be good if @stax76 implemented this additional item in NVEnc ffmpeg (DXVA2) decoder option. )

Choose your own audio encoding.

After muxing is done, you will see the final sync is a little bit off: video is a little delayed behind audio. But as ffprobe tells us, the video starts at 0.280633 second, i.e., about 281 milliseconds.

So, you need to remux video (hevc) and audio by delaying the audio by 281 milliseconds.



Now you'll see the output is fully in sync.
This is good advice

Sent from my SM-G986U1 using Tapatalk
jlw_4049 is offline  
Old 6th July 2020, 08:32   #2069  |  Link
44vince44
Registered User
 
Join Date: May 2020
Posts: 188
to Lordalibaski:

Your source file is a VOB file. In Settings > Preprocessing, you can select which one will handle mpeg2 and vob:
- D2V Witch
- DGIndex

I bet D2V Witch is selected.
So select DG Index. And before importing file, you MUST delete the temp folder of your project, to make sure no trace of the older intermediate files is left, and also maybe restart Staxrip to make sure DGIndex will be used.


EDIT: TESTED your sample file, with the DGIndex selected, and the result gave Audio Video SYNCED!

Last edited by 44vince44; 6th July 2020 at 09:10.
44vince44 is offline  
Old 6th July 2020, 09:53   #2070  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Yes, I verified that @44vince44's approach works.

The combination of DGIndex and MPEG2Source works good on this source and produces no out-of-sync problem.
(Although you need to delay audio by 281 milliseconds.)

This way you can avoid forcing a frame rate via FFmpeg introduced in my approach, which means you can make most of the affluent AVS filters.
The resulting frame rate is 24000/1001, same as the source frame rate detected by MediaInfo.

Interesting result. Only DGIndex generated d2v works OK whereas D2V Witch or DGIndexNV fails. Seems like oldies go well with each other.

Last edited by JKyle; 6th July 2020 at 10:10.
JKyle is offline  
Old 6th July 2020, 14:22   #2071  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Quote:
Originally Posted by JKyle View Post
Interesting result. Only DGIndex generated d2v works OK whereas D2V Witch or DGIndexNV fails.
It works fine with DGDecNV when handled correctly.

The source VOB has the infamous black-frames-at-the-start-with-no-audio pathology. The timestamps reset after those frames and that is what causes the problem. You can see this by logging timestamps. Here's how to do it properly:

- Open the VOB in DGIndexNV.
- Skip forward 3 GOPs with the GOP forward button (it's only black video) and then set the project start there with the [ button.
- Save the project.
- Now the following script serves perfectly synced audio. I use 32-bit because my nicaudio.dll is 32-bit. You can play the script in VirtualDub32 for example.

Code:
loadplugin("dgdecodenv.dll")
loadplugin("nicaudio.dll")
vid=dgsource("Test.dgi",fieldop=1)
aud=NicAC3Source("Test T80 2_0ch 48KHz 192Kbps DELAY -90ms.ac3",2).DelayAudio(-0.09)
AudioDub(vid,aud)
And Bob's yer uncle.

Note, the video also has field-order transitions. I won't get into that as it does not bear on the sync issue and here the video is progressive (with 3:2 pulldown) so it is inconsequential.

This is the pedal-to-the-metal way to handle this stream. I cannot comment on what 3rd-party transcoders are doing, nor how they differ in their handling with DGIndex versus DGIndexNV.

EDIT: You can get away with skipping only two GOPs also, but use the correct delay from the demuxed AC3 filename in your script. I didn't try skipping only one GOP.

Last edited by videoh; 6th July 2020 at 15:19.
videoh is offline  
Old 6th July 2020, 15:07   #2072  |  Link
44vince44
Registered User
 
Join Date: May 2020
Posts: 188
Thanks JKyle for confirming, and videoh for the information.

As a general rule, to people using vob sources, I recommend that they keep using DGIndex. It's better than D2V Witch, and it's not the first time a problem happens with D2V Witch..
44vince44 is offline  
Old 6th July 2020, 19:21   #2073  |  Link
Z'Hadum
Registered User
 
Join Date: Dec 2018
Posts: 22
Quote:
Originally Posted by JKyle View Post
Just a suggestion: have you tried enabling developer mode?
yes, so then I will stick at the installed avisynth version ....
thx
Z'Hadum is offline  
Old 6th July 2020, 19:30   #2074  |  Link
hevron
Registered User
 
Join Date: Jun 2020
Posts: 26
My choice is h264 NVEnc or h264 QSVEnc. I worked with files about which jlw_4049 wrote
Quote:
there are dropped frames in the video stream
I did so:
AviSynth/VapourSynth
The Godfather I,II,III \BDMV\STREAM\00001.m2ts
Folder _temp before encoding: 00001.h264 - Frame rate: 23.976 (24000/1001) FPS
Folder _temp after encoding: 00001_out.h264 - Frame rate: 24.000 FPS
desync

FFmpeg (Intel)
Folder _temp before encoding: 00001.h264 - Frame rate: 23.976 (24000/1001) FPS
Folder _temp after encoding: 00001_out.h264 - Frame rate: 23.976 (24000/1001) FPS
But the desync remained

I could try to do as -QfG- wrote
Quote:
Open the file with mkvtoolnix-gui and change the framerate in the video settings
but I did not want to torment the video. I just changed the FPS audio for my new video (from 23. 976 to 24).The out of sync has disappeared. I have 15 audio streams, this is the main difficulty.

Last edited by hevron; 6th July 2020 at 19:55.
hevron is offline  
Old 6th July 2020, 20:12   #2075  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by videoh View Post
It works fine with DGDecNV when handled correctly.

The source VOB has the infamous black-frames-at-the-start-with-no-audio pathology. The timestamps reset after those frames and that is what causes the problem. You can see this by logging timestamps. Here's how to do it properly:

- Open the VOB in DGIndexNV.
- Skip forward 3 GOPs with the GOP forward button (it's only black video) and then set the project start there with the [ button.
- Save the project.
- Now the following script serves perfectly synced audio. I use 32-bit because my nicaudio.dll is 32-bit. You can play the script in VirtualDub32 for example.

Code:
loadplugin("dgdecodenv.dll")
loadplugin("nicaudio.dll")
vid=dgsource("Test.dgi",fieldop=1)
aud=NicAC3Source("Test T80 2_0ch 48KHz 192Kbps DELAY -90ms.ac3",2).DelayAudio(-0.09)
AudioDub(vid,aud)
And Bob's yer uncle.

Note, the video also has field-order transitions. I won't get into that as it does not bear on the sync issue and here the video is progressive (with 3:2 pulldown) so it is inconsequential.

This is the pedal-to-the-metal way to handle this stream. I cannot comment on what 3rd-party transcoders are doing, nor how they differ in their handling with DGIndex versus DGIndexNV.

EDIT: You can get away with skipping only two GOPs also, but use the correct delay from the demuxed AC3 filename in your script. I didn't try skipping only one GOP.
The fieldop=1 option in DGSource(...) was the magic key.
Just putting this extra option in it solved the out-of-sync problem.
I didn't even have to skip initial GOPs.

So all this fuss was about how to deal with 3:2 pulldown?
Thanks a lot for enlightening me, @videoh!

Last edited by JKyle; 6th July 2020 at 20:22.
JKyle is offline  
Old 6th July 2020, 21:22   #2076  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
That cannot be correct, because the run time should not be affected by fieldop 0 versus 1. On the other hand, fieldop=2 can change the run time. And I definitely see the desync without skipping GOPs. Are you using direct manual stuff like I did or doing it through staxriip? I have to step out now but will come back to this.

Last edited by videoh; 6th July 2020 at 21:24.
videoh is offline  
Old 6th July 2020, 22:24   #2077  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by videoh View Post
Are you using direct manual stuff like I did or doing it through staxriip?
I did it on StaxRip (2.1.3.7). As you know, StaxRip splits video and audio and deals with them separately.

And yes, I was mistaken. Audio out-of-sync problem does NOT occur with DGIndexNV as long as you delay audio by 281 milliseconds (video start time info gained by ffprobe), no matter whether you put fieldop=1 or not. (Maybe my temp files were messed up when I thought it did.)

But AviSynth+ 3.6.1 feeds source video (to NVEnc in my video encoding setting) at different frame rates depending on fieldop values, as is expected:
with fieldop=1, it feeds source video at 23.976fps (24000/1001fps), and without it, at 29.970fps (30000/1001fps).

(In both cases, I verified that audio sync problem did not occur.)

And as is intended, fieldop=1 tackles IVTC: there's combing with 29.970fps, and no combing with 23.976fps.

You can download those two videos from here and compare them yourself.

Log for no fieldop (fieldop=0): https://pastebin.com/jpE9xkgH
Log for fieldop=1: https://pastebin.com/QSYJH8Hz

Thanks for the clarification, @videoh.

Last edited by JKyle; 6th July 2020 at 22:55.
JKyle is offline  
Old 7th July 2020, 01:36   #2078  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Quote:
Originally Posted by JKyle View Post
Audio out-of-sync problem does NOT occur with DGIndexNV as long as you delay audio by 281 milliseconds
That's one way. I prefer to skip the weird GOPs and get the delay from the filename. But as they say, it's six of one and half a dozen of the other.

Quote:
Thanks for the clarification, @videoh.
My pleasure, Sir.

Quote:
As you know, ...
Don't assume that which is not in evidence. I don't know that much about staxrip and happily defer to you guys. Seems to be a very popular and well-executed application. We all hope to do as well.

Last edited by videoh; 7th July 2020 at 01:44.
videoh is offline  
Old 8th July 2020, 01:23   #2079  |  Link
Disturbance
Registered User
 
Join Date: Mar 2007
Posts: 26
@Stax76

Hello, I have been wondering if it was possible to implement a feature that allows you to cut a video by its Chapters. It is a feature from an old program I used to use called V.A.F.E. which is a program that stopped being supported or updated in 2015. As shown in the image it comes up in the preview page and you can select from the boxes which chapter chunks you want to select and what to cut out. After this it will also generate a "keyframes.qpf" for the encode to generate I frames for the start frame of the selected chapters that are selected. I am aware this is pretty niche, I am just asking the question is all

Failing that just a function that can generate a QPF file based on the current trimming/cutting functionality of Staxrip would be great (for inserting I frames).

Alternatively, if anyone else knows is there currently a way to generate a QPF file based on the cuts that already exists, just atm the current method I have for doing this is: cutting->preview code->paste code into AVSPmod->find frame numbers of the first frame of cut segments->manually put frames in a "keyframes.qpf" to import for encoding (eg "3000 I -1").


Last edited by Disturbance; 8th July 2020 at 02:02.
Disturbance is offline  
Old 8th July 2020, 20:37   #2080  |  Link
44vince44
Registered User
 
Join Date: May 2020
Posts: 188
@Patman
Hi Patman, I just noticed there are no ffmeg builds in your repository... is there a problem (hope not!!)
44vince44 is offline  
Closed Thread

Tags
aac, hdr, hevc, nvenc, staxrip, x264, x265

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.