[FFmpeg-user] Accurate seek times with multiple input files

Mountain Man txmountainman45 at gmail.com
Fri Jun 14 04:21:37 CEST 2013


Hello,

I'm trying to combine part of the video stream of an avi file with some
audio I've already processed.  Frame accuracy for the video is very
important because I will be merging the video back together later.
Unfortunately I haven't been able to figure out how to make this work if I
use -ss after the input file (more accurate).  For example, this command
works as expected:

ffmpeg  -ss 4 -i 100_0290.MOV    -i threesec.wav  -map 0:v -map 1:a  -t
3.003 -acodec copy -vcodec ffv1 -pix_fmt yuv420p -r 29.97  combined.avi

However, when I move the -ss portion to after the input files it is either
ignored or causes the audio to fail to copy (presumably because it is
trying to start 4 seconds in to a 3 second file).  For example, I tried:

ffmpeg   -i 100_0290.MOV  -i threesec.wav  -map 0:v -map 1:a -ss:0 4 -ss:1
0 -t 3.003 -acodec copy -vcodec ffv1 -pix_fmt yuv420p -r 29.97  combined.avi

But this gives me 3.003 seconds of audio and video from the beginning of
both files.  What I want is to start several seconds in from the video
stream but start the audio stream from 0.
Is there a way to map the start time to a specific stream so I can use it
after the input files?  Or do I need to pull out just the video stream and
then later combine it back with the separate audio?

The output of the second command (the one I can't make work) is:

ffmpeg   -i 100_0290.MOV  -i threesec.wav  -map 0:v -map 1:a -ss:0 4 -ss:1
0 -t 3.003 -acodec copy -vcodec ffv1 -pix_fmt yuv420p -r 29.97  combined.avi
ffmpeg version N-38182-g449558d Copyright (c) 2000-2013 the FFmpeg
developers
  built on Jun  4 2013 18:35:01 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --extra-libs=-ldl --enable-gpl --enable-libass
--enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libspeex --enable-libtheora
--enable-libvorbis --enable-libopus --enable-libvpx --enable-x11grab
--enable-libx264 --enable-nonfree --enable-version3
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 15.100 / 55. 15.100
  libavformat    55.  8.102 / 55.  8.102
  libavdevice    55.  2.100 / 55.  2.100
  libavfilter     3. 75.101 /  3. 75.101
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '100_0290.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2012-11-08 11:32:19
    comment         : KODAK PlaySport Video Camera, Zx3
    comment-eng     : KODAK PlaySport Video Camera, Zx3
  Duration: 00:01:45.71, start: 0.000000, bitrate: 8127 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], 7991 kb/s, 29.97 fps, 29.97 tbr, 90k tbn,
59.94 tbc
    Metadata:
      creation_time   : 2012-11-08 11:32:19
      handler_name    : Ambarella AVC
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
fltp, 128 kb/s
    Metadata:
      creation_time   : 2012-11-08 11:32:19
      handler_name    : Ambarella AAC
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, wav, from 'threesec.wav':
  Metadata:
    comment         : KODAK PlaySport Video Camera, Zx3
    encoder         : Lavf55.8.102
  Duration: 00:00:03.00, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo, s16, 1536 kb/s
Output #0, avi, to 'combined.avi':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    comment-eng     : KODAK PlaySport Video Camera, Zx3
    ICMT            : KODAK PlaySport Video Camera, Zx3
    ISFT            : Lavf55.8.102
    Stream #0:0(eng): Video: ffv1 (FFV1 / 0x31564646), yuv420p, 1280x720
[SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.97 tbn, 29.97 tbc
    Metadata:
      creation_time   : 2012-11-08 11:32:19
      handler_name    : Ambarella AVC
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz,
stereo, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> ffv1)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=   90 fps= 37 q=-1.0 Lsize=   28993kB time=00:00:03.00
bitrate=79092.0kbits/s
video:28415kB audio:563kB subtitle:0 global headers:0kB muxing overhead
0.052633%


More information about the ffmpeg-user mailing list