zinon
zinon

Reputation: 4664

Convert yuv video to png frames using ffmpeg

I want to convert a yuv video to png frames using ffmpeg.

The command I use is

/root/bin/ffmpeg -i pirkagia_max_vid_qual_one.yuv -s 720x576 -r 25 -pix_fmt yuv420p -f image2 one/image-%3d.png

I get the following response:

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

Any idea?

Upvotes: 2

Views: 13796

Answers (2)

Chiranjib Patra
Chiranjib Patra

Reputation: 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)

Upvotes: -1

llogan
llogan

Reputation: 134263

In your case the rawvideo demuxer needs additional information. Since there appears to be no header in your inputs specifying the video parameters you must specify them in order to be able to decode the data correctly. Example:

ffmpeg -pixel_format yuv420p -video_size 720x576 -framerate 25 -i …

Also, yuv420p is incompatible for the PNG encoder, so you can remove that as an output option and an appropriate pixel format will be auto-selected.

Upvotes: 3

Related Questions