Video As Code – 왜 ffmpeg일까

1.
예전에 유튜브를 하려고 이런저런 장비를 준비했습니다. 비싼 것은 아니지만 알리익스프레스에서 지향성 마이크를 샀고 당근마켓에서는 팬덤파워, 마이크 거치대도 구매했습니다. 영상녹화를 하려고 니콘 카메라를 해킹해서 사용하는 법도 확인하였죠. 여기까지만 하고 멈췄습니다. 엄두가 나지 않았습니다.

요즘 가족들이 유튜브를 하라고 성화입니다. 무언가 대단한 것을 할 수 있다는 기대감은 아닙니다. 큰 딸이 유뷰브와 관련한 PD를 하고 있기때문에 이런저런 이야기를 나누다가 나온 이야기입니다. 말이 씨앗이 된다고 하죠? 딱 그 모양입니다. 무슨 주제로 할까 고민을 해보았습니다. 투자와 관련한 콘텐츠가 인기가 있는 모양이지만 하던 일이 투자이긴 하지만 IT이기때문에 지속가능하지 않습니다. 국내외 보고서를 읽어주는 아이템도 고민했지만 연습이 필요해보였습니다. IT와 관련한 일을 했기때문에 관련한 주제가 가능하겠지만 워낙 많은 분들이 하고 있습니다. 그러다고 우연히 ffmpeg과 관련한 문서를 보았습니다. 영상의 코덱을 바꾸거나 영상을 자를 때(split) 자주 사용하는 어플리케이션이지만 상세한 설명서는 처음이었습니다.

FFmpeg Filters Documentation

문서가 다루는 주제는 Filter입니다. Filter기능을 보니까 무척이나 많습니다. 그 중 Fade out을 적용한 샘플입니다. Transitions : fade-in & fade-out에 올라온 영상입니다.

물론 영상편집프로그램을 이용하면 Fade In/Out과 같은 효과를 쉽게 만들 수 있습니다. 차이라고 하면 ffmpeg을 이용하면 CLI(Commandline Interface)이고 영상편집프로그램은 별도의 GUI(Graphic User Interface)입니다.

2.
한번더 생각을 해보았습니다.영상을 만들면 어떤 절차에 따라 만들까?

어떤 주제를 잡으면 그와 관련한 미디오소스를 가장 먼저 구할 듯 합니다. 영상이든 음성이든 자체로 생산하여 영상에서 실제로 사용할 부분을 짤라서 미디어 소스를 만들 듯 합니다. 저작권이 있는 저작물인 경에도 마찬가지일 듯 합니다. 여기에 이미지와 관련한 자료도 필요합니다.

영상소스 + 음성소스 + 사진소스 + 텍스트

이상을 시나리오에 따라 하나의 영상을 만들지 않을까 상상했습니다. 좀더 상상을 해보면 영상에 글자를 넣거나 자막을 넣을 수도 있고 영상 앞이나 뒤 혹은 중간에 사진을 넣을 수도 있고… 영상에 음성을 덧붙일 수도 있는 일이 있을 수 있습니다. 필요한 경우 영상과 영상 혹은 영상과 사진사이에 효과를 넣을 수도 있겠죠. 이런 일을 무엇으로 할까 고민해보았습니다. 리눅스에서 사용할 수 있는 영상이나 음성으로 작업할 수 있는 오픈소스 어플리케이션은 무척 많습니다. 소스가 아니더라도 사용할 수 있는 Free Version도 많습니다. 다만 영상을 편집할 때 하드웨어의 사양이 높아야 하는 단점이 있습니다. 유튜브를 위한 하드웨어를 별도로 준비한다? 쉽지않은 선택입니다. 그래서 ffmpeg을 적극적으로 검토했습니다.

FFmpeg (or “Fast Forward MPEG”) is a simple yet feature rich command line utility to allow the manipulation (including decoding, encoding, transcoding, muxing, demuxing, streaming, filtering, and playing) of media and video files.

FFMpeg의 장점은 거의 모든 OS에서 사용할 수 있습니다. 그리고 끊임없이 업그레이드를 하고 있습니다. 현재 코드네임은 “Von Neumann”이네요.

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It can decode, encode, transcode, mux, demux, stream, filter and play pretty much any media file in any format. It is also highly portable as it compiles and runs in a wide variety of build environments, machine architectures, and configurations like Linux, Mac OS X, Microsoft Windows, etc.

저는 Ubuntu 계열의 OS를 사용하고 있습니다. 현재 버전을 보면 4.4.2입니다.

FFmpeg.org를 가면 6.0까지 나왔습니다. Git로 소스를 가져와서 컴파일을 하니까 아래와 같이 나옵니다.

알림을 보면 1년에 최소 한번정도는 업그레이드를 하네요.

February 28th, 2023, FFmpeg 6.0 “Von Neumann”

A new major release, FFmpeg 6.0 “Von Neumann”, is now available for download. This release has many new encoders and decoders, filters, ffmpeg CLI tool improvements, and also, changes the way releases are done. All major releases will now bump the version of the ABI. We plan to have a new major release each year. Another release-specific change is that deprecated APIs will be removed after 3 releases, upon the next major bump. This means that releases will be done more often and will be more organized.

New decoders featured are Bonk, RKA, Radiance, SC-4, APAC, VQC, WavArc and a few ADPCM formats. QSV and NVenc now support AV1 encoding. The FFmpeg CLI (we usually reffer to it as ffmpeg.c to avoid confusion) has speed-up improvements due to threading, as well as statistics options, and the ability to pass option values for filters from a file. There are quite a few new audio and video filters, such as adrc, showcwt, backgroundkey and ssim360, with a few hardware ones too. Finally, the release features many behind-the-scenes changes, including a new FFT and MDCT implementation used in codecs (expect a blog post about this soon), numerous bugfixes, better ICC profile handling and colorspace signalling improvement, introduction of a number of RISC-V vector and scalar assembly optimized routines, and a few new improved APIs, which can be viewed in the doc/APIchanges file in our tree. A few submitted features, such as the Vulkan improvements and more FFT optimizations will be in the next minor release, 6.1, which we plan to release soon, in line with our new release schedule. Some highlights are:

  • Radiance HDR image support
  • ddagrab (Desktop Duplication) video capture filter
  • ffmpeg -shortest_buf_duration option
  • ffmpeg now requires threading to be built
  • ffmpeg now runs every muxer in a separate thread
  • Add new mode to cropdetect filter to detect crop-area based on motion vectors and edges
  • VAAPI decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9
  • WBMP (Wireless Application Protocol Bitmap) image format
  • a3dscope filter
  • bonk decoder and demuxer
  • Micronas SC-4 audio decoder
  • LAF demuxer
  • APAC decoder and demuxer
  • Media 100i decoders
  • DTS to PTS reorder bsf
  • ViewQuest VQC decoder
  • backgroundkey filter
  • nvenc AV1 encoding support
  • MediaCodec decoder via NDKMediaCodec
  • MediaCodec encoder
  • oneVPL support for QSV
  • QSV AV1 encoder
  • QSV decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9
  • showcwt multimedia filter
  • corr video filter
  • adrc audio filter
  • afdelaysrc audio filter
  • WADY DPCM decoder and demuxer
  • CBD2 DPCM decoder
  • ssim360 video filter
  • ffmpeg CLI new options: -stats_enc_pre[_fmt], -stats_enc_post[_fmt], -stats_mux_pre[_fmt]
  • hstack_vaapi, vstack_vaapi and xstack_vaapi filters
  • XMD ADPCM decoder and demuxer
  • media100 to mjpegb bsf
  • ffmpeg CLI new option: -fix_sub_duration_heartbeat
  • WavArc decoder and demuxer
  • CrystalHD decoders deprecated
  • SDNS demuxer
  • RKA decoder and demuxer
  • filtergraph syntax in ffmpeg CLI now supports passing file contents as option values
  • hstack_qsv, vstack_qsv and xstack_qsv filters

앞으로 Video As Code를 주제로 ffmpeg의 사용법을 설명하는 자료를 올리려고 합니다. 과정을 영상으로 찍고, 이름하여 메이킹필름입니다. 결과물도 별도로 올릴 예정입니다. 물론 유튜브에 올립니다. 그동안 해왔던 일과 조금 다른 방향으로 시도해봅니다. 많이 익숙해지면 오랜 동안 했던 금융IT와 관련한 콘텐츠도 만들어볼 계획입니다.
왜 Video As Code라는 이름을 짓었을까요? 클라우드, VM과 관련한 기술들이 발전하면서 as code라는 말이 유행중입니다. 대표적인 표현을 보면

Network as Code
Hardware as Code

가 있습니다. 소프트웨어로 네트워크와 하드웨어 설치, 설정합니다. 같은 분위기로 코드로 비디오를 생산한다? 뭐 이런 의미입니다.

Leave a Comment

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.