Skip to content

Play Raw Video Streams

WangBin edited this page Mar 15, 2015 · 5 revisions

Raw YUV Streams

libavformat supports raw video streams that only contains video frame data without any other information.

To get a raw yuv stream for testing, you can run

ffmpeg -i test.mp4 -c:v rawvideo -pix_fmt yuv420p test.yuv

To play the yuv stream with ffplay

ffplay -f rawvideo -pix_fmt yuv420p -s 1280x720 -i test.yuv

To play the yuv stream in QtAV player, you have to set some options for libavformat like ffplay does.

Open Setup dialog->Open AVFormat tab->Fill Extra with format_whitelist=rawvideo video_size=1280x720 pixel_format=yuv420p framerate=25->Play test.yuv

You can also setup in C++ code

QVariantHash fmt_opt;
fmt_opt["format_whitelist"] = "rawvideo"; // since QtAV 1.6 (or since commit e828f9c4)
fmt_opt["video_size"] = "1280x720";
fmt_opt["pixel_format"] = "yuv420p";
fmt_opt["framerate"] = 25;
player->setOptionsForFormat(fmt_opt);
player->setFile("test.yuv");
player->play();

Raw H.264 Streams

If a raw h264 stream does not have timestamp information, you must force a frame rate to the player.

player->setFrameRate(fps);

It's different from raw yuv streams because we can compute the frame number by size for a raw yuv stream.