How to make an MPEG2 video file with the highest quality possible using FFMPEG?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Orient Looping
--
Chapters
00:00 How To Make An Mpeg2 Video File With The Highest Quality Possible Using Ffmpeg?
02:01 Accepted Answer Score 23
04:36 Answer 2 Score 0
05:07 Thank you
--
Full question
https://superuser.com/questions/835871/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#video #ffmpeg #microsoftpowerpoint #videoconversion #mpeg2
#avk47
ACCEPTED ANSWER
Score 23
The problem is that the default bitrate for the MPEG-2 is rather low (as with most other video encoders in ffmpeg, the H.264 one being an exception). MPEG-2 is also not the best choice as a codec these days.
Better quality for MPEG-2
You have a few options if you want to stick with MPEG-2:
Increase the bitrate. You're now using
-b:v 2500k
. If it's HD video, you will not get far with only 2.5 MBit/s. You need at least double that or even more to make the result look good. For example, use-b:v 6000k -target pal-dvd
.For 720p, I think that you should still use a higher bitrate. Remember that DVDs use MPEG-2 and come in about 4.7 GB for 2hrs of movie, so you end up with around 5–8 MBit/s. MPEG-2 is really not very compression-efficient and works better at higher bitrates.
Use a specific quality setting. Change
-b:v …
to-qscale:v 2
. The number here ranges from 1 to 31 and higher means lower quality. There's no point going beyond 4 or 5. If you don't care for the bitrate start with 2 and see if that works for you.
Messing with the number of B-frames, motion estimation method or GOP size may tweak the quality a little but won't result in big changes.
Silent audio
Use -f lavfi -i aevalsrc=0
to generate a silent audio stream. For example:
ffmpeg -i "in.wmv" -f lavfi -i aevalsrc=0 -shortest -c:v mpeg2video -qscale:v 2 -c:a libmp3lame "out.mpg"
You may need to add -target pal-dvd
to the above command to force a certain buffer size.
I chose MP3 as codec. MPEG files cannot contain audio other than MPEG Layer I and II audio as well as PCM streams, so using a silent Ogg Vorbis file will not work unless you convert the audio stream as well (which is not what you're doing when you use -c:a copy
).
Use a different video codec
I'm surprised that a TV that plays video files will read MPEG-2 but not anything else. At least MPEG-4 Part II video should be supported (that's what you know as "DivX" – an MPEG-4 Part II encoder). So you could try:
ffmpeg -i "in.wmv" -f lavfi -i aevalsrc=0 -shortest -c:v libxvid -qscale:v 2 -c:a libmp3lame "out.mp4"
Your TV might actually also support H.264, but only a certain profile. Try using the baseline
profile, for example:
ffmpeg -i "in.wmv" -f lavfi -i aevalsrc=0 -shortest -c:v libx264 -profile:v baseline -crf 23 -c:a aac -strict experimental "out.mp4"
In the above example I've used the CRF option to set the quality instead of qscale
. See the H.264 encoding guide for more.
ANSWER 2
Score 0
I would immediately say if file-size doesn't really matter then just experiment with increasing the bit-rate.
For the silent audio you may just want to use ffmpeg, I do not know enough about Audacity to give any sort of comment. I have used this before.
ffmpeg.exe -f lavfi -i aevalsrc=0:0::duration=YOUR_DESIRED_DURATION -ab 10k YourAudioName.aac
This won't work for you though since you are using mpg container so you may want to try.(mp3 container)
ffmpeg.exe -f lavfi -i aevalsrc=0:0::duration=YOUR_DESIRED_DURATION -ab 10k YourAudioName.mp3
It seemed to work for me.