Opened 15 years ago

#1488 new defect

A/V desync when encoding with yadif=1

Reported by: ashaduri@… Owned by: reimar
Priority: normal Component: vf
Version: HEAD Severity: normal
Keywords: Cc:
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

I have this problem with mencoder:
Whenever I try to encode with yadif=1 (50 fps output in case of PAL), I get A/V desync, the sound is about 150ms late. That is, when I play the result with "mplayer -delay 0.15 test.avi", everything's ok.

The (simplified) command is:
$ mencoder -vf yadif=1,harddup -ovc lavc -lavcopts vcodec=mpeg4:keyint=132:threads=2:vbitrate=1000 -fps 50 -ofps 50 -oac copy -dvd-device . dvd://1 -aid 0 -o test.avi -endpos 0:2:0

If I encode it with yadif=0 (25 fps output, same fps as the source), there is no delay:
$ mencoder -vf yadif=0,harddup -ovc lavc -lavcopts vcodec=mpeg4:keyint=132:threads=2:vbitrate=1000 -oac copy -dvd-device . dvd://1 -aid 0 -o test.avi -endpos 0:2:0

I get it with any DVD I try to encode. The issue has been confirmed on MPlayer mailing list.

The delay always seems to be around 150ms. I thought about correcting it manually on the container level or during encoding (-audio-delay option), but there's visible junk in the beginning of the video if I do that, and it interferes with the possibility of joining the files later. Plus, I need to know the exact value to use.

Things I've tried:

  • Encoding audio track too (to cbr mp3). The delay is still there.
  • Encoding video separately (-of rawvideo), then muxing audio (both original and encoded to mp3) to mkv container using mkvmerge. The delay is still there.
  • Using -mc 0 with -oac copy. I actually get the reverse situation here - about 100ms _video_ delay.
  • Using -mc 0 with audio encode. This is the only one that seems to be in sync. Of course, this has the disadvantage of re-encoding the already lossy audio. Plus, -mc 0 disables all kinds of A/V sync, and since my sources are definitely not 100% good, it will cause the sync to go bad for most of them.

This issue really makes yadif=1 (or, generally, high quality double-fps
encoding) unusable in mencoder.

Here's the mencoder output:


$ mencoder -vf yadif=1,harddup -ovc lavc -lavcopts vcodec=mpeg4:keyint=132:threads=2:vbitrate=1000 -fps 50 -ofps 50 -oac copy -dvd-device . dvd://1 -aid 0 -o test.avi -endpos 0:2:0
MEncoder SVN-r29352-4.3 (C) 2000-2009 MPlayer Team
libdvdread: Using libdvdcss version 1.2.10 for DVD access
libdvdread: Couldn't find device name.
There are 1 titles on this DVD.
There are 1 angles in this DVD title.
audio stream: 0 format: mpeg1 (stereo) language: unknown aid: 0.
audio stream: 1 format: ac3 (stereo) language: unknown aid: 129.
number of audio channels on disk: 2.
number of subtitles on disk: 0
success: format: 2 data: 0x0 - 0x1c74e000
MPEG-PS file format detected.
VIDEO: MPEG2 720x576 (aspect 3) 25.000 fps 8197.6 kbps (1024.7 kbyte/s)
[V] filefmt:2 fourcc:0x10000002 size:720x576 fps:25.000 ftime:=0.0400
Input fps will be interpreted as 50.000 instead.
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 256.0 kbit/16.67% (ratio: 32000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [harddup]
Opening video filter: [yadif=1]
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 720 x 576 (preferred colorspace: Mpeg PES)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Unsupported PixelFormat -1
Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
==========================================================================
audiocodec: framecopy (format=50 chans=2 rate=48000 bits=16 B/s=32000 sample-1)
VDec: vo config request - 720 x 576 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
videocodec: libavcodec (720x576 fourcc=34504d46 [FMP4])
[mpeg2video @ 0x15a7d30]ac-tex damaged at 1 1
[mpeg2video @ 0x15a7d30]Warning MVs not available
[mpeg2video @ 0x15a7d30]concealing 1575 DC, 1575 AC, 1575 MV errors
Pos: 0.0s 1f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
1 duplicate frame(s)!
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
New_Face failed. Maybe the font path is wrong.n 0mb A-V:0.002 [0:0]
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

1 duplicate frame(s)!
Pos: 0.8s 22f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.042 [0:256]
Skipping frame!
Pos: 1.2s 32f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.042 [1625:256]
Skipping frame!
Pos: 1.6s 42f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.041 [1473:256]
Skipping frame!
Pos: 2.1s 57f ( 0%) 43.61fps Trem: 0min 0mb A-V:0.041 [1371:256]
Skipping frame!
Pos: 3.2s 84f ( 0%) 44.23fps Trem: 0min 0mb A-V:0.041 [1330:256]
Skipping frame!
Pos: 34.5s 869f ( 0%) 41.43fps Trem: 47min 739mb A-V:0.041 [1049:256]
Skipping frame!
Pos: 120.0s 3008f ( 2%) 40.79fps Trem: 47min 713mb A-V:-0.011 [1009:256]
Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1009.791 kbit/s (126223 B/s) size: 15151919 bytes 120.040 secs 3008 frames

Audio stream: 256.000 kbit/s (32000 B/s) size: 3840000 bytes 120.000 secs

Change History (0)

Note: See TracTickets for help on using tickets.