user12153: I'm using ffmpeg version 2.8.11 to convert an AVC/AAC video to HEVC/AAC: with the command ffmpeg -loglevel error -i input.mp4 -c:a copy -c:v libx265 -preset fast -x265-params crf=25 -vf scale=-8:ih output.mkv
The command works as expected on other files, but this particular file throws:
[matroska @ 0x88c2e0] Error parsing AAC extradata, unable to determine samplerate.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Source info from mediainfo:
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 138 MiB
Duration                                 : 25mn 31s
Overall bit rate mode                    : Variable
Overall bit rate                         : 755 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=50
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 25mn 31s
Duration_FirstFrame                      : 40ms
Bit rate                                 : 650 Kbps
Width                                    : 864 pixels
Original width                           : 854 pixels
Height                                   : 470 pixels
Original height                          : 480 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.064
Stream size                              : 118 MiB (86%)
Writing library                          : x264 core 148 r236 a01e339
Encoding settings                        : cabac=1 / ref=1 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-1 / threads=2 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=50 / keyint_min=5 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=650 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=850 / vbv_bufsize=850 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Codec ID                                 : 40
Duration                                 : 25mn 31s
Bit rate mode                            : Variable
Bit rate                                 : 98.5 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)
Compression mode                         : Lossy
Stream size                              : 18.0 MiB (13%)
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

I've tested playback of the source file which works as expected on both totem and mplayer. Based on the error I can only surmise that there's something off with the AAC stream description data. (extradata). My goal is to somehow repair/normalize this data so that I can successfully transcode it with HEVC encoder v.1.9

user12153: ffmpeg will happily rewrite the incorrect extradata for you if you simply copy the streams and utilize the bit stream filter aac_adtstoasc with the command ffmpeg -i input.mp4 -bsf:a aac_adtstoasc -c:a copy -c:v copy output.mp4 the resulting file converts as expected.
This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4 ADTS header and removes the ADTS header which appears was the root cause of the problem.
mediainfo reports the output file like this:
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 137 MiB
Duration                                 : 25mn 31s
Overall bit rate mode                    : Variable
Overall bit rate                         : 750 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf56.40.101

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=50
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 25mn 31s
Duration_FirstFrame                      : 40ms
Duration_LastFrame                       : 23ms
Bit rate                                 : 650 Kbps
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.063
Stream size                              : 118 MiB (86%)
Writing library                          : x264 core 148 r236 a01e339
Encoding settings                        : cabac=1 / ref=1 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-1 / threads=2 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=50 / keyint_min=5 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=650 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=850 / vbv_bufsize=850 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 25mn 31s
Bit rate mode                            : Variable
Bit rate                                 : 96.0 Kbps
Maximum bit rate                         : 217 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)
Compression mode                         : Lossy
Stream size                              : 17.6 MiB (13%)
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

And a diff of the reports shows the relevant changes made:
6c6
< File size                                : 138 MiB
---
> File size                                : 137 MiB
9c9
< Overall bit rate                         : 755 Kbps
---
> Overall bit rate                         : 750 Kbps
11a12
> Writing application                      : Lavf56.40.101
24a26
> Duration_LastFrame                       : 23ms
26,29c28,29
< Width                                    : 864 pixels
< Original width                           : 854 pixels
< Height                                   : 470 pixels
< Original height                          : 480 pixels
---
> Width                                    : 854 pixels
> Height                                   : 480 pixels
30a31
> Original display aspect ratio            : 16:9
37c38
< Bits/(Pixel*Frame)                       : 0.064
---
> Bits/(Pixel*Frame)                       : 0.063
47a49
> Format profile                           : LC
51c53,54
< Bit rate                                 : 98.5 Kbps
---
> Bit rate                                 : 96.0 Kbps
> Maximum bit rate                         : 217 Kbps
52a56
> Channel positions                        : Front: L R
56c60,62
< Stream size                              : 18.0 MiB (13%)
---
> Stream size                              : 17.6 MiB (13%)
> Default                                  : Yes
> Alternate group                          : 1

Source: https://ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc

user1760: Your ffmpeg is outdated. Update and it will automatically insert some bitstream filters (at least aac_adtstoasc, hevc_mp4toannexb, h264_mp4toannexb). According to the aac_adtstoasc documentation:

Please note that it is auto-inserted for MP4A-LATM and MOV/MP4 and
  related formats.

It also seems to also work for Matroska. You can verify the behavior by adding -loglevel debug and viewing the output. Look for Automatically inserted bitstream filter 'aac_adtstoasc'.
See the FFmpeg Download page (Get the Packages section) for links to recent builds for Linux, macOS, and Windows. Get a build from the master branch: releases are essentially "frozen" branches derived from master; they are meant for distributors and those who need to stay within a particular API version. Releases receive less attention and get no new features so therefore they age quickly.

12153: <p>I'm using ffmpeg version 2.8.11 to convert an AVC/AAC video to HEVC/AAC: with the command <code>ffmpeg -loglevel error -i input.mp4 -c:a copy -c:v libx265 -preset fast -x265-params crf=25 -vf scale=-8:ih output.mkv</code></p>

<p>The command works as expected on other files, but this particular file throws:</p>

<p><code>[matroska @ 0x88c2e0] Error parsing AAC extradata, unable to determine samplerate.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument</code></p>

<p>Source info from mediainfo:</p>

<pre><code>Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 138 MiB
Duration                                 : 25mn 31s
Overall bit rate mode                    : Variable
Overall bit rate                         : 755 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=50
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 25mn 31s
Duration_FirstFrame                      : 40ms
Bit rate                                 : 650 Kbps
Width                                    : 864 pixels
Original width                           : 854 pixels
Height                                   : 470 pixels
Original height                          : 480 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.064
Stream size                              : 118 MiB (86%)
Writing library                          : x264 core 148 r236 a01e339
Encoding settings                        : cabac=1 / ref=1 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-1 / threads=2 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=50 / keyint_min=5 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=650 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=850 / vbv_bufsize=850 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Codec ID                                 : 40
Duration                                 : 25mn 31s
Bit rate mode                            : Variable
Bit rate                                 : 98.5 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)
Compression mode                         : Lossy
Stream size                              : 18.0 MiB (13%)
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
</code></pre>

<p>I've tested playback of the source file which works as expected on both totem and mplayer. Based on the error I can only surmise that there's something off with the AAC stream description data. (extradata). My goal is to somehow repair/normalize this data so that I can successfully transcode it with HEVC encoder v.1.9</p>
 12153: <p><code>ffmpeg</code> will happily rewrite the incorrect extradata for you if you simply copy the streams and utilize the bit stream filter aac_adtstoasc with the command <code>ffmpeg -i input.mp4 -bsf:a aac_adtstoasc -c:a copy -c:v copy output.mp4</code> the resulting file converts as expected.</p>

<p>This filter creates an MPEG-4 AudioSpecificConfig from an MPEG-2/4 ADTS header and removes the ADTS header which appears was the root cause of the problem.</p>

<p><code>mediainfo</code> reports the output file like this:</p>

<pre><code>Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 137 MiB
Duration                                 : 25mn 31s
Overall bit rate mode                    : Variable
Overall bit rate                         : 750 Kbps
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
Writing application                      : Lavf56.40.101

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L3
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=50
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 25mn 31s
Duration_FirstFrame                      : 40ms
Duration_LastFrame                       : 23ms
Bit rate                                 : 650 Kbps
Width                                    : 854 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Original display aspect ratio            : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.063
Stream size                              : 118 MiB (86%)
Writing library                          : x264 core 148 r236 a01e339
Encoding settings                        : cabac=1 / ref=1 / deblock=1:-1:-1 / analyse=0x1:0x111 / me=umh / subme=8 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-1 / threads=2 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / stitchable=1 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=50 / keyint_min=5 / scenecut=0 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=650 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=850 / vbv_bufsize=850 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 25mn 31s
Bit rate mode                            : Variable
Bit rate                                 : 96.0 Kbps
Maximum bit rate                         : 217 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Frame rate                               : 43.066 fps (1024 spf)
Compression mode                         : Lossy
Stream size                              : 17.6 MiB (13%)
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 1904-01-01 00:00:00
Tagged date                              : UTC 1904-01-01 00:00:00
</code></pre>

<p>And a diff of the reports shows the relevant changes made:</p>

<pre><code>6c6
&lt; File size                                : 138 MiB
---
&gt; File size                                : 137 MiB
9c9
&lt; Overall bit rate                         : 755 Kbps
---
&gt; Overall bit rate                         : 750 Kbps
11a12
&gt; Writing application                      : Lavf56.40.101
24a26
&gt; Duration_LastFrame                       : 23ms
26,29c28,29
&lt; Width                                    : 864 pixels
&lt; Original width                           : 854 pixels
&lt; Height                                   : 470 pixels
&lt; Original height                          : 480 pixels
---
&gt; Width                                    : 854 pixels
&gt; Height                                   : 480 pixels
30a31
&gt; Original display aspect ratio            : 16:9
37c38
&lt; Bits/(Pixel*Frame)                       : 0.064
---
&gt; Bits/(Pixel*Frame)                       : 0.063
47a49
&gt; Format profile                           : LC
51c53,54
&lt; Bit rate                                 : 98.5 Kbps
---
&gt; Bit rate                                 : 96.0 Kbps
&gt; Maximum bit rate                         : 217 Kbps
52a56
&gt; Channel positions                        : Front: L R
56c60,62
&lt; Stream size                              : 18.0 MiB (13%)
---
&gt; Stream size                              : 17.6 MiB (13%)
&gt; Default                                  : Yes
&gt; Alternate group                          : 1
</code></pre>

<p>Source: <a href="https://ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc" rel="nofollow noreferrer">https://ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc</a></p>
 1760: <p>Your <code>ffmpeg</code> is outdated. Update and it will automatically insert some bitstream filters (at least aac_adtstoasc, hevc_mp4toannexb, h264_mp4toannexb). According to the <a href="https://ffmpeg.org/ffmpeg-bitstream-filters.html#aac_005fadtstoasc" rel="nofollow noreferrer">aac_adtstoasc documentation</a>:</p>

<blockquote>
  <p>Please note that it is auto-inserted for MP4A-LATM and MOV/MP4 and
  related formats.</p>
</blockquote>

<p>It also seems to also work for Matroska. You can verify the behavior by adding <code>-loglevel debug</code> and viewing the output. Look for <code>Automatically inserted bitstream filter 'aac_adtstoasc'</code>.</p>

<p>See the <a href="https://ffmpeg.org/download.html" rel="nofollow noreferrer">FFmpeg Download</a> page (<em>Get the Packages</em> section) for links to recent builds for Linux, macOS, and Windows. Get a build from the master branch: releases are essentially "frozen" branches derived from master; they are meant for distributors and those who need to stay within a particular API version. Releases receive less attention and get no new features so therefore they age quickly.</p>
