ffmpegを仕事で使ったので調べたことなど。
オプション
muxer
-f image2 // 画像ファイル全般の指定 -f image2pipe // 画像ファイルをpipeにストリームするときの指定。
image2pipeに関する情報が少なくて参った。
上書き
-y // Main optionに記述がある。 update 1 // image2のoptionに記述がある。
scale filter
-vf scale=1920:1080
幅か高さに-1を指定すると縦横比を維持できる、とある。
raw画像
-vcodec rawvideo
image2 / image2pipeを使ってraw画像を取り出す時でも、コーデックの指定はrawvideoでいい模様。拡張子.rawにすれば指定しなくていいかもしれない。
固定長データで切り出す
rawvideo形式は完全にピクセル数×カラーチャンネルのデータで成立しているので、pipeに出てくるデータをwidth * height * channelで切り出すことができれば、raw画像として使用できる。もちろんffmpegにraw画像保存させた方がラクなんだけど、まぁ要件によってはそうもいかず。
フレーム数
今回、動画のフレーム数を取得する方法を調べた。
%d.raw // ファイル名にフレーム数を含めるためのパラメータ。 %05d.raw // フレーム数5桁をベースにしたパラメータ。5桁であふれると勝手に桁が増える模様。
ファイル名にフレーム数を載せるのはこれで行ける。ただ、pipeのようにファイル名を使わない場合に、フレーム数を取得するスマートな方法はあまりない。
力業で解決するしかないみたい。
ffmpegのログファイルにフレーム数があるらしく、そちらをなんとかする方法があるのかも……という提案がこちらにはある。ちょっと大変だけど。
参考URL
- ffmpeg Documentation
- FFmpeg Devices Documentation
- FFmpeg Formats Documentation
- Scaling – FFmpeg
- ffmpeg pix_fmt bgr24 - Google 検索
- node.js - How to pipe sequence of thumbnails/screenshots from ffmpeg to nodejs for further processing? - Stack Overflow
- Map – FFmpeg
- bash - ffmpeg capture current frame and overwrite the image output file - Stack Overflow
- ffmpegで連番画像から動画生成 / 動画から連番画像を生成 ~コマ落ちを防ぐには~ - Qiita
- rgb565 なRAW 画像の作り方.1)800x600 のpng 画像を用意.2)ffmpeg で変換.うーん.もっと楽な方法があると思う. % co...
- 最新ffmpegのオプションまとめ - MobileHackerz Knowledgebase Wiki
- [FFmpeg-user] How to output real frame number instead of sequentially added image numbers
- Frame Number Overlay With FFmpeg - Stack Overflow
- [FFmpeg-devel] [PATCH] img2: added support for %t output pattern
- video - How to extract a fixed number of frames with ffmpeg? - Stack Overflow
- FFprobeTips – FFmpeg
- node.js - Pipe output of ffmpeg using nodejs stdout - Stack Overflow
- node.js - NodeJS - piping multiple FFMPEG processes - Stack Overflow
- node.js - FFmpeg Stream RTSP input and save to file at the same time using nodejs - Stack Overflow
- javascript - node.js live streaming ffmpeg stdout to res - Stack Overflow
- node.js - How to capture a log message coming out of node JS spawn ffmpeg command - Stack Overflow
- ffmpeg exited with code 1: pipe:1: Invalid argument · Issue #337 · fluent-ffmpeg/node-fluent-ffmpeg
- 'Error opening filters' on mp4 stream · Issue #353 · fluent-ffmpeg/node-fluent-ffmpeg
- Converting GIF buffer to MP4 buffer without writing to file first · Issue #567 · fluent-ffmpeg/node-fluent-ffmpeg
- node.js - ffmpeg convert stream to jpg buffer without saving do disk - Stack Overflow
- javascript - Node.js - Buffer Data to Ffmpeg - Stack Overflow
- サンプルで使って慣れる。ffmpeg の使い方。 - それマグで!
- ffmpeg に関する覚え書き – dyama's page
- コマンドラインからffmpegを使ってみる - eggshell blue
- FFmpeg - Wikipedia
- ffmpeg - How to dump raw RTSP stream to file? - Stack Overflow
- video capture - FFMPEG: how to save input camera stream into the file with the SAME codec format? - Stack Overflow
- javascript - node.js live streaming ffmpeg stdout to res - Stack Overflow
- Windows の ffmpeg で生放送する方法 : ニコニコ動画研究所
- node.js - Pipe output of ffmpeg using nodejs stdout - Stack Overflow
- ffmpeg raw vcodec copy avi - Google 検索
- サンプルで使って慣れる。ffmpeg の使い方。 - それマグで!
- How to convert a raw video using ffmpeg - Ask Ubuntu
- ffmpegでエンコードした動画をそのまま垂れ流すサーバー - Qiita
- agsh/rtsp-ffmpeg: Node.js FFMpeg wrapper for streaming RTSP into MotionJPEG