[MEncoder-users] Time Sync problems transcoding an Android MP4 video

Walter Belhaven wbelhaven at yahoo.com
Sat Apr 20 18:45:19 CEST 2013


Hi,

I recorded a video on my Android device using the "DVD" preset and am trying to slice and dice it and/or transcode it with mencoder, and am having a/v sync issues.

Here's what mplayer tells me I'm starting with:

c:\Users\Jim\Desktop\mplayer>mplayer -identify -frames 0 droid.mp4
mplayer -identify -frames 0 droid.mp4
MPlayer Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team
getch2: 6 can't get number of input events  [disabling console input]

Playing droid.mp4.
libavformat file format detected.
ID_AUDIO_ID=0
ID_AID_0_LANG=eng
[lavf] stream 0: audio (aac), -aid 0, -alang eng
ID_VIDEO_ID=0
[lavf] stream 1: video (h264), -vid 0
VIDEO:  [H264]  720x480  24bpp  30.000 fps  6070.9 kbps (741.1 kbyte/s)
Clip info:
 major_brand: isom
ID_CLIP_INFO_NAME0=major_brand
ID_CLIP_INFO_VALUE0=isom
 minor_version: 0
ID_CLIP_INFO_NAME1=minor_version
ID_CLIP_INFO_VALUE1=0
 compatible_brands: isom3gp4
ID_CLIP_INFO_NAME2=compatible_brands
ID_CLIP_INFO_VALUE2=isom3gp4
ID_CLIP_INFO_N=3
Load subtitles in ./
ID_FILENAME=droid.mp4
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=6070912
ID_VIDEO_WIDTH=720
ID_VIDEO_HEIGHT=480
ID_VIDEO_FPS=30.000
ID_VIDEO_ASPECT=1.5000
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=127992
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_START_TIME=0.00
ID_LENGTH=1093.74
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
ID_VIDEO_CODEC=ffh264
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 15999->176400)
ID_AUDIO_BITRATE=127992
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [dsound] 44100Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=ffaac
Starting playback...


Exiting... (End of file)
ID_EXIT=EOF



When I try to cut a clip out of that with mencoder, I get this:

c:\Users\Jim\Desktop\mplayer>mencoder -oac copy -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
mencoder -oac copy -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team
success: format: 0  data: 0x0 - 0x328fffab
libavformat file format detected.
[lavf] stream 0: audio (aac), -aid 0, -alang eng
[lavf] stream 1: video (h264), -vid 0
VIDEO:  [H264]  720x480  24bpp  30.000 fps  6070.9 kbps (741.1 kbyte/s)
[V] filefmt:44  fourcc:0x34363248  size:720x480  fps:30.000  ftime:=0.0333
videocodec: framecopy (720x480 24bpp fourcc=34363248)
Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.

Exiting...

So I dutifully comply and get this:

c:\Users\Jim\Desktop\mplayer>mencoder -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
mencoder -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team
success: format: 0  data: 0x0 - 0x328fffab
libavformat file format detected.
[lavf] stream 0: audio (aac), -aid 0, -alang eng
[lavf] stream 1: video (h264), -vid 0
VIDEO:  [H264]  720x480  24bpp  30.000 fps  6070.9 kbps (741.1 kbyte/s)
[V] filefmt:44  fourcc:0x34363248  size:720x480  fps:30.000  ftime:=0.0333
videocodec: framecopy (720x480 24bpp fourcc=34363248)
Forcing output audio format tag to 0x706d.
audiocodec: framecopy (format=706d chans=2 rate=44100 bits=16 B/s=15999 sample-0)
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.
Pos:  11.1s    334f ( 1%)  0.00fps Trem:   1min 729mb  A-V:-0.069 [5939:128]

1 duplicate frame(s)!
Pos:  11.5s    344f ( 1%)  0.00fps Trem:   1min 739mb  A-V:-0.069 [5908:128]

1 duplicate frame(s)!
Pos:  11.8s    354f ( 1%)  0.00fps Trem:   1min 725mb  A-V:-0.069 [5871:128]

 ----8<----- (540 more of these) ----8<-----

1 duplicate frame(s)!
Pos: 210.0s   5758f (20%) 350.90fps Trem:   1min 804mb  A-V:-0.049 [6617:128]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 6616.601 kbit/s  (827075 B/s)  size: 173713346 bytes  210.033 secs  5758 frames

Audio stream:  128.016 kbit/s  (16001 B/s)  size: 3360432 bytes  210.001 secs


As you can see, tons of "duplicate frame(s)" warnings, and the result is a file with extreme a/v sync issues when I play it with mplayer.   (The audio lags the video by progressively more time as it plays.)   Just for kicks I pretended the video was 24fps, and tried this:

c:\Users\Jim\Desktop\mplayer>mencoder -fps 24 -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
mencoder -fps 24 -oac copy -fafmttag 0x706d -ovc copy droid.mp4 -ss 00:00:00 -endpos 00:03:30 -o output.avi
MEncoder Sherpya-SVN-r33883-4.2.5 (C) 2000-2011 MPlayer Team
success: format: 0  data: 0x0 - 0x328fffab
libavformat file format detected.
[lavf] stream 0: audio (aac), -aid 0, -alang eng
[lavf] stream 1: video (h264), -vid 0
VIDEO:  [H264]  720x480  24bpp  30.000 fps  6070.9 kbps (741.1 kbyte/s)
[V] filefmt:44  fourcc:0x34363248  size:720x480  fps:30.000  ftime:=0.0333
Input fps will be interpreted as 24.000 instead.
videocodec: framecopy (720x480 24bpp fourcc=34363248)
Forcing output audio format tag to 0x706d.
audiocodec: framecopy (format=706d chans=2 rate=44100 bits=16 B/s=15999 sample-0)
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.
Pos:   1.0s     25f ( 0%)  0.00fps Trem:   0min 300mb  A-V:0.085 [0:130]

Skipping frame!
Pos:   1.4s     35f ( 0%)  0.00fps Trem:   0min 407mb  A-V:0.085 [5685:130]

Skipping frame!
Pos:   1.8s     45f ( 0%)  0.00fps Trem:   0min 380mb  A-V:0.085 [5397:129]

   ------8<------- (248 more of these) ---------8<----------

Skipping frame!
Pos: 210.0s   5293f (19%) 554.82fps Trem:   0min 767mb  A-V:0.064 [5892:128]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 5891.746 kbit/s  (736468 B/s)  size: 154689022 bytes  210.042 secs  5293 frames

Audio stream:  128.016 kbit/s  (16001 B/s)  size: 3360432 bytes  210.001 secs



Tons of "Skipping frame!" warnings, as you can see.  This file has various video artifacts but at least it maintains sync between the audio and video.

I've also tried some "real" transcoding, instead of -oac copy and instead of -ovc copy (and both).  I've also tried using different output containers, but every time I omit -fps 24 the a/v sync is horrible.

So, what am I doing wrong?  Any help is very much appreciated.

Cheers,
WB


More information about the MEncoder-users mailing list