Opened 2 months ago

Last modified 2 months ago

#7353 new defect

Option -ss on output with -c copy uses dts instead of pts

Reported by: Misaki Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: dts, pts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Editing scenario: have a finished video, want to copy audio from another video starting at a certain point.

If you use the command

ffmpeg -ss 11 -i video1.webm -i video2.mp4 -c copy output.mkv

then ffmpeg will seek to the video keyframe before 11 in video1.webm, and copy audio from there, instead of from 11.

If you add -ss 0 to the output, it trims audio before 11. But due to this bug, if the first dts of video2.mp4 is negative, it also trims the first group of pictures.

How to replicate:

ffmpeg -filter_complex color=black -t 2 -g 25 black.mp4; ffmpeg -i black.mp4 -c copy -ss 0 black2.mp4; ffmpeg -i black.mp4 -ss 0 black3.mp4

The first file is 50 frames. The second, using -c copy, is only 25 frames. The third, not copying, is 50 frames. Verbose output for these commands attached to report.

The desired behaviour is that packets are trimmed based on their presentation timestamp (pts), not their decode timestamp (dts).

Attachments (3)

ffmpeg-20180812-155540.log (13.2 KB) - added by Misaki 2 months ago.
First command's verbose output
ffmpeg-20180812-155542.log (11.7 KB) - added by Misaki 2 months ago.
Second command's verbose output
ffmpeg-20180812-155543.log (25.9 KB) - added by Misaki 2 months ago.
Third command's verbose output

Download all attachments as: .zip

Change History (5)

Changed 2 months ago by Misaki

First command's verbose output

Changed 2 months ago by Misaki

Second command's verbose output

Changed 2 months ago by Misaki

Third command's verbose output

comment:1 Changed 2 months ago by Gyan

For your root use case, you can run

ffmpeg -seek2any 1 -ss 11 -i video1.webm -i video2.mp4 -c copy -map 1:v -map 0:a output.mkv

For supporting demuxers (like Matroska), this won't seek to an earlier KF.

comment:2 Changed 2 months ago by Misaki

Thanks

Note: See TracTickets for help on using tickets.