[FFmpeg-devel] [PATCH 2/3 v2] avformat/mov: Populate packet duration using stts atom instead of guessing

Michael Niedermayer michael at niedermayer.cc
Mon Nov 25 03:46:23 EET 2024


Hi

On Thu, Nov 21, 2024 at 07:40:22PM -0300, James Almer wrote:
> From: Darren Mo <fumoboy007 at me.com>
> 
> Fixes tickets #7855 and #11312.
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
>  libavformat/isom.h                            |   3 +
>  libavformat/mov.c                             | 181 ++++++++++++++++--
>  tests/ref/fate/copy-trac236                   |   4 +-
>  tests/ref/fate/filter-fps                     |   1 +
>  tests/ref/fate/filter-fps-cfr                 |   1 +
>  tests/ref/fate/filter-meta-4560-rotate0       |   4 +-
>  tests/ref/fate/gaplessenc-itunes-to-ipod-aac  |   2 +-
>  tests/ref/fate/matroska-dovi-write-config8    |   4 +-
>  .../fate/matroska-non-rotation-displaymatrix  |   6 +-
>  tests/ref/fate/mov-aac-2048-priming           |   2 +-
>  tests/ref/fate/mov-zombie                     |   4 +-
>  11 files changed, 182 insertions(+), 30 deletions(-)

this does strange things to duration:

./ffmpeg -i mm-short.mpg -y -bitexact -t 1 -acodec aac -frag_duration 200k test2.mov
./ffprobe -v 0 test2.mov -show_packets -print_format compact

 packet|codec_type=video|stream_index=0|pts=10752|pts_time=0.840000|dts=10240|dts_time=0.800000|duration=512|duration_time=0.040000|size=2130|pos=77815|flags=___
 packet|codec_type=video|stream_index=0|pts=13312|pts_time=1.040000|dts=10752|dts_time=0.840000|duration=512|duration_time=0.040000|size=5123|pos=79945|flags=___
 packet|codec_type=video|stream_index=0|pts=12288|pts_time=0.960000|dts=11264|dts_time=0.880000|duration=512|duration_time=0.040000|size=3980|pos=85068|flags=___
 packet|codec_type=video|stream_index=0|pts=11776|pts_time=0.920000|dts=11776|dts_time=0.920000|duration=512|duration_time=0.040000|size=2266|pos=89048|flags=___
 packet|codec_type=video|stream_index=0|pts=12800|pts_time=1.000000|dts=12288|dts_time=0.960000|duration=512|duration_time=0.040000|size=2085|pos=91314|flags=___
-packet|codec_type=audio|stream_index=1|pts=38656|pts_time=0.805333|dts=38656|dts_time=0.805333|duration=1024|duration_time=0.021333|size=343|pos=93399|flags=K__
-packet|codec_type=audio|stream_index=1|pts=39680|pts_time=0.826667|dts=39680|dts_time=0.826667|duration=1024|duration_time=0.021333|size=338|pos=93742|flags=K__
-packet|codec_type=audio|stream_index=1|pts=40704|pts_time=0.848000|dts=40704|dts_time=0.848000|duration=1024|duration_time=0.021333|size=337|pos=94080|flags=K__
-packet|codec_type=audio|stream_index=1|pts=41728|pts_time=0.869333|dts=41728|dts_time=0.869333|duration=1024|duration_time=0.021333|size=326|pos=94417|flags=K__
-packet|codec_type=audio|stream_index=1|pts=42752|pts_time=0.890667|dts=42752|dts_time=0.890667|duration=1024|duration_time=0.021333|size=339|pos=94743|flags=K__
-packet|codec_type=audio|stream_index=1|pts=43776|pts_time=0.912000|dts=43776|dts_time=0.912000|duration=1024|duration_time=0.021333|size=336|pos=95082|flags=K__
-packet|codec_type=audio|stream_index=1|pts=44800|pts_time=0.933333|dts=44800|dts_time=0.933333|duration=1024|duration_time=0.021333|size=330|pos=95418|flags=K__
-packet|codec_type=audio|stream_index=1|pts=45824|pts_time=0.954667|dts=45824|dts_time=0.954667|duration=1024|duration_time=0.021333|size=333|pos=95748|flags=K__
-packet|codec_type=audio|stream_index=1|pts=46848|pts_time=0.976000|dts=46848|dts_time=0.976000|duration=1024|duration_time=0.021333|size=340|pos=96081|flags=K__
-packet|codec_type=audio|stream_index=1|pts=47872|pts_time=0.997333|dts=47872|dts_time=0.997333|duration=1024|duration_time=0.021333|size=337|pos=96421|flags=K__
-packet|codec_type=audio|stream_index=1|pts=48896|pts_time=1.018667|dts=48896|dts_time=1.018667|duration=1024|duration_time=0.021333|size=398|pos=96898|flags=K__
-packet|codec_type=audio|stream_index=1|pts=49920|pts_time=1.040000|dts=49920|dts_time=1.040000|duration=1024|duration_time=0.021333|size=367|pos=97296|flags=K__
-packet|codec_type=audio|stream_index=1|pts=50944|pts_time=1.061333|dts=50944|dts_time=1.061333|duration=1024|duration_time=0.021333|size=328|pos=97663|flags=K__
+packet|codec_type=audio|stream_index=1|pts=38656|pts_time=0.805333|dts=38656|dts_time=0.805333|duration=1070071408|duration_time=22293.154333|size=343|pos=93399|flags=K__
+packet|codec_type=audio|stream_index=1|pts=39680|pts_time=0.826667|dts=39680|dts_time=0.826667|duration=1070071408|duration_time=22293.154333|size=338|pos=93742|flags=K__
+packet|codec_type=audio|stream_index=1|pts=40704|pts_time=0.848000|dts=40704|dts_time=0.848000|duration=1070071408|duration_time=22293.154333|size=337|pos=94080|flags=K__
+packet|codec_type=audio|stream_index=1|pts=41728|pts_time=0.869333|dts=41728|dts_time=0.869333|duration=1070071408|duration_time=22293.154333|size=326|pos=94417|flags=K__
+packet|codec_type=audio|stream_index=1|pts=42752|pts_time=0.890667|dts=42752|dts_time=0.890667|duration=1070071408|duration_time=22293.154333|size=339|pos=94743|flags=K__
+packet|codec_type=audio|stream_index=1|pts=43776|pts_time=0.912000|dts=43776|dts_time=0.912000|duration=1070071408|duration_time=22293.154333|size=336|pos=95082|flags=K__
+packet|codec_type=audio|stream_index=1|pts=44800|pts_time=0.933333|dts=44800|dts_time=0.933333|duration=1070071408|duration_time=22293.154333|size=330|pos=95418|flags=K__
+packet|codec_type=audio|stream_index=1|pts=45824|pts_time=0.954667|dts=45824|dts_time=0.954667|duration=1070071408|duration_time=22293.154333|size=333|pos=95748|flags=K__
+packet|codec_type=audio|stream_index=1|pts=46848|pts_time=0.976000|dts=46848|dts_time=0.976000|duration=1070071408|duration_time=22293.154333|size=340|pos=96081|flags=K__
+packet|codec_type=audio|stream_index=1|pts=47872|pts_time=0.997333|dts=47872|dts_time=0.997333|duration=1070071408|duration_time=22293.154333|size=337|pos=96421|flags=K__
+packet|codec_type=audio|stream_index=1|pts=48896|pts_time=1.018667|dts=48896|dts_time=1.018667|duration=1070071408|duration_time=22293.154333|size=398|pos=96898|flags=K__
+packet|codec_type=audio|stream_index=1|pts=49920|pts_time=1.040000|dts=49920|dts_time=1.040000|duration=1070071408|duration_time=22293.154333|size=367|pos=97296|flags=K__
+packet|codec_type=audio|stream_index=1|pts=50944|pts_time=1.061333|dts=50944|dts_time=1.061333|duration=1070071408|duration_time=22293.154333|size=328|pos=97663|flags=K__

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241125/a726a6c8/attachment.sig>


More information about the ffmpeg-devel mailing list