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?

  • 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 Jul 20 '17 at 5:35
  • 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 Jul 20 '17 at 18:00
  • 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: dropbox.com/s/dw6ml8iwnnkmoz9/hd.avi?dl=0 and the output file is here: dropbox.com/s/p19vsn9iasb99km/scaledoutput.mp4?dl=0 Let me know if that works for you. – Ute Jul 20 '17 at 19:01

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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