ffmpeg - 把vcd (dat ) 转换成多个图片,然后再组合

访问量: 90

我自己提出的问题:

https://stackoverflow.com/questions/68207429/how-to-use-ffmpeg-to-convert-vcddat-file-to-a-batch-of-images-then-convert-th

把video拆分成图片:

参考:https://stackoverflow.com/questions/40088222/ffmpeg-convert-video-to-images

图片组合成video: 

https://stackoverflow.com/questions/22965569/convert-from-jpg-to-mp4-by-ffmpeg

VCD格式的视频,一秒的fps是25 . 

所以,可以根据这个命令来转换:

ffmpeg -i MUSIC01-马礼堂养气功VCD.DAT -vf fps=40 -ss 00:09:00 -t 10 images/out-%08d.png

(从 -ss 00:09:00 开始, -t 持续10秒 , fps: 每秒40帧)

每个VCD的图片大小是 352 x 288, png 格式

ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mpeg, from 'MUSIC01-马礼堂养气功VCD.DAT':
  Duration: 00:58:04.32, start: 0.653333, bitrate: 1411 kb/s
    Stream #0:0[0x1e0]: Video: mpeg1video, yuv420p(tv), 352x288 [SAR 178:163 DAR 1958:1467], 1120 kb/s, 25 fps, 25 tbr, 90k tbn, 25 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 44100 Hz, stereo, s16p, 224 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg1video (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'images/out-%08d.png':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: png, rgb24, 352x288 [SAR 178:163 DAR 1958:1467], q=2-31, 200 kb/s, 40 fps, 40 tbn, 40 tbc
    Metadata:
      encoder         : Lavc57.107.100 png
frame=  400 fps= 38 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=0.945x    
video:67161kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

ffmpeg 的详细解释:

组合图片的格式:https://ffmpeg.org/ffmpeg-formats.html#image2-1

%3d, %08d , glob 是啥意思(极其详细): https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence

组合时候的注意:

1. 图片必须从 00001, 00002 这样的开始,

2. 图片必须是连续的, 例如 00001, 00002, .... 09999, 10000,  中间绝对不可以断掉

对于不方便肉眼查看的大文件夹,建议使用 ll target_dir > /tmp/files ,  来查看。

订阅/RSS Feed

Subscribe

分类/category