Activity › Forums › Compression Techniques › [ffmpeg] Best settings for quick images @ 720p MP4
-
[ffmpeg] Best settings for quick images @ 720p MP4
Lou Logan replied 13 years, 4 months ago 3 Members · 14 Replies
-
Alex Harzy
December 25, 2012 at 11:00 amHello,
I’ve been converting many clips and they all get good using the simple (but powerful) command offfmpeg -i input_file -vcodec libx264 -preset veryfast -crf 20 -acodec libmp3lame -ac 2 -ab 160k output.mp4
I can get enough quality for everything I want.
I figured out two big problems, though:
1) Sometimes, the aspect ratio of the output file is scrumbled. I mean, sometimes the video converted is unnaturally stretched in a 4:3 screen aspect. I don’t know why this happens, I solved this problem by adding “-s 960×540” in the command in the video section.
2) Sometimes, when I convert a two hour mkv to a mp4, the audio is out of sync by a second or two, progressively. This means that at the beginning it’s in sync, but at the end it is not anymore. How can I do to re-sync it? What can I do to convert mkv to mp4 without having this loss of sync?
Thank you and merry X-Mas everybody!
-
Lou Logan
December 25, 2012 at 9:08 pm[Alex Harzy] ”
1) Sometimes, the aspect ratio of the output file is scrumbled. I mean, sometimes the video converted is unnaturally stretched in a 4:3 screen aspect. I don’t know why this happens, I solved this problem by adding “-s 960×540″ in the command in the video section.”With what player(s) does it appear to be incorrect? It’s hard to say what might be going on without the complete ffmpeg console output that appears after you run your command (excluding “-s 960×540”).
[Alex Harzy] ”
2) Sometimes, when I convert a two hour mkv to a mp4, the audio is out of sync by a second or two, progressively.”Does this occur using the same command you showed, or are you modifying it? Also, instead of re-encoding the MKV, you can probably simply re-mux into a MP4 container since the video stream in the MKV is most likely H.264 video which works just fine in MP4 container. Assuming your audio stream is compatible with MP4 container:
ffmpeg -i input.mkv -c copy -map 0 output.mp4 -
Alex Harzy
December 27, 2012 at 5:50 pm[Lou Logan] “instead of re-encoding the MKV, you can probably simply re-mux into a MP4 container since the video stream in the MKV is most likely H.264 video which works just fine in MP4 container. Assuming your audio stream is compatible with MP4 container:
ffmpeg -i input.mkv -c copy -map 0 output.mp4”Really?
Well I probably don’t know the difference between muxing and encoding.
what would that “-c copy” and “-map 0” command do?
I’m confused :-/ -
Lou Logan
December 27, 2012 at 7:02 pm[Alex Harzy] “Well I probably don’t know the difference between muxing and encoding.”
Think of it as a copying and pasting the video and audio into another media container format.
[Alex Harzy] “what would that “-c copy” and “-map 0″ command do?”
“-c copy” enables stream copy mode, and “-map 0” will copy all streams of input 0 (the first input). By default ffmpeg includes only one stream of each type (video, audio, subtitle) present in the input files and adds them to each output file. “-map 0” overrides this default. I usually explicitly include it because users often don’t know that the default behaviour may not include all streams of the input: such as in input with multiple audio streams.
See the documentation on stream copy, stream selection, and stream specifiers. Also see info on “-codec (or ‘-c’ as an alias)” under Main options, and “-map” under Advanced options.
This is my 14th post and they are still being moderated for approval. I wonder how long that lasts.
Reply to this Discussion! Login or Sign Up