[FFmpeg-user] -itsoffset doesn't work for mp4/mov files

Xinglong Wu cakuba at gmail.com
Thu Oct 25 11:14:40 CEST 2012


Hi, guys,

     I downloaded and compiled the latest tarball, FFmpeg 1.0 "Angel",
and ffmpeg works fine. Today, I tried to merge a video and an audio
stream together into a single file with "-itsoffset" to solve the
out-of-sync problem. The following command works perfectly for a FLV
file, and delays the audio stream for 2 seconds,

ffmpeg -y -i mjtest.flv -itsoffset 2 -i mjtest.flv -map 0:v -map 1:a
-vcodec copy -acodec copy test.flv

however, the exactly same command for mp4 or mov files produces no
error but I haven't observed any delay in audio stream,

ffmpeg -y -i 720p.mp4 -itsoffset 2 -i 720p.mp4 -map 0:v -map 1:a
-vcodec copy -acodec copy test.mp4
ffmpeg -y -i kids.mov -itsoffset 2 -i kids.mov -map 0:v -map 1:a
-vcodec copy -acodec copy test.mov

More info about these two files (kids.mov was taken directly from my iPhone)

=============================================
[root at c05 TEST]# ffprobe kids.mov
ffprobe version 1.0 Copyright (c) 2007-2012 the FFmpeg developers
  built on Oct 24 2012 17:36:22 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-libx264 --enable-gpl --enable-pthreads
--enable-avfilter --enable-filter=movie
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '../kids.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2012-07-05 01:31:08
    encoder         : 5.0.1
    encoder-chi     : 5.0.1
    date            : 2012-07-05T09:31:08+0800
    date-chi        : 2012-07-05T09:31:08+0800
  Duration: 00:02:18.36, start: 0.000023, bitrate: 10485 kb/s
    Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661),
yuv420p, 1280x720, 10412 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc
    Metadata:
      creation_time   : 2012-07-05 01:31:08
      handler_name    : Core Media Data Handler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono,
s16, 63 kb/s
    Metadata:
      creation_time   : 2012-07-05 01:31:09
      handler_name    : Core Media Data Handler

[root at c05 TEST]# ffprobe 720p.mp4
ffprobe version 1.0 Copyright (c) 2007-2012 the FFmpeg developers
  built on Oct 24 2012 17:36:22 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-libx264 --enable-gpl --enable-pthreads
--enable-avfilter --enable-filter=movie
  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '720p.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2012-03-30 10:31:08
    encoder         : Lite MP4 Tool v2.3
  Duration: 01:26:11.24, start: 0.000000, bitrate: 1557 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
1280x720, 1426 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2012-03-30 10:31:08
      handler_name    : Imported with GPAC 0.4.6-DEV (internal rev. 5)
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz,
stereo, s16, 127 kb/s
    Metadata:
      creation_time   : 2012-03-30 10:31:13
      handler_name    : GPAC ISO Audio Handler

=====================================

I do notice there are two open ticket
(http://roundup.libav.org/issue359 and
https://ffmpeg.org/trac/ffmpeg/ticket/1349) for "-itsoffset",
especially the second one, and tried different ways (use ts container,
swith the input order, etc..)  to see if the streams in mp4/mov can be
delayed. I even tried different branches of FFmpeg (0.11, 0.9, and
0.5), but I have no success. Can anyone give me a hint if it is
possible to use "-itsoffset" for mp4/mov files? Thanks.

Brett


More information about the ffmpeg-user mailing list