Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7677 closed defect (duplicate)

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 (2)

c.mp4.gz (86.8 KB ) - added by forthrin 5 years ago.
s.mov.gz (120.3 KB ) - added by forthrin 5 years ago.

Download all attachments as: .zip

Change History (53)

comment:1 by Carl Eugen Hoyos, 5 years ago

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

comment:2 by forthrin, 5 years ago

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 by Carl Eugen Hoyos, 5 years ago

Please attach the first 2.5 MB of your input file.

comment:4 by Carl Eugen Hoyos, 5 years ago

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

comment:5 by compn, 5 years ago

why arent you using -f ipod ?

comment:6 by forthrin, 5 years ago

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 by Carl Eugen Hoyos, 5 years ago

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 by forthrin, 5 years ago

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 by Carl Eugen Hoyos, 5 years ago

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

comment:10 by forthrin, 5 years ago

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 by Carl Eugen Hoyos, 5 years ago

Resolution: needs_more_info
Status: newclosed

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

by forthrin, 5 years ago

Attachment: c.mp4.gz added

comment:12 by forthrin, 5 years ago

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 5 years ago by forthrin (previous) (diff)

comment:13 by forthrin, 5 years ago

Resolution: needs_more_info
Status: closedreopened

comment:14 by forthrin, 5 years ago

@cehoyos: What did you find out when analysing the problem?

comment:15 by Carl Eugen Hoyos, 5 years ago

Resolution: needs_more_info
Status: reopenedclosed

Please do not upload output files (that were created with FFmpeg) unless specifically asked to.

comment:16 by forthrin, 5 years ago

Resolution: needs_more_info
Status: closedreopened

I provided you with a file that demonstrates the described problem. What do you want, then, if not this?

comment:17 by Carl Eugen Hoyos, 5 years ago

Resolution: needs_more_info
Status: reopenedclosed

(The first MB of) the original avi file. Please don’t ask for support if you cannot provide it.

comment:18 by forthrin, 5 years ago

Resolution: needs_more_info
Status: closedreopened

If you do ffmpeg -i first-1-mb.avi ... out.mp4 you can't reproduce the problem when playing out.mp4 in an Apple player. I tried this, and it's necessary to encode all the way to the end of the original file to make the problem happen, even if the problem happens after just 3 minutes. But if you know for sure the solution to understanding the problem is in the AVI header or something, then let me know.

comment:19 by compn, 5 years ago

we need a way to reproduce the issue with the original avi input file. otherwise it is more difficult to just "fix the output" if we don't know where its going wrong at.

obviously something is weird if encoding a small chunk works but the entire file breaks.

does this also happen with one of our samples, for example
http://samples.ffmpeg.org/A-codecs/Indeo_audio/sample.avi

or does the video length have to be longer for the bug to show? hmmm.

in reply to:  19 comment:20 by Carl Eugen Hoyos, 5 years ago

Replying to compn:

we need a way to reproduce the issue with the original avi input file.

No!
We need the first MB of the original file to be able to understand the issue, we (of course) trust the OP that the issue exists as described.

comment:21 by Carl Eugen Hoyos, 5 years ago

Resolution: needs_more_info
Status: reopenedclosed

comment:22 by forthrin, 5 years ago

Resolution: needs_more_info
Status: closedreopened

I think #5882 is the same bug. However, the suggested remedy (-video_track_timescale <input-framerate>) is not acceptable, because you have to manually check the input framerate and punch it on the command line. The proper solution would be detecting and fixing the issue automatically.

comment:23 by Carl Eugen Hoyos, 5 years ago

Resolution: duplicate
Status: reopenedclosed

Of course! (You would have avoided searching for this ticket if I had the possibility to test myself.)
The correct fix is that you choose an output format specific to Apple if your output files are meant to be played on Apple devices.

comment:24 by galad, 5 years ago

Your test file (c.mp4) shows no issue on 10.14, so Apple fixed the QuickTime Player issue at least.

Last edited 5 years ago by galad (previous) (diff)

comment:25 by forthrin, 5 years ago

I'll test 10.14 when I update macOS. iPods are still an issue. Which CLI options do I need? I already use -profile:v baseline -level 3.0 -pix_fmt yuv420p, which still provokes the error.

comment:26 by forthrin, 5 years ago

Resolution: duplicate
Status: closedreopened

comment:27 by Carl Eugen Hoyos, 5 years ago

Resolution: duplicate
Status: reopenedclosed

I believe you explained that this is a duplicate of ticket #5882 which is not completely unexpected.

comment:28 by forthrin, 5 years ago

Resolution: duplicate
Status: closedreopened

You wrote: "The correct fix is that you choose an output format specific to Apple if your output files are meant to be played on Apple devices."

Can you tell me specifically what should be added to the ffmpeg command line?

(I can find nothing on this in this bug report, in #5882, in the FFmpeg documentation, or elsewhere.)

comment:29 by Carl Eugen Hoyos, 5 years ago

Didn't I explain this at least twice in ticket #5882? Why are you using mp4 (I am not interested in Apple-compatibility) and not mov (I need Apple compatibility)? As you found out Apple's mp4-compatibility is limited.

comment:30 by Carl Eugen Hoyos, 5 years ago

Resolution: duplicate
Status: reopenedclosed

comment:31 by forthrin, 5 years ago

Resolution: duplicate
Status: closedreopened

Using .mov extension: ffmpeg ... -profile:v baseline -level 3.0 -pix_fmt yuv420p out.mov gives the same problem, both in QuickTime on macOS 10.12 and on the iPod Nano 3rd generation.

Adding -video_track_timescale 23.98 or -r 23.98 removes the problem, but they are not practical solutions, as you have to retrieve the input frame rate manually or by a script (ffprobe, etc.)

Do you have a straight forward command line that solves the problem?

in reply to:  31 comment:32 by Carl Eugen Hoyos, 5 years ago

Resolution: duplicate
Status: reopenedclosed

Replying to forthrin:

Adding -video_track_timescale 23.98

The value looks wrong / not ideal.

Please stop reopening this ticket, for any support questions ask on the FFmpeg user mailing list.

comment:33 by forthrin, 5 years ago

23.98 is the frame rate of the original file I am converting. I thought video_track_timescale took the input frame rate as argument? It works for me. Just too bad the value must be changed all the time.

#5882 seems to have a good suggestion: "ffmpeg should guess FPS ... and write "video_track_timescale" automatically, even if the input is bugged ... check for input "timebase" and fix it on the fly."

If for some reason it is not possible to fix FFmpeg this way, or the developers simply have no time or interest in solving the issue, just state this plainly, and I will pursue the issue no further.

Unfortunately I am unable to participate on the mailing list, but if a solution actually exists for the current version of FFmpeg, it would be very kind if you could write it here, and in the "Compatibility" section of the official documentation: https://trac.ffmpeg.org/wiki/Encode/H.264#AdditionalInformationTips. This would be helpful to everyone who is converting video content to watch on Apple devices.

in reply to:  33 comment:34 by Carl Eugen Hoyos, 5 years ago

Replying to forthrin:

23.98 is the frame rate of the original file I am converting.

This is unlikely, such files exist but are already broken. More likely is a framerate of 24000/1001, for such files a correct video track timebase is 24000 iirc.

comment:35 by forthrin, 5 years ago

Can FFmpeg be changed so this issue is detected and fixed automatically? If not, could you explain why?

comment:36 by Carl Eugen Hoyos, 5 years ago

Several people failed, please send your patch - made with git format-patch - to the FFmpeg development mailing list if you succeed.

comment:37 by forthrin, 5 years ago

Resolving the issue is beyond even the ingenious FFmpeg developers? Must be a real nut, then. The suggestion in #5882 seemed so easy. Looks like we'll have to live with it until some brainiac has an eureka moment. Wish I could help, but video conversion isn't my forte. Thanks for clarifying.

comment:38 by forthrin, 5 years ago

@cehoyos: What is the exact formula for calculating the value for video_track_timescale?

Last edited 5 years ago by forthrin (previous) (diff)

comment:39 by Carl Eugen Hoyos, 5 years ago

As explained above multiplying the actual frame rate with 1001 will work in many cases.

comment:40 by forthrin, 5 years ago

@cehoyos: I found a new video which, after being converted, plays fine in QuickTime on macOS (10.12), but still plays faulty on the iPod, even when setting -video_track_timescale 24024 with an input frame rate of 24 fps. Does this mean this is not the same bug as #5882 after all, since the workaround doesn't work?

(What happens specifically on the iPod is that when the video reaches around 12 minutes, the player progress bar races insanely fast through the rest of the video, like several minutes per second, and then it exits back to the list of videos.)

Last edited 5 years ago by forthrin (previous) (diff)

in reply to:  40 comment:41 by Carl Eugen Hoyos, 5 years ago

Replying to forthrin:

I found a new video which, after being converted, plays fine in QuickTime on macOS (10.12), but still plays faulty on the iPod, even when setting -video_track_timescale 24024 with an input frame rate of 24 fps.

Command line, complete, uncut console output and an input sample missing.

Does this mean this is not the same bug as #5882 after all, since the workaround doesn't work?

There is no workaround involved.

comment:42 by forthrin, 5 years ago

The enclosed file and command line below will produce a file that makes the native video player on an iPod Nano 3rd generation abruptly exit at 11:20 even though the video length is 12:00.

Note:

  • The file intentionally contains black/silence. The problem seems independent of content.
  • The problem persists even if adding -video_track_timescale 24024.
  • The problem disappears if you do ffmpeg -i s.mov s.avi, and use s.avi as input.
$ ffmpeg -y -i s.mov -vcodec libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p t.mov
ffmpeg version N-45416-g7e4d3dbe1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --enable-gpl --enable-libx264 --enable-libass
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 47.102 / 58. 47.102
  libavformat    58. 26.101 / 58. 26.101
  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, mov,mp4,m4a,3gp,3g2,mj2, from 's.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.26.101
  Duration: 00:12:00.03, start: 0.000000, bitrate: 10 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 480:347 DAR 640:347], 2 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.47.102 libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7ff6d700f800] using SAR=480/347
[libx264 @ 0x7ff6d700f800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7ff6d700f800] profile Constrained Baseline, level 3.0
[libx264 @ 0x7ff6d700f800] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=24 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, mov, to 't.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.26.101
    Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 480:347 DAR 640:347], q=-1--1, 24 fps, 24 tbn, 24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.47.102 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.47.102 aac
video:202kB audio:184kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 140.998138%
[libx264 @ 0x7ff6d700f800] frame I:70    Avg QP: 8.04  size:   243
[libx264 @ 0x7ff6d700f800] frame P:17210 Avg QP:11.00  size:    11
[libx264 @ 0x7ff6d700f800] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x7ff6d700f800] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0x7ff6d700f800] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7ff6d700f800] i16 v,h,dc,p: 93%  0%  7%  0%
[libx264 @ 0x7ff6d700f800] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 0x7ff6d700f800] kb/s:2.29
[aac @ 0x7ff6d7013200] Qavg: 65536.000
Last edited 5 years ago by forthrin (previous) (diff)

by forthrin, 5 years ago

Attachment: s.mov.gz added

comment:43 by forthrin, 5 years ago

@cehoyos: Any update on this? It's really a nuisance having to convert files via AVI to avoid the problem.

comment:44 by Carl Eugen Hoyos, 5 years ago

Please provide an input file that was not created with FFmpeg if you want me to spend more time on this ticket.

comment:45 by forthrin, 5 years ago

@cehoyos: Unfortunately that's not possible, since the source files are hundreds of megabytes. Besides, what difference does it make if it's been through FFmpeg? The error is present in the submitted file just as much as in the original. In fact, even if you convert the file 100 times from mp4 to mp4, the error "sticks". It's first when you convert via another format (like AVI) that you "get rid of" the error. So my unqualified hunch is that there's some metadata in the mp4 format that is "carried over" when going to mp4 to mp4. Or something like that.

in reply to:  45 comment:46 by Carl Eugen Hoyos, 5 years ago

Replying to forthrin:

@cehoyos: Unfortunately that's not possible, since the source files are hundreds of megabytes.

The original sample for #2263 was 11G (when internet connections were slower), so a few hundred MB do not scare me.

comment:47 by forthrin, 5 years ago

@cehoyos: The original file has quite likely been generated with FFmpeg too, it being the world's de facto video converter. So I don't see the benefit. However, if you have a private FTP server which accepts uploads, I will see what I can do.

comment:49 by forthrin, 5 years ago

Thanks! Can you give me the technical background of why a file that has been converted with FFmpeg can't be used for debugging?

comment:50 by Carl Eugen Hoyos, 5 years ago

No technical background that I know of.

comment:51 by forthrin, 5 years ago

Then why are you asking for an "original" file, when a converted file exhibits the same problem, even when converted any number of times? I'm just not following the logic...

Note: See TracTickets for help on using tickets.