Low quality output when scaling AVI and converting to MP4

1

I have been trying to scale and avi file, converting it to mp4 at the same time, but the output it horrible. I am using ffmpeg, and found several posts about this conversion without loosing quality. Yet my output gets worse as the video plays.

I have tried using these commands, some found right here on superuser:

ffmpeg -v verbose -i hd.avi -c:v libx264 -crf 19 -preset slow -c:a aac -b:a 192k -ac 2 scaledoutput.mp4

ffmpeg -i hd.avi -strict -2 scaledoutput.mp4

ffmpeg  -v verbose -re -i hd.avi -vf scale=640:480 scaledoutput.mp4

I think it would help if I could attache a sample video of input and output, but don't know how to do that, so a description will have to do. The output starts clear, but starts going downhills as the video plays. The colors are skewed and weird. Audio is clear, but the video is almost unrecognizable.

Any ideas?

Ute

Posted 2017-07-19T22:53:34.077

Reputation: 11

Will need to see sample of both source and "almost unrecognizable" output. Don't upload the full video if it's too large. Use ffmpeg -ss N -t 10 -i file -c copy -avoid_negative_ts make_zero file_sample to extract a portion from both files. Keep sample extension same as source. N should be chosen so that the distortion is visible in the output. – Gyan – 2017-07-20T05:35:29.597

The video is only 17 seconds long. is that short enough? BUT, I don't know how to upload files to this site. Can you tell me how to upload or where to find instructions? Thanks for your reply! – Ute – 2017-07-20T18:00:15.633

I think I found a way to get the videos posted. I put them on my dropbox page. Here is the link to the input file: https://www.dropbox.com/s/dw6ml8iwnnkmoz9/hd.avi?dl=0 and the output file is here: https://www.dropbox.com/s/p19vsn9iasb99km/scaledoutput.mp4?dl=0 Let me know if that works for you.

– Ute – 2017-07-20T19:01:14.717

Answers

0

I have an answer to my question about converting avi files to mp4. It turns out that ffmpeg has a hard time converting non-standard videos. I posted on the ffmpeg User email list and someone named Gyan had a solution for me and Carl Eugene Hoyos filed a bug report with ffmpeg about it.

For now, to convert a non-standard video to avi to mp4 format, you have to preprocess the file using mp4peg to convert it to h264 format. Then you can convert it to mp4 using ffmpeg. Here are the commands:

mp4box -aviraw video hd.avi 
ffmpeg  -v verbose -i hd_video.h264 -i hd.avi -map 0 -map 1:a -vf scale = 640:480 out.mp4

Note: hd.avi is your video, hd_video.h264 is produced by mp4box and the final output will be in out.mp4

The bug report filed on July 25, 2017 with ffmpeg has ticket number 6551. As of October 6, 2017 nothing has been done to fix it.

I hope this helps someone.

Ute

Posted 2017-07-19T22:53:34.077

Reputation: 11