-1

I have HD 1920x1080 YUV format videos. I would like to compress them to 640x480and other convert to other format(mp4/avi..) I used the follwing command:

ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 25 -i input.yuv -c:v libx264 output.mp4
It converts the video but it looks **blurry** and **broken**.

Does any one have better solution for my problem? [There are lot of solutions i found as like as the above one but none of them works good] I would most appreciate your help.

11
  • Can you add sample frames?
    – Rekin
    Commented Aug 8, 2015 at 16:38
  • @Rekin, I am not sure what u mean. can u give me code i would try if that helps to compress and..
    – mrana
    Commented Aug 8, 2015 at 18:30
  • Can you upload a screenshot somewhere of a comparison of input and output to indicate why you believe the quality is bad? It sounds to me like you're not selecting any ratecontrol/quality variables for the video encoding, so I'd start by choosing some of these. E.g., try -b:v 1024k -preset:v veryslow (after -c:v libx264, but before output.mp4). See also trac.ffmpeg.org/wiki/Encode/H.264 Commented Aug 8, 2015 at 18:53
  • original(yuv):dropbox.com/s/a1hf5hv6omqthaw/original.png?dl=0 After compression(mp4): dropbox.com/s/2m7f43vwvtjvyuo/after-compression.png?dl=0
    – mrana
    Commented Aug 8, 2015 at 22:17
  • @RonaldS.Bultje this code: ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 1920x1080 -r 25 -i input.yuv -c:v libx264 -b:v 1024k -preset:v veryslow output.mp4 Broken output: dropbox.com/s/7bhq6pe4cpz2u5x/test2.png?dl=0
    – mrana
    Commented Aug 9, 2015 at 9:16

2 Answers 2

1

Your videos are not yuv420p, they are yuv422p. Use the following commandline:

ffmpeg -f rawvideo -pix_fmt yuv422p -s:v 1920x1080 -r 25 -i input.yuv -c:v libx264 output.mp4

And then use rate control variables for H264 encoding as documented here.

9
  • This is excellent!! How i can convert the video to the ration: 640 × 480 Thanks so much.
    – mrana
    Commented Aug 10, 2015 at 13:44
  • ffmpeg -f rawvideo -pix_fmt yuv422p -s:v 1920x1080 -r 25 -i input.yuv -c:v libx264 -vf scale=640:480 output.mp4 Commented Aug 10, 2015 at 15:01
  • Dear @Ronald I don't want loss of quality from the original to new one. How can i proof that the video quality did not change, may be PSNR value? Also, if the video quality changes then can we do less number of distortion of the video quality? I would be grateful to have some ideas. Thanks again.
    – mrana
    Commented Aug 12, 2015 at 20:40
  • No quality loss means "lossless", check the lossless section in trac.ffmpeg.org/wiki/Encode/H.264 - to check for that, use e.g. the psnr filter: ffmpeg -f rawvideo -pix_fmt yuv422p -s:v 1920x1080 -r 25 -i input.yuv -i output.mp4 -lavfi psnr -f null -, and check for the line "[Parsed_psnr_0 @ 0x7f8b98525600] PSNR y:inf u:inf v:inf average:inf min:inf max:inf" in the output. A value of inf means the conversion was lossless. A typical value is around 40, anything substantially higher (50 or 60) is incredible good quality, and anything below (e.g. 30) is pretty terrible. Commented Aug 13, 2015 at 11:43
  • Dear Ronald, thanks so much (i will respond you on this later). I posted another question: stackoverflow.com/questions/31981455/… Still no solution i got, can u please check that too. Many thanks
    – mrana
    Commented Aug 13, 2015 at 15:52
0

You are not specifying a quality factor, or a bit rate, So a default value is being chosen for you. try adding something like -crf 18.

2

Not the answer you're looking for? Browse other questions tagged or ask your own question.