1

When I try to convert an very old avi to a mp4 with ffmpeg, the thumbnail disappears. Is there a way to preserve the thumbnail or auto-generate one directly from the video stream, for example, using the first frame, without having to save an image and then add it? Using Win10 and trying to view the files in Windows explorer.

Log:

ffmpeg version git-2020-07-16-d11cc74 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 96.100 / 58. 96.100
  libavformat    58. 48.100 / 58. 48.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, avi, from 'in.avi':
  Metadata:
    creation_time   : 2004-03-14 13:53:17
    encoder         : CanonMVI01
  Duration: 00:00:30.00, start: 0.000000, bitrate: 5217 kb/s
    Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 5136 kb/s, 15 fps, 15 tbr, 15 tbn, 15 tbc
    Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11024 Hz, mono, u8, 88 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (pcm_u8 (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0000023cd2571a40] Too many bits 17832.925170 > 6144 per frame requested, clamping to max
[libx264 @ 0000023cd256fb00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000023cd256fb00] profile High 4:2:2, level 2.2, 4:2:2, 8-bit
[libx264 @ 0000023cd256fb00] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 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=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=15 ip_ratio=1.40 pb_ratio=1.30 aq=0
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf58.48.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj422p(pc), 640x480, q=-1--1, 15 fps, 500k tbn, 15 tbc
    Metadata:
      encoder         : Lavc58.96.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 66 kb/s
    Metadata:
      encoder         : Lavc58.96.100 aac
frame=  450 fps= 32 q=-1.0 Lsize=   21274kB time=00:00:30.00 bitrate=5809.2kbits/s speed=2.15x
video:21065kB audio:195kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.062795%
[libx264 @ 0000023cd256fb00] frame I:2     Avg QP:12.00  size: 59822
[libx264 @ 0000023cd256fb00] frame P:117   Avg QP:15.00  size: 57718
[libx264 @ 0000023cd256fb00] frame B:331   Avg QP:16.66  size: 44404
[libx264 @ 0000023cd256fb00] consecutive B-frames:  1.3%  0.9%  2.7% 95.1%
[libx264 @ 0000023cd256fb00] mb I  I16..4:  0.1% 99.5%  0.3%
[libx264 @ 0000023cd256fb00] mb P  I16..4:  0.0% 55.3%  7.8%  P16..4:  9.2% 16.1% 11.5%  0.0%  0.0%    skip: 0.0%
[libx264 @ 0000023cd256fb00] mb B  I16..4:  0.1% 25.5%  0.3%  B16..8: 25.6% 19.7%  7.7%  direct:20.1%  skip: 1.0%  L0:17.5% L1:13.5% BI:69.0%
[libx264 @ 0000023cd256fb00] 8x8 transform intra:93.4% inter:84.1%
[libx264 @ 0000023cd256fb00] coded y,uvDC,uvAC intra: 98.8% 79.8% 22.5% inter: 97.3% 94.2% 42.8%
[libx264 @ 0000023cd256fb00] i16 v,h,dc,p:  4% 25% 16% 55%
[libx264 @ 0000023cd256fb00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 19% 52%  2%  2%  2%  4%  2%  5%
[libx264 @ 0000023cd256fb00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 20% 15%  7%  9%  6% 11%  6% 13%
[libx264 @ 0000023cd256fb00] i8c dc,h,v,p: 45% 21% 33%  2%
[libx264 @ 0000023cd256fb00] Weighted P-Frames: Y:6.0% UV:1.7%
[libx264 @ 0000023cd256fb00] ref P L0: 38.4% 25.7% 19.4% 15.7%  0.8%
[libx264 @ 0000023cd256fb00] ref B L0: 88.3%  9.6%  2.1%
[libx264 @ 0000023cd256fb00] ref B L1: 94.8%  5.2%
[libx264 @ 0000023cd256fb00] kb/s:5752.13
[aac @ 0000023cd2571a40] Qavg: 58267.156
7
  • What are you using to view the thumbnail? What is your OS? What is your ffmpeg command? What does the ffmpeg log show?
    – llogan
    Commented Jan 25, 2021 at 19:41
  • Trying to view them in Win10 Explorer. Native mp4s work ok and I can see a thumbnail for them but not for the transcoded. I use >ffmpeg.exe -i in.avi -qp 15 -c:v h264 -c:a aac -b:a 192K out.mp4 and it seems to work well.
    – Linus
    Commented Jan 25, 2021 at 22:32
  • Show the full log from the command.
    – llogan
    Commented Jan 25, 2021 at 22:45
  • The log is a bit too long to add here but it doesn't give any warnings or errors, playing the video works but it lacks a thumbnail that would make it easy to identify the video. Thank you for taking an interest.
    – Linus
    Commented Jan 25, 2021 at 22:46
  • The log is about 4500 characters above the comment limit. I could spread it over multiple comments.
    – Linus
    Commented Jan 25, 2021 at 22:49

1 Answer 1

3

Add -vf format=yuv420p:

ffmpeg -i in.avi -qp 15 -c:v h264 -c:a aac -b:a 192k -vf format=yuv420p out.mp4

This will use a compatible chroma subsampling scheme. Otherwise the encoder libx264 will choose chroma subsampling that most resembles the input, but it is not readable by most players or file managers.

1
  • Thank you very much! It fixed my problem.
    – Linus
    Commented Jan 25, 2021 at 23:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .