Opened 5 years ago

Closed 5 years ago

#3443 closed defect (fixed)

h264_mp4toannexb filter causes artefacts

Reported by: eelco Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: h264
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

When copying a h.264 stream to a TS file, the result does not play cleanly but contains several artefacts. This only happens for certain input.

How to reproduce:

$ ffmpeg -i input.m4v -c:a copy -c:v copy -bsf h264_mp4toannexb copied.ts
ffmpeg version N-61143-g64e4bd7 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar  7 2014 10:57:23 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  configuration: --prefix=/Users/eelco/Projects/Beamer/FFmpeg/build/ --disable-ffserver --disable-doc --extra-cflags='-DMACOSX_DEPLOYMENT_TARGET=10.9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -I/Users/eelco/Projects/Beamer/FFmpeg/build//include' --extra-ldflags='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -L/Users/eelco/Projects/Beamer/FFmpeg/build//lib'
  libavutil      52. 66.101 / 52. 66.101
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.101 / 55. 33.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 18.100 /  0. 18.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2014-03-04 16:07:22
    title           : American Hustle t03 - iFlix
    encoder         : iFlicks 2.0.2.2166
    hd_video        : 1
    media_type      : 9
    gapless_playback: 0
  Duration: 00:03:26.34, start: 0.000021, bitrate: 17699 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 17535 kb/s, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Metadata:
      creation_time   : 2014-03-04 16:07:22
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default)
    Metadata:
      creation_time   : 2014-03-04 16:07:22
File 'copied.ts' already exists. Overwrite ? [y/N] y
Output #0, mpegts, to 'copied.ts':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    gapless_playback: 0
    title           : American Hustle t03 - iFlix
    media_type      : 9
    hd_video        : 1
    encoder         : Lavf55.33.101
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 17535 kb/s, 23.98 fps, 90k tbn, 23.98 tbc (default)
    Metadata:
      creation_time   : 2014-03-04 16:07:22
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 156 kb/s (default)
    Metadata:
      creation_time   : 2014-03-04 16:07:22
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[adts @ 0x7fdb12809800] Encoder did not produce proper pts, making some up.
frame= 4947 fps=573 q=-1.0 Lsize=  481239kB time=00:03:26.33 bitrate=19106.3kbits/s    
video:441654kB audio:3940kB subtitle:0 data:0 global headers:0kB muxing overhead 7.999454%

Note that the input file is already problematic for some players.

player input copied
ffplay incorrect framerate artefacts and incorrect framerate
QuickTime Player no problems artefacts
MplayerX garbled artefacts

Attachments (5)

mplayerx-input.png (1.8 MB) - added by eelco 5 years ago.
ffplay-copied.png (986.1 KB) - added by eelco 5 years ago.
mplayerx-copied.jpg (2.0 MB) - added by eelco 5 years ago.
quicktime-player-copied.jpg (887.5 KB) - added by eelco 5 years ago.
3443-input_remux.m4v (2.3 MB) - added by cehoyos 5 years ago.

Change History (11)

Changed 5 years ago by eelco

Changed 5 years ago by eelco

Changed 5 years ago by eelco

Changed 5 years ago by eelco

comment:1 Changed 5 years ago by eelco

Input and output files are uploaded to upload.ffmpeg.org as 3443-input.m4v and 3443-copied.ts respectively.

To be clear, I’m suspecting h264_mp4toannexb to be the cause of this because transcoding the video (e.g., ffmpeg -i input.m4v -c:a copy -c:v libx264 transcoded.mp4) works as expected.

comment:2 Changed 5 years ago by cehoyos

I cannot find the (necessary) input file, could you upload it again?
Output files are typically unneeded.

comment:3 Changed 5 years ago by eelco

Oops, sorry, it failed. It should be uploaded in 20 minutes or so.

comment:4 in reply to: ↑ description Changed 5 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords h264 added
  • Reproduced by developer set
  • Status changed from new to open

Replying to eelco:

player input
ffplay incorrect framerate

Unrelated to your ticket (that is reproducible):
The file 3443-input.m4v that you uploaded plays in-sync here with ffplay and the frame-rate looks expected. What do I miss?

The problem that remuxing the h264 stream of the mp4 sample with the h264_mp4toannexb bitstream filter leads to massive artefacts is reproducible, not a regression afaict. I have remuxed the beginning of the sample to mp4 and the resulting file allows to reproduce the issue here:

$ ffmpeg -i 3443-input_remux.m4v -vcodec copy -vbsf h264_mp4toannexb out.h264
ffmpeg version N-61143-g64e4bd7 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar  7 2014 10:48:59 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libvorbis --enable-libvpx
  libavutil      52. 66.101 / 52. 66.101
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.101 / 55. 33.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '3443-input_remux.m4v':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : American Hustle t03 - iFlix
    encoder         : Lavf55.33.101
    media_type      : 9
    hd_video        : 1
    gapless_playback: 0
  Duration: 00:00:02.00, start: 0.000000, bitrate: 9642 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 9635 kb/s, 23.99 fps, 23.98 tbr, 16k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Output #0, h264, to 'out.h264':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : American Hustle t03 - iFlix
    gapless_playback: 0
    media_type      : 9
    hd_video        : 1
    encoder         : Lavf55.33.101
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 9635 kb/s, 23.99 fps, 90k tbn, 23.98 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   48 fps=0.0 q=-1.0 Lsize=    2354kB time=00:00:01.91 bitrate=10055.2kbits/s
video:2354kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.006970%

out.h264 shows massive artefacts on playback.

Changed 5 years ago by cehoyos

comment:5 Changed 5 years ago by eelco

Sorry, I used an older version of ffplay (not from the same build), so that’s probably my fault.

comment:6 Changed 5 years ago by eelco

  • Resolution set to fixed
  • Status changed from open to closed

Seems to be fixed in 289b149cec, thanks!

Note: See TracTickets for help on using tickets.