我想使用ffmpeg
将yuv视频转换为png帧。
我使用的命令是
/root/bin/ffmpeg -i pirkagia_max_vid_qual_one.yuv -s 720x576 -r 25 -pix_fmt yuv420p -f image2 one/image-%3d.png
我收到以下回复:
ffmpeg version git-2015-08-07-8015150 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
libavutil 54. 30.100 / 54. 30.100
libavcodec 56. 57.100 / 56. 57.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 32.100 / 5. 32.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[IMGUTILS @ 0x7fffe8e84760] Picture size 0x0 is invalid
[IMGUTILS @ 0x7fffe8e84310] Picture size 0x0 is invalid
[rawvideo @ 0x3aaf160] Could not find codec parameters for stream 0 (Video: rawvideo (I420 / 0x30323449), yuv420p, -4 kb/s): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
pirkagia_max_vid_qual_one.yuv: could not find codec parameters
Input #0, rawvideo, from 'pirkagia_max_vid_qual_one.yuv':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, -4 kb/s, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'one/image-%3d.png':
Output file #0 does not contain any stream
有什么想法吗?
答案 0 :(得分:1)
在您的情况下,rawvideo demuxer需要其他信息。由于输入中似乎没有标题指定视频参数,因此必须指定它们才能正确解码数据。例如:
ffmpeg -pixel_format yuv420p -video_size 720x576 -framerate 25 -i …
此外,yuv420p
与PNG编码器不兼容,因此您可以将其删除为输出选项,并自动选择适当的像素格式。
答案 1 :(得分:-1)
import os
num = 1
video_name = ['out.yuv']
short = ['yuv']
for i in range(num):
saveroot = 'images/' + short[i]
savepath = 'images/' + short[i] + '/im%03d.yuv'
if not os.path.exists(saveroot):
os.makedirs(saveroot)
print('ffmpeg -y -pix_fmt yuv420p -s 1920x1024 -i ' + 'videos_crop/' + video_name[i] + ' ' + savepath)
os.system('ffmpeg -y -pix_fmt yuv420p -s 1920x1024 -i ' + 'videos_crop/' + video_name[i] + ' ' + savepath)