奇数サイズの動画をmp4等に変換しようとするとエラーになる
$ ffmpeg -i infile.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" outfile.mp4 : [libx264 @ 0x55950e5c6e40] width not divisible by 2 (559x353) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
サイズ調整して変換
$ ffmpeg -i infile.webm -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" outfile.mp4
$ ffprobe ./pfetch.mp4 -hide_banner -show_entries format 2>/dev/null [FORMAT] filename=./pfetch.mp4 nb_streams=1 nb_programs=0 format_name=mov,mp4,m4a,3gp,3g2,mj2 format_long_name=QuickTime / MOV start_time=0.000000 duration=24.240000 size=223463 bit_rate=73750 probe_score=100 TAG:major_brand=isom TAG:minor_version=512 TAG:compatible_brands=isomiso2avc1mp41 TAG:encoder=Lavf58.20.100 [/FORMAT]
指定情報のみ取得(ここでは duration
動画時間)
$ ffprobe ./pfetch.mp4 -hide_banner -show_entries format=duration 2>/dev/null [FORMAT] duration=24.240000 [/FORMAT]
$ ls -1 ./file*.mp4 | xargs -I{} ffprobe {} -hide_banner -show_entries format 2>/dev/null | grep duration | cut -f2 -d= | xargs -I{} echo {}/60|bc 230 120
コメント