Reputation: 195
I'm generating thumbnails for a videos that are available from s3 and need to minimize traffic. Frame is going to be from the first couple seconds of the video so the question: is there a way to get frame without passing the full file through network?
At the moment I'm passing video url to ffmpeg but seems like it downloads the whole file, not only first couple seconds.
ffmpeg -ss 0 -noaccurate_seek -i {srcPresignedUrl} -vframes 1 -q:v 2 {outputFileName}
I tried downloading first 10mb of the file and passing it, this works for some mp4 files, but fails on mov:
ffmpeg.exe -ss 0 -i source.mov -vframes 1 -q:v 2 thumb.jpg
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
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 --enable-librav1e --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. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000017582ffff40] moov atom not found
source.mov: Invalid data found when processing input
Upvotes: 3
Views: 1298
Reputation: 57163
That's true. Some mp4 files are streaming-ready, but often they are not. The trick is that the moov
atom (in simple English, the table of contents of the video file) is normally prepared during the file encoding and attached to the end. There are different ways to move this information to the head of the stream (see Post processing in ffmpeg to move 'moov atom' in MP4 files (qt-faststart)), but this requires rebuilding the video.
Upvotes: 1