0

I'd really appreciate help with this one. I am recording video via a webcam with my beaglebone black. The formats supported by the camera are shown below.

    v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
    Index       : 0
    Type        : Video Capture
    Pixel Format: 'YUYV'
    Name        : YUV 4:2:2 (YUYV)

    Index       : 1
    Type        : Video Capture
    Pixel Format: 'MJPG' (compressed)
    Name        : MJPEG

When I record a raw 4:2:2 YUV video clip, there is no way to play it back to view, so I am trying to convert it to mp4 with ffmpeg.

It states that yuyv422 is an incompatible pixel format, so I try to first convert the video to 420p with the below command, output_422.yuv being the video that I recorded from the camera.

ffmpeg -y -pix_fmt yuyv422 -s 640x480 -r 30 -i output_422.yuv -f rawvideo -pix_fmt yuv420p -s 640x480 -r 30 output_420.yuv

The result is :

    Input #0, rawvideo, from 'output_422.yuv':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: rawvideo, yuyv422, 640x480, 30 tbr, 30 tbn, 30 tbc
[buffer @ 0x41520] w:640 h:480 pixfmt:yuyv422
[avsink @ 0x412c0] auto-inserting filter 'auto-inserted scaler 0' between the 
filter 'src' and the filter 'out'
[scale @ 0x44700] w:640 h:480 fmt:yuyv422 -> w:640 h:480 fmt:yuv420p 
flags:0x4
Output #0, rawvideo, to 'output_420.yuv':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: rawvideo, yuv420p, 640x480, q=2-31, 200 kb/s, 90k 
tbn, 30 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
Error while decoding stream #0.0
frame=   11 fps=  0 q=0.0 Lsize=    4950kB time=0.37 bitrate=110592.0kbits/s
video:4950kB audio:0kB global headers:0kB muxing overhead 0.000000%

I then try to convert this to mp4 like this :

ffmpeg -f rawvideo -pix_fmt yuv420p -s 640x480 -r 30 -i output_420.yuv -vcodec libx264 output.mp4

It looks like the conversion is successful, however when I try to play this back via vlc player, I have no video, just flickering for a few seconds. I have tried changing resolutions, frame rates etc. but no joy. Something is wrong somewhere but not sure where.

Would anyone have some idea as to what could be wrong? Thanks

Engineer999
  • 3,683
  • 6
  • 33
  • 71
  • 1
    Why not use the second format that is listed (MJPEG) instead of using the raw YUYV? You should be able to directly play that with vlc without any conversion. – w-m Jun 15 '18 at 08:55
  • Why do you use two intermediate files? It would be faster and easier to directly let ffmpeg record from the v4l device and encode the video stream. ffmpeg can do the colorspace conversion in the fly. – micha137 Jun 18 '18 at 10:59
  • Actually yes, I was able to directly encode the video in MJPEG instead and directly play it. Thanks for your help – Engineer999 Jun 19 '18 at 14:57

0 Answers0