1

I am trying to use ffmpeg to convert a set of YUV frames to a mp4 video. I have a set of YUV frames which named as (each one is an image) : YUV1.yuv YUV2.yuv . . YUv15.yuv The code is:

ffmpeg -s 3840x2160 -pix_fmt yuv420p -i YUV%d.yuv -vcodec libx264 -r 30 -s 3840x2160 output.mp4

It shows that the YUV%d.yuv no such file or directory. I know the png or jpeg or bmp can be named as Img%d.png/jpeg/bmp but perhaps can not be used for .yuv. So is there any way to input a set of yuv images in ffmpeg?

Ying Wang
  • 21
  • 1
  • 6

2 Answers2

1

ffmpeg's wildcard syntax doesn't work on yuv or other video formats, I guess. You could concat them just like:

cat *.yuv > all.yuv  
# or cat `ls |grep "\d*.yuv"` > all.yuv if you like
# or any other complex commands to get the file list
ffmpeg -i all.yuv -c:v libx264 ...

Reference

halfelf
  • 9,737
  • 13
  • 54
  • 63
  • 2
    You can skip the file creation (and stream props have to be signalled): `cat *.yuv | ffmpeg -f rawvideo -s 3840x2160 -pix_fmt yuv420p -framerate 30 -i - -c:v libx264 ...` – Gyan Apr 04 '18 at 11:15
  • Thank u for ur code. I tried this code, but it alwasy shows that 'cat' is not found. – Ying Wang Apr 04 '18 at 12:19
  • Then you should ask yourself [Is there a replacement for cat on Windows](https://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows#60254)? – micha137 Apr 05 '18 at 11:33
0

From ffmpeg documentation: You can use YUV files as input:

ffmpeg -i /tmp/test%d.Y /tmp/out.mpg

It will use the files:

/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...

I found that i needed to use this line:

-r, 21, -pix_fmt, yuv420p, -s, 1280x720, -i, file.Y

https://ffmpeg.org/ffmpeg.html#Video-Options

Hojte
  • 21
  • 2