티스토리 뷰

ffmpeg 을 통해 영상으로 부터 이미지를 추출 하려고 하는데, 아래와 같이 오류가 발생했다.

(ffmpeg -version 은 아래와 같다)

ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 14.0.3 (clang-1403.0.22.14.1) configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
libavutil 58. 2.100 / 58. 2.100
libavcodec 60. 3.100 / 60. 3.100
libavformat 60. 3.100 / 60. 3.100
libavdevice 60. 1.100 / 60. 1.100
libavfilter 9. 3.100 / 9. 3.100
libswscale 7. 1.100 / 7. 1.100
libswresample 4. 10.100 / 4. 10.100
libpostproc 57. 1.100 / 57. 1.100

 

아래와 같이 명령어를 실행하면...

ffmpeg -i {mp4 url} \
	-vf "fps=1/10,scale='if(lt(sar\,1),trunc(iw*sar),iw)':'if(lt(sar\,1),ih,trunc(ih/sar))',setsar=1" \
    -loglevel warning \
    %5d.jpg

 

잘 실행되다가 아래 오류와 함께 중간에 중지가 된다.

[http @ 0x600002d54000] No trailing CRLF found in HTTP header. Adding it. [swscaler @ 0x1308c8000] deprecated pixel format used, make sure you did set range correctly
[http @ 0x600002d54000] Stream ends prematurely at 1079264728, should be 1845939458 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x126604bb0] Packet corrupt (stream = 0, dts = 47529460).
[NULL @ 0x126705760] Invalid NAL unit size (35164 > 2231).
[NULL @ 0x126705760] missing picture in access unit with size 2235
...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x126604bb0] stream 0, offset 0x4054ccee: partial file Error demuxing input file 0
...
[h264 @ 0x12673ff20] Invalid NAL unit size (35164 > 2231). [h264 @ 0x12673ff20] Error splitting the input into NAL units.
...
Input/output error Last message repeated 8 times Error while decoding stream #0:0: Invalid data found when processing input

 

왜 일까?

"stream 0, offset 0x4054ccee: partial file Error demuxing input file 0"

 

input 파일이 0 이라서? 왜지?

input 으로 전달된 mp4 url 은 nginx 로 서빙 되는 url 이며, 최근 apache -> nginx 로 변경하였다.그 이유 때문일까?

 

wget 으로 파일 다운로드를 시도해 보자

...
1079197696 바이트에 연결 끊음. 다시 시도 중.
...

 

약 1GB에서 끊어지고 wget 내부에서 재처리를 하는 것으로 보인다. (1GB 마다 재시도를 하여 결국 다운로드를 성공)

ffmpeg 에서는 1GB 만 받고 실패하는 듯 하다.

 

nginx_temp_file_size 설정을 0으로 변경하고 proxy_buffering 을 off 한 뒤, 테스트를 해 보니 정상적으로 실행이 되었다.

nginx 설정은 참고 블로그에 잘 설명이 되어 있으니 참고하자.

 

참고

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size

https://www.digitalocean.com/community/tutorials/understanding-nginx-http-proxying-load-balancing-buffering-and-caching

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함