Re-encode with ffmpeg using libx265 - rawvideo I have a script that is going through a media library and re-encoding files to HEVC with ffmpeg and using libx265. The default command I use is:

ffmpeg -i "$origFile" -map 0 -c copy -c:v libx265 -preset slow -crf 28 "$newFile"


However, for some files this process fails, it outputs the following information about the video:

Output #0, matroska, to 'test.mkv':
  Metadata:
    encoder         : Lavf56.15.105
    Stream #0:0: Video: hevc, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 23.98 fps
    Metadata:
      encoder         : Lavc57.14.100 libx265
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, 128 kb/s
Stream mapping:
  Stream #0:0 -&gt; #0:0 (rawvideo (native) -&gt; hevc (libx265))
  Stream #0:1 -&gt; #0:1 (copy)


And then, I just get the wall of errors that are printed below here: 

[rawvideo @ 000000c56052c920] Invalid buffer size, packet size 295 &lt; expected frame_size 1
769472
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 000000c56052c920] Invalid buffer size, packet size 362 &lt; expected frame_size 1
769472
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 000000c56052c920] Invalid buffer size, packet size 5926 &lt; expected frame_size
1769472
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 000000c56052c920] Invalid buffer size, packet size 406 &lt; expected frame_size 1
769472
Error while decoding stream #0:0: Invalid argument


I've tried following some other advice, since when I try and read the codec, it says "rawvideo", and using commands like ffmpeg -f rawvideo -pix_fmt yuv420p...., but that also does not work. If anyone has any insight or ability to help explain how to overcome this issue, it would be really appreciated. I've included the ffprobe output for this particular file as well if that is helpful:

ffprobe version N-76479-gc878082 Copyright (c) 2007-2015 the FFmpeg developers
  built with gcc 5.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --e
nable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-li
bass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libf
reetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libm
p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --en
able-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libv
o-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-deckli
nk --enable-zlib
  libavutil      55.  5.100 / 55.  5.100
  libavcodec     57. 14.100 / 57. 14.100
  libavformat    57. 14.100 / 57. 14.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 14.101 /  6. 14.101
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, avi, from '109 - The Voices of the Dead.avi':
  Metadata:
    encoder         : Lavf56.15.105
  Duration: 00:58:35.47, start: 0.000000, bitrate: 359 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 1024x576, 219 kb/s, SAR 1:1 DAR 16:9, 23.98 fps,
23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
For files already encoded to AVI, you'll have to extract the video to a raw HEVC stream first:

ffmpeg -i in.avi -c copy -map 0:v -f hevc in.265


and then

ffmpeg -framerate 30 -i in.265 -i in.avi -c copy -map 0:v -map 1:a -video_track_timescale 1k fixed.mp4


Replace the framerate value with the true rate of the video.



Encode new files to MP4 or MKV.

ffmpeg -i "$origFile" -map 0 -c copy -c:v libx265 -preset slow -crf 28 "newFile.mp4"