Opened 2 years ago

Closed 2 years ago

Last modified 18 months ago

#9513 closed defect (fixed)

shortest cuts audio off early on 1fps video

Reported by: Cosmin Stejerean Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

This might be related to #9512 but the problem manifests itself differently and it's specific to low fps video, where it appears the audio cuts off as soon as the last frame is written rather than accounting for the last frame duration.

But similarly to #9512 it works differently on video copy vs video transcode.

Let's create the assets

% ffmpeg -f lavfi -i testsrc2=size=vga:rate=1 -t 10 -y video.mp4
% ffmpeg -f lavfi -i sine=1000 -t 30 -y music.m4a

Attempting a simple operation to edit the audio and leave the video alone, cutting audio off at the video duration

% ffmpeg -i music.m4a -i video.mp4 -filter_complex '[0:a:0] volume=1 [audio]' -map "[audio]" -map 1:v:0 -c:v libx264 -c:a libfdk_aac -shortest -y mixed-transcoded.mp4

This works, produces a 10s output and it plays correctly with audio through the end. But the video transcode is unnecessary given the video isn't being modified. Trying again with -c:v copy

% ffmpeg -i music.m4a -i video.mp4 -filter_complex '[0:a:0] volume=1 [audio]' -map "[audio]" -map 1:v:0 -c:v copy -c:a libfdk_aac -shortest -y mixed-copy.mp4

Based on a naive ffprobe inspection this appears correct with a total duration of 10s. But looking at the individual streams show that audio in fact is only 7s long (and attempting to play it cuts off audio early).

I originally assumed this was missing the last 1s due the frame duration, but the problem seems potentially worse as it's actually missing almost 3s of video

Change History (4)

comment:1 by pantheon_guillaume, 2 years ago

I can confirm that I am seeing the same problem in ffmpeg version 4.2.4-1ubuntu0.1, .mp4 vcodec libx264, both using acodec aac and ac3. I do not have the problem when using .webm vcodec libvpx-vp9 and acodec libopus.

My application supplies frames from python using vidgear, encoding the video to 25fps.

comment:2 by pantheon_guillaume, 2 years ago

Version: unspecified4.2.4

comment:3 by James, 2 years ago

Resolution: fixed
Status: newclosed

comment:4 by Carl Eugen Hoyos, 18 months ago

Component: undeterminedffmpeg
Version: 4.2.4git-master
Note: See TracTickets for help on using tickets.