Ticket #1349 (reopened defect)
itsoffset doesn't work for second input file (audio)
| Reported by: | bombo | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | FFmpeg |
| Version: | git-master | Keywords: | itsoffset |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
this delays the video for 10s:
$ ffmpeg -itsoffset -00:00:10 -i video.avi -i audio.mp3 -codec copy muxed.avi
playing with mplayer shows that its working.
now i need the audio to be delayed 10s so it would be:
$ ffmpeg -i video.avi -itsoffset -00:00:10 -i audio.mp3 -codec copy muxed.avi
the result is no delay at all.
version is: ffmpeg-20120519-git-31dfe20-win32-static.7z
Change History
comment:2 follow-up: ↓ 4 Changed 13 months ago by mjs973
* Edit by mjs973: this information is wrong; see post below *
The -itsoffset option does not work the way you think it does.
Unless something has changed in the code, the behavior is to add (or subtract) a constant value to each *video* timestamp. It never modifies audio timestamps.
So your command will not work: You must shift the video stream, not try to shift the audio stream.
I think this ticket should be closed with resolution of "invalid".
comment:3 Changed 13 months ago by cehoyos
- Keywords audio mux removed
- Status changed from new to closed
- Resolution set to invalid
Thank you for the explanation!
comment:4 in reply to: ↑ 2 Changed 13 months ago by bombo
Replying to mjs973:
The -itsoffset option does not work the way you think it does.
‘-itsoffset offset (input)’
Set the input time offset in seconds. [-]hh:mm:ss[.xxx] syntax is also supported. The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by offset seconds.
(http://ffmpeg.org/ffmpeg.html)
someone should add *video* there, i thought it would modify *any* 'input files'
Unless something has changed in the code, the behavior is to add (or subtract) a constant value to each *video* timestamp. It never modifies audio timestamps.
So your command will not work: You must shift the video stream, not try to shift the audio stream.
well ok, so i need to shift the video stream 10s backwards (audio is 10s early)
it works for positive values (forwards):
Y:\test>ffmpeg -y -itsoffset 00:00:10 -i video.avi -i audio.mp3 -codec copy muxed.avi
ffmpeg version N-40824-g31dfe20 Copyright (c) 2000-2012 the FFmpeg developers built on May 19 2012 00:45:59 with gcc 4.6.3 configuration: --enable-gpl --ena
ble-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libop
encore-amrnb --enable-libopencore-amrwb --enable
-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-li
btheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxv
id --enable-zlib
libavutil 51. 53.100 / 51. 53.100
libavcodec 54. 21.101 / 54. 21.101
libavformat 54. 5.100 / 54. 5.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 74.101 / 2. 74.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 12.100 / 0. 12.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, avi, from 'video.avi':
Metadata:
encoder : Lavf54.5.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 1237 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x416 [SAR 1:1 DAR 45:26], 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0228f040] max_analyze_duration 5000000 reached at 5016000
Input #1, mp3, from 'audio.mp3':
Metadata:
encoder : Lavf54.5.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 183 kb/s
Stream #1:0: Audio: mp3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, avi, to 'muxed.avi':
Metadata:
ISFT : Lavf54.5.100
Stream #0:0: Video: mpeg4 (XVID / 0x44495658), yuv420p, 720x416 [SAR 1:1 DAR 45:26], q=2-31, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1500 fps=0.0 q=-1.0 Lsize= 10476kB time=00:01:00.00 bitrate=1430.4kbits/s
video:9020kB audio:1346kB global headers:0kB muxing overhead 1.063745%
result: audio starts at 00:00:00, video starts at 00:00:10 (10s later)
but the problem is actually, the audio is 10s early, so i expect negative values to do the trick:
Y:\test>ffmpeg -y -itsoffset -00:00:10 -i video.avi -i audio.mp3 -codec copy muxed.avi
ffmpeg version N-40824-g31dfe20 Copyright (c) 2000-2012 the FFmpeg developers built on May 19 2012 00:45:59 with gcc 4.6.3
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-lib
ass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-
libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 51. 53.100 / 51. 53.100
libavcodec 54. 21.101 / 54. 21.101
libavformat 54. 5.100 / 54. 5.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 74.101 / 2. 74.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 12.100 / 0. 12.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, avi, from 'video.avi':
Metadata:
encoder : Lavf54.5.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 1237 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x416 [SAR 1:1 DAR 45:26], 25 tbr, 25 tbn, 25 tbc
[mp3 @ 0228f040] max_analyze_duration 5000000 reached at 5016000
Input #1, mp3, from 'audio.mp3':
Metadata:
encoder : Lavf54.5.100
Duration: 00:01:00.00, start: 0.000000, bitrate: 183 kb/s
Stream #1:0: Audio: mp3, 48000 Hz, stereo, s16, 192 kb/s
Output #0, avi, to 'muxed.avi':
Metadata:
ISFT : Lavf54.5.100
Stream #0:0: Video: mpeg4 (XVID / 0x44495658), yuv420p, 720x416 [SAR 1:1 DAR 45:26], q=2-31, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1500 fps=0.0 q=-1.0 Lsize= 10470kB time=00:00:50.00 bitrate=1715.5kbits/s
video:9020kB audio:1346kB global headers:0kB muxing overhead 1.007220%
result: audio + video play at the same time, 00:00:00, no delay at all.
i'm not sure what it is supposed to do with negative values... skip/remove the seconds from the video stream?
comment:5 Changed 13 months ago by mjs973
So, are you saying that -10 didn't give the result you wanted?
There are two experiments you could try:
1) the .avi container is fairly dumb: it has no timestamps. Have you tried using a better container (.mp4 or .mkv) for the output file to see if that works any better? I'm not sure which containers know how to handle XVID and mp3.
~2) There could be a bug when two input files are used. The -itsoffset feature is typically used on a single input file. Have you tried muxing the two streams into a single file without using -itsoffset, then doing the time shift by re-muxing that one file with -itsoffset?~
comment:6 Changed 13 months ago by mjs973
I've looked into this further. My description in comment 2 doesn't match the behavior of current git, so either I mis-remembered or something changed.
This command should display file1 content one second earlier than file2 content:
ffmpeg -itsoffset -1 -i file1.ts -i file2.ts -vcodec copy -acodec copy -map 0:0 -map 1:1 out.ts
1) What I see is that -itsoffset adds or subtracts from all the timestamps (both the video and audio streams) in a file. So this option is only going to be useful when remuxing from separate input files.
2) outfile has expected playback behavior with .ts and .mkv containers.
3) It does not work with .avi (no timestamps, so not a surprise)
4) It does not work with .mp4 container (a bug?)



Complete, uncut console output missing.