Reputation: 1305
I need convert all videos to my video player (in website) when file type is other than flv/mp4/webm.
When I use: ffmpeg -i filename.mkv -sameq -ar 22050 filename.mp4
:
[h264 @ 0x645ee0] error while decoding MB 22 1, bytestream (8786)
My point is, what I should do, when I need convert file type: .mkv and other(not supported by jwplayer) to flv/mp4 without quality loss.
Upvotes: 28
Views: 108723
Reputation: 2744
For MP3, the best is to use -q:a 0
(same as '-qscale 0'), but MP3 has always loss quality.
To have less loss quality, use FLAC
See this documentation link
Upvotes: 1
Reputation: 65
For me that was the best way to convert it.
ffmpeg -i {input} -vcodec copy {output}
I am writing a script in python that appends multiple .webm files to one .mp4. It was taking me 10 to 20 seconds to convert one chunk of 5 seconds using:
ffmpeg -i {input} -qscale 0 copy {output}
There's some folders with more than 500 chunks.
Now it takes less than a second per chunk. It took me 5 minutes to convert a 1:20:00 long video.
Upvotes: 4
Reputation: 133753
-sameq
, it does not mean "same quality"This option has been removed from FFmpeg a while ago. This means you are using an outdated build.
Use the -crf
option instead when encoding with libx264. This is the H.264 video encoder used by ffmepg
and, if available, is the default encoder for MP4 output. See the FFmpeg H.264 Video Encoding Guide for more info on that.
ffmpeg
Go to the FFmpeg Download page and get a build there. There are options for Linux, OS X, and Windows. Or you can follow one of the FFmpeg Compile Guides. Because FFmpeg development is so active it is always recommended that you use the newest version that is practical for you to use.
You can produce a lossless output with libx264, but that will likely create absolutely huge files and may not be decodeable by the browser and/or be supported by JW Player (I've never tried).
The good news is that you can create a video that is roughly visually lossless. Again, the files may be somewhat large, but you need to make a choice between quality and file size.
With -crf
choose a value between 18 to around 29. Choose the highest number that still gives an acceptable quality. Use that value for your videos.
Add -movflags +faststart
. This will relocate the moov atom from the end of the file to the beginning. This will allow the video to begin playback while it is still being downloaded. Otherwise the whole video must be completely downloaded before it can begin playing.
Add -pix_fmt yuv420p
. This will ensure a chroma subsampling that is compatible for all players. Otherwise, ffmpeg
, by default and depending on several factors, will attempt to minimize or avoid chroma subsampling and the result is often not playable by non-FFmpeg based players.
Upvotes: 29
Reputation: 1720
Instead of -sameq (removed by FFMpeg), use -qscale 0
: the file size will increase but it will preserve the quality.
Upvotes: 32
Reputation: 87
convert all mkv to mp4 without quality loss (actually it is only re-packaging):
for %a in ("*.mkv") do ffmpeg.exe -i "%a" -vcodec copy -acodec copy -scodec mov_text "%~na.mp4"
Upvotes: 7