Opened 4 days ago

Last modified 41 hours ago

#7677 reopened defect

Some converted video files fail miserably with Apple video players

Reported by: forthrin Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm converting videos to watch on a 3rd generation iPod Nano. Most videos work fine, but maybe 10% of all videos, specifically around 12 minutes, either stop (the video player exits back to the list of videos), or video/audio gets out of sync (video skips ahead several minutes, while audio keeps correct position).

Interestingly, videos that fail on the iPod Nano also fail in iTunes and QuickTime? on the Mac, but in different places. One video plays fine in QuickTime? until 3:45, after which video fails to play while audio plays fine. At this point, pausing QuickTime? causes VTDecoderXPCService to use max CPU.

Notice also:

  • The videos play fine in VLC (3.0.3) or mplayer (4.2.1) on macOS (10.12.6)
  • The problem persists if I remove the audio track (ffmpeg -an)

By trial and error, I've noticed that explicitly setting the output framerate identical to the input framerate, the problem magically disappears. (I realise "identical" may not be the case, as there may be rounding involved.)

At any rate, I'd like to understand the problem properly:

  • Is this a bug in FFmpeg or not?
  • Why do Apple video players gravely fail with some of these videos?
  • What is the proper way to solve the problem? (Since the input framerate may vary for input videos, I'd like to use an option that does not require me to manually change the command line)

Attempt A: Converting without specifying the output framerate explicitly.

$ ffmpeg -hide_banner -y -i in.avi -vcodec libx264 -acodec aac -ac 2 -ar 44100 -ab 128k -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf scale=320:240 out.mp4
Input #0, avi, from 'in.avi':
  Metadata:
    encoder         : transcode-1.0.2
  Duration: 00:51:32.02, start: 0.000000, bitrate: 952 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 806 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[mpeg4 @ 0x7ffe98831400] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
[libx264 @ 0x7ffe98813000] using SAR=936/935
[libx264 @ 0x7ffe98813000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7ffe98813000] profile Constrained Baseline, level 3.0
[libx264 @ 0x7ffe98813000] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 936:935 DAR 1248:935], q=-1--1, 23.98 fps, 2997003.00 tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc58.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.18.100 aac
[mpeg4 @ 0x7ffe9882e200] Discarding excessive bitstream in packed xvid
[mpeg4 @ 0x7ffe98834600] Discarding excessive bitstream in packed xvid
frame=74135 fps=260 q=-1.0 Lsize=  144392kB time=00:51:32.03 bitrate= 382.6kbits/s dup=2 drop=0 speed=10.8x    
video:94123kB audio:48522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.224464%
[libx264 @ 0x7ffe98813000] frame I:739   Avg QP:20.80  size:  6684
[libx264 @ 0x7ffe98813000] frame P:73396 Avg QP:24.20  size:  1246
[libx264 @ 0x7ffe98813000] mb I  I16..4: 29.5%  0.0% 70.5%
[libx264 @ 0x7ffe98813000] mb P  I16..4:  1.8%  0.0%  2.1%  P16..4: 40.3% 14.3%  5.0%  0.0%  0.0%    skip:36.5%
[libx264 @ 0x7ffe98813000] coded y,uvDC,uvAC intra: 51.2% 70.5% 32.0% inter: 15.6% 26.8% 1.3%
[libx264 @ 0x7ffe98813000] i16 v,h,dc,p: 43% 20% 15% 22%
[libx264 @ 0x7ffe98813000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 19% 17%  6%  8%  8%  7%  6%  5%
[libx264 @ 0x7ffe98813000] i8c dc,h,v,p: 55% 17% 21%  6%
[libx264 @ 0x7ffe98813000] ref P L0: 81.9% 10.9%  7.2%
[libx264 @ 0x7ffe98813000] kb/s:249.37
[aac @ 0x7ffe99800c00] Qavg: 197.591

Attempt B: The exact same thing, only with "-r 23.98" explicitly added.

$ ffmpeg -hide_banner -y -i in.avi -r 23.98 -vcodec libx264 -acodec aac -ac 2 -ar 44100 -ab 128k -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf scale=320:240 out.mp4
Input #0, avi, from 'in.avi':
  Metadata:
    encoder         : transcode-1.0.2
  Duration: 00:51:32.02, start: 0.000000, bitrate: 952 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 806 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[mpeg4 @ 0x7fbc30827400] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
[libx264 @ 0x7fbc31034400] using SAR=936/935
[libx264 @ 0x7fbc31034400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fbc31034400] profile Constrained Baseline, level 3.0
[libx264 @ 0x7fbc31034400] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 936:935 DAR 1248:935], q=-1--1, 23.98 fps, 19184 tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc58.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.18.100 aac
[mpeg4 @ 0x7fbc30809000] Discarding excessive bitstream in packed xvid
[mpeg4 @ 0x7fbc3082a600] Discarding excessive bitstream in packed xvid
frame=74147 fps=285 q=-1.0 Lsize=  144391kB time=00:51:32.03 bitrate= 382.5kbits/s dup=14 drop=0 speed=11.9x    
video:94121kB audio:48522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.224970%
[libx264 @ 0x7fbc31034400] frame I:739   Avg QP:20.80  size:  6684
[libx264 @ 0x7fbc31034400] frame P:73408 Avg QP:24.20  size:  1246
[libx264 @ 0x7fbc31034400] mb I  I16..4: 29.5%  0.0% 70.5%
[libx264 @ 0x7fbc31034400] mb P  I16..4:  1.8%  0.0%  2.1%  P16..4: 40.3% 14.3%  5.0%  0.0%  0.0%    skip:36.5%
[libx264 @ 0x7fbc31034400] coded y,uvDC,uvAC intra: 51.2% 70.5% 31.9% inter: 15.6% 26.8% 1.3%
[libx264 @ 0x7fbc31034400] i16 v,h,dc,p: 43% 20% 15% 21%
[libx264 @ 0x7fbc31034400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 19% 17%  6%  8%  8%  7%  6%  5%
[libx264 @ 0x7fbc31034400] i8c dc,h,v,p: 55% 17% 21%  6%
[libx264 @ 0x7fbc31034400] ref P L0: 81.9% 10.9%  7.1%
[libx264 @ 0x7fbc31034400] kb/s:249.36
[aac @ 0x7fbc30812600] Qavg: 197.591

Version information:

$ ffmpeg
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-nonfree
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100

Attachments (1)

c.mp4.gz (86.8 KB) - added by forthrin 3 days ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 4 days ago by cehoyos

Please test current FFmpeg git head and remove -hide_banner from your command line to make this a valid ticket.

comment:2 Changed 4 days ago by forthrin

Exact same playback problems with Git head.

$ git clone git://source.ffmpeg.org/ffmpeg
$ ./configure --enable-libx264 --enable-gpl
$ make
$ ffmpeg -y -i in.avi -vcodec libx264 -acodec aac -ac 2 -ar 44100 -ab 128k -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf scale=320:240 out.mp4
ffmpeg version git-2019-01-12-1ea5529 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --enable-libx264 --enable-gpl
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 43.101 / 58. 43.101
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, avi, from 'in.avi':
  Metadata:
    encoder         : transcode-1.0.2
  Duration: 00:51:32.02, start: 0.000000, bitrate: 952 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 806 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[mpeg4 @ 0x7ff771800600] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
[libx264 @ 0x7ff770002000] using SAR=936/935
[libx264 @ 0x7ff770002000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7ff770002000] profile Constrained Baseline, level 3.0
[libx264 @ 0x7ff770002000] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.25.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 936:935 DAR 1248:935], q=-1--1, 23.98 fps, 2997003.00 tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc58.43.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.43.101 aac
[mpeg4 @ 0x7ff771803800] Discarding excessive bitstream in packed xvid
frame=74135 fps=270 q=-1.0 Lsize=  140788kB time=00:51:32.03 bitrate= 373.0kbits/s dup=2 drop=0 speed=11.3x    
video:90518kB audio:48522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.256773%
[libx264 @ 0x7ff770002000] frame I:1024  Avg QP:20.59  size:  5918
[libx264 @ 0x7ff770002000] frame P:73111 Avg QP:24.07  size:  1185
[libx264 @ 0x7ff770002000] mb I  I16..4: 32.4%  0.0% 67.6%
[libx264 @ 0x7ff770002000] mb P  I16..4:  1.8%  0.0%  1.9%  P16..4: 41.4% 14.0%  4.9%  0.0%  0.0%    skip:36.0%
[libx264 @ 0x7ff770002000] coded y,uvDC,uvAC intra: 50.4% 70.2% 32.0% inter: 14.9% 27.0% 1.3%
[libx264 @ 0x7ff770002000] i16 v,h,dc,p: 43% 20% 15% 22%
[libx264 @ 0x7ff770002000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 17% 17%  6%  8%  8%  7%  7%  5%
[libx264 @ 0x7ff770002000] i8c dc,h,v,p: 55% 16% 22%  6%
[libx264 @ 0x7ff770002000] ref P L0: 81.1% 11.4%  7.4%
[libx264 @ 0x7ff770002000] kb/s:239.81
[aac @ 0x7ff770005a00] Qavg: 197.591

comment:3 Changed 4 days ago by cehoyos

Please attach the first 2.5 MB of your input file.

comment:4 Changed 3 days ago by cehoyos

Please consider to update 2MB instead of 2KB to make reproducing the issue easier (or at least 1MB).

comment:5 Changed 3 days ago by compn

why arent you using -f ipod ?

comment:6 Changed 3 days ago by forthrin

Exact same playback problems with -f ipod. Sorry about the KB/MB mixup. Nevertheless, 2 MB equals 10 seconds, while problems occur after 3-4 minutes, so that won't be much help. Let me know how else I can provide necessary input, like verbose output or debug information.

comment:7 Changed 3 days ago by cehoyos

Please either:

  • Attach the first MB (or two) here in the ticket

or

  • Upload the complete file to a filehoster of your choice.

comment:8 Changed 3 days ago by forthrin

How can I provide the necessary information without uploading media content? I'll be happy to run ffmpeg verbosely on the input (or output) file and send the output from the program.

comment:9 Changed 3 days ago by cehoyos

Do attachments not work anymore? I believe I attached a file a few hours ago.

comment:10 Changed 3 days ago by forthrin

I'm asking if there is a way to provide necessary information without uploading media content. I know ffmpeg has quite verbose options that output meta data information about each frame, for instance.

comment:11 Changed 3 days ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from new to closed

I don’t think this is a valid ticket but we may never find out.

Changed 3 days ago by forthrin

comment:12 Changed 3 days ago by forthrin

OK, I managed to make a miniature video file (only 16x16 pixel resolution and byte-truncated), but still exhibits the exact same playback problem as experienced with the full file.

  • ffplay/mplayer/vlc: Plays continuously as expected
  • QuickTime?: Stops playing after 2 seconds.

I'll be very interested in hearing what causes QuickTime? to stop playing the file.

Last edited 41 hours ago by forthrin (previous) (diff)

comment:13 Changed 41 hours ago by forthrin

  • Resolution needs_more_info deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.