Opened 13 years ago
Last modified 12 years ago
#1985 new defect
MKV audio delay ignored in MEncoder unless -ss is not 0
Reported by: | Owned by: | reimar | |
---|---|---|---|
Priority: | normal | Component: | core |
Version: | HEAD | Severity: | normal |
Keywords: | Cc: | temp0@… | |
Blocked By: | Blocking: | ||
Reproduced by developer: | no | Analyzed by developer: | no |
Description
5mb test file at http://www.spirton.com/uploads/Unsorted/AudioDelayTest.mkv
Using the following, the correct audio offset is used:
mencoder -ss 1 AudioDelayTest.mkv -oac lavc -of mpeg -ovc lavc -mc 0 -noskip -o file.mpeg
But take away the -ss or set it to 0 like:
mencoder AudioDelayTest.mkv -oac lavc -of mpeg -ovc lavc -mc 0 -noskip -o file.mpeg
or
mencoder -ss 0 AudioDelayTest.mkv -oac lavc -of mpeg -ovc lavc -mc 0 -noskip -o file.mpeg
And the audio offset is ignored. This problem affects MEncoder while MPlayer plays it perfectly.
Change History (16)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
By the way you can test this with any file you have, just load the file into MKVMerge and set a delay on the audio track; MEncoder will use the delay if you specify -ss but ignore it if you don't.
comment:3 by , 13 years ago
Cc: | added |
---|
Reproduced same behavior with all latest versions.
MEncoder doesn't count with audio delay when -ss is exactly zero. If I defined -ss 0.008 audio delay is fixed but it seems extraction starts from next key frame so final file miss few seconds from start.
I tried to use -ss 0 for video part and -ss 0.008 for audio part to obey this bug but it seems also audio extraction counts with video key frame so final file is totally out of sync(video start from beginning but connected audio starts from next key frame = A/V out of sync)
Many thanks for fix!!!!
ExSport
comment:4 by , 13 years ago
I just went through a lot of old versions of MEncoder to see when this bug was introduced and can confirm that this issue has existed since at least r24762 (from 2007), so it possibly has always been an issue, since I couldn't find builds older than that.
Of course most people would not notice it because most videos either have no audio delay or they only have a slight one.
comment:5 by , 13 years ago
Summary: | Audio delay setting ignored in MEncoder unless -ss has a value → MKV Audio delay setting ignored in MEncoder unless -ss has a value |
---|
comment:6 by , 13 years ago
Summary: | MKV Audio delay setting ignored in MEncoder unless -ss has a value → MKV audio delay ignored in MEncoder unless -ss is not 0 |
---|
comment:7 by , 13 years ago
(In reply to comment #4)
Of course most people would not notice it because most videos either have no
audio delay or they only have a slight one.
Almost all of my files are with audio delay because in past I bought many Blu-Ray documents without my native audio(never were released with my lang.) and later I added native audio track from DVD/TV so almost all of my files in library has delay, sometimes more than 7seconds which is hugely visible also in documents:-(
Please fix it if possible. I am using DLNA TV/PS3 for playing files so MEncoder is a must, MPlayer is not a solution but PS3MediaServer with MEncoder engine yes.
Many thanks again!
ExSport
comment:8 by , 13 years ago
Hopefully it will be sometimes fixed but I gave up on it...it seems nobody is interested in this bug unfortunatelly.
Regards ExSport
comment:9 by , 13 years ago
Unlikely. Not using -ss is interpreted by MPlayer to mean "process all data".
With AVI and other formats not (properly) supporting audio delay it has to start audio and video at the same time.
It should then fix it up over time, however by default only very slowly and by using -mc 0 you completely forbid it to do that.
It would be possible to make mencoder add silent audio, but that would be a new feature and nobody is working on new features for mencoder.
comment:10 by , 13 years ago
(In reply to comment #7)
Unlikely. Not using -ss is interpreted by MPlayer to mean "process all data".
With AVI and other formats not (properly) supporting audio delay it has to
start audio and video at the same time.
It should then fix it up over time, however by default only very slowly and by
using -mc 0 you completely forbid it to do that.
It would be possible to make mencoder add silent audio, but that would be a new
feature and nobody is working on new features for mencoder.
Thanks for the reply, Reimar.
So it's not possible to make it work without -ss, what about if we used -ss 0.01, would it be easier to modify MEncoder to be able to seek to actual times instead of keyframes or is that just as difficult?
comment:11 by , 13 years ago
I would expect that to work already with -edl and -hr-edl-seek.
I'd expect it should be possible and not too hard to make -hr-edl-seek behaviour also apply to -ss, but generally none of the regular MPlayer maintainers have time to add new features to mencoder (i.e. to do more than barely keep it working).
comment:12 by , 13 years ago
(In reply to comment #9)
I would expect that to work already with -edl and -hr-edl-seek.
I'd expect it should be possible and not too hard to make -hr-edl-seek
behaviour also apply to -ss, but generally none of the regular MPlayer
maintainers have time to add new features to mencoder (i.e. to do more than
barely keep it working).
Hi guys
Thanks for tip Reimar but unfortunately edl doesn't work.
When -ss not zero used, a/v sync is OK.
When -ss is zero and -edl file.edl -hr-edl-seek is used, it starts from non key frame also for AVC MKV files but unfortunately A/V is not fixed.
So for seek to exact frame it is great but it seems only -ss > 0 enables A/V sync routine but not -ss 0 plus -edl seeking.
For some files A/V mismatch was reduced with -hr-edl-seek but I had to use bigger "cut" than when -ss 0.05 is used so it skips to first keyframe.
Anyway I fixed this -ss "bug" another way in PS3MediaServer application so I am happy now.
Many thanks Reimar for further info so I now understand why noone is interested fixing this bug.
Happy New Year for everybody guys.
Thanks
ExSport
comment:13 by , 13 years ago
Yes, you are right, though I would express the reason a bit differently (which clarifies the problem in fixing): When using -hr-edl-seek mencoder still respects "-mc 0".
What you need is for it to ignore the -mc setting at the beginning, I pasted a quick untested hack that might do that below (though I admit it's more likely it won't quite work).
Fixing things so you don't need to use "-mc 0 -noskip" might be a better target.
Index: mencoder.c
===================================================================
--- mencoder.c (revision 34454)
+++ mencoder.c (working copy)
@@ -140,7 +140,7 @@
A-V sync:
static float default_max_pts_correction=-1;0.01f;
-static float max_pts_correction=0;default_max_pts_correction;
+static float max_pts_correction=1000;default_max_pts_correction;
static float c_total=0;
static float audio_preload=0.5;
comment:14 by , 13 years ago
(In reply to comment #11)
Yes, you are right, though I would express the reason a bit differently (which
clarifies the problem in fixing): When using -hr-edl-seek mencoder still
respects "-mc 0".
What you need is for it to ignore the -mc setting at the beginning, I pasted a
quick untested hack that might do that below (though I admit it's more likely
it won't quite work).
Fixing things so you don't need to use "-mc 0 -noskip" might be a better
target.
I never used "-mc 0 -noskip" and I always had same behavior when talking about -ss zero or nonzero or using -edl(tested after your tip so not much tests). In past with older MEncoder builds if -mc something wasn't defined, MEncoder ignored audio delay in stream so I used -mc 0.005 to obey it.
Now with new MEncoder versions also in case no -mc parameter is used, audio delay is detected and removed.
So all above I posted was without any -mc parameters. Hopefully SubJunk will test your suggestions, I am quite poor to be able compile MEncoder build:-)
Many thanks Reimar!
comment:15 by , 13 years ago
Hm, I only know about the given sample. -mc 100 instead of -mc 0 -noskip fixes the delay, though it seems to overshoot a bit in the middle (and quality is worse due to the (needlessly?) skipped frames).
My suggested patch however does not work.
The hack below however mostly works, but it's not acceptable as is.
Index: mencoder.c
===================================================================
--- mencoder.c (revision 34471)
+++ mencoder.c (working copy)
@@ -140,7 +140,7 @@
A-V sync:
static float default_max_pts_correction=-1;0.01f;
-static float max_pts_correction=0;default_max_pts_correction;
+static float max_pts_correction=1000;default_max_pts_correction;
static float c_total=0;
static float audio_preload=0.5;
@@ -1545,7 +1545,7 @@
AV_delay /= playback_speed;
AV_delay-=a_muxer_time-(v_muxer_time-(v_timer_corr+v_pts_corr));
compensate input video timer by av:
- x=AV_delay*0.1f;
+ x=AV_delay;*0.1f;
if(x<-max_pts_correction) x=-max_pts_correction; else
if(x> max_pts_correction) x= max_pts_correction;
if(default_max_pts_correction>=0)
comment:16 by , 12 years ago
I tried it with that patch and it seems to bring it closer to being in sync than before but still not the same as it is when -ss is used.
Forgot to add I tested it with r34132