0
I have a collection of avi videos (say A).
I first convert them into MPEG4 Part2 (say B) using ffmpeg -i ${inname} -vf scale=340:256,setsar=1:1 -q:v 1 -c:v mpeg4 -g 12 -f rawvideo ${outname}. The total file size is 3.5G.
Then using B as input, I apply the same command to transcode B again into C, which has size 3.1G.
I thought B and C have the same format and thus should have the same file size? Why not and how can I resolve it to make sure no information loss in the second transcoding process?
2Transcoding *always* looses data. Video encoding is lossy. – Mokubai – 2018-12-22T22:34:00.323
Thanks. But B and C have the same formats such as block size, number of p-frames, etc. It should be possible to make it lossless -- consider just duplicating B as C, right? – apoliver – 2018-12-22T23:42:47.700
By simply copying the video to a new container, yes. By transcoding, no. Ffmpeg supports copying using
-c:v copy– Mokubai – 2018-12-22T23:47:46.457Thanks. But my goal is not just copying. I'd like to learn which factors lead to this loss in the second stage and I want to avoid such second quality loss when I use other different codecs. – apoliver – 2018-12-23T00:49:31.810
BTW, by copying the video to a new container,
-c:v copy, do you mean that, say copy a video from H.264 to MPEG4 Part2, the format can still be changed to accommodate MPEG4 Part2 but no information loss? Thanks. Sorry that I am new to video compression... I guess the answer is no because I need to specify-c:v mpeg4? or I just need to name the output as .mp4 ? – apoliver – 2018-12-26T16:57:12.050if the video is contained within an mkv file but is an h.264 video then you can use the copy method to move it to to an mp4 file without any loss in quality. It is simply moving video from one container file to another without generational loss. If you are converting between codecs (from h.264 to MPEG 4 Part 2) then even if you specify a higher bitrate you will loose quality due to the lossy algorithms involved. You should read about generation loss to better understand what is going on.
– Mokubai – 2018-12-26T19:00:52.547very helpful! much appreciated! – apoliver – 2018-12-26T20:04:11.583