1

I have 10 yuv input and each yuv is a frame of WxH (ip0_WxH.yuv, ip1_WxH.yuv, ..., ip9_WxH.yuv)

I need to concatenate all 10 to create a final yuv output with all 10 frames in this.

Option 1:

I used below link to do so. But final yuv output is not proper from frame number 2 onwards. Only first frame looks good. From frame number 2, the buffer address of chroma and luma has may be some wrong indexing and hence the display of the picture is wrong.

Converting more yuv frames to one yuv frame

cat *.yuv > movie.yuv

Option 2:

I tried to use FFMPEG to concatenate the yuvs together : https://trac.ffmpeg.org/wiki/Concatenate

$ cat mylist.txt
file 'ip0_WxH.yuv'
file 'ip1_WxH.yuv'
file 'ip2_WxH.yuv'

Desktop/danny$ ffmpeg -f rawvideo -f concat -safe 0 -i myfile.txt -c out.yuv

but got this error:

...
Trailing options were found on the commandline.
[IMGUTILS @ 0x7fff4d92d720] Picture size 0x0 is invalid
[concat @ 0x558b6c335900] Impossible to open 'ip0_WxH.yuv'
myfile.txt: Invalid argument

Can any one suggest the ffmpeg command to concatenate these YUVs together.


UPDATE:

As per the first answer suggested by llogan, I used below command:

ffmpeg -f image2 -c:v rawvideo -pixel_format rgb24 -video_size 1344x968 -i  ip%d_WxH.yuv output.yuv

Output

~/Desktop/danny$ ffmpeg -f image2 -c:v rawvideo -pixel_format rgb24 -video_size 1344x968 -i  ip%d_WxH.yuv output.yuv
ffmpeg version 3.4.8-0ubuntu0.2 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, image2, from ' ip%d_WxH.yuv':
  Duration: 00:00:00.16, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1344x968, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[rawvideo @ 0x5623405f30c0] Invalid buffer size, packet size 2132928 < expected frame_size 3902976
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 0x5623405f30c0] Invalid buffer size, packet size 2132928 < expected frame_size 3902976
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 0x5623405f30c0] Invalid buffer size, packet size 2132928 < expected frame_size 3902976
Error while decoding stream #0:0: Invalid argument
[rawvideo @ 0x5623405f30c0] Invalid buffer size, packet size 2132928 < expected frame_size 3902976
Error while decoding stream #0:0: Invalid argument
Finishing stream 0:0 without any data written to it.
Output #0, rawvideo, to 'output.yuv':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1344x968, q=2-31, 780595 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.107.100 rawvideo
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Conversion failed!
Danny
  • 68
  • 6
  • 1
    Probably won't make a difference, but you can try `ffmpeg -f image2 -c:v rawvideo -pixel_format rgb24 -video_size 320x240 -i ip%d_WxH.yuv out.yuv` Make sure to use appropriate `-pixel_format` and `-video_size` values for your input. See `ffmpeg -pix_fmts` for a list. – llogan May 26 '21 at 16:56
  • @llogan, I tried with your suggested answer. I have updated my question with the trial . But no luck. More details about errors are there in **UPDATE** sections. – Danny May 26 '21 at 18:52
  • Are you sure these are all rawvideo frames? rawvideo should be the same size each frame. So either some are not rawvideo or the attributes are different such as varying video sizes or pixel formats. – llogan May 26 '21 at 19:02
  • @llogan, thanks for pointing out the issue. – Danny May 26 '21 at 19:07
  • So it was the wrong pixel format. You shouldn't have blindly copied my rgb24 example. That was laziness on my part. Looks like someone already adapted my comment as an answer. – llogan May 26 '21 at 19:19
  • @llogan, I do not have the privilege to vote for the comments as I do not have that many points. But thanks for your answer. Your answer guided me initially. – Danny May 27 '21 at 07:42

1 Answers1

0

Try different yuvformat.

As you are using yuv. So use either yuv422p or yuv420p depends upon your input yuv type.

Try this :

ffmpeg -f image2 -c:v rawvideo -pixel_format yuv420p -video_size 1344x968 -i ip%d_WxH.yuv out.yuv
studinstru
  • 124
  • 12