How do you edit an MPEG-2 (VOB) video file then encode it while keeping the quality exactly the same? I’ve read that to retain the original quality, you need to match the export bitrate with the source bitrate. Is this true? It would make sense.
See this topic if you read through it all you will see that it is theoretically possible, however in practice not consistently achievable and the percieved quality depends on the viewing device.
See this topic if you read through it all you will see that it is theoretically possible, however in practice not consistently achievable and the percieved quality depends on the viewing device.
. . . . How do you edit an MPEG-2 (VOB) video file then encode it while keeping the quality exactly the same? . . . . Surely it should work if you match the bitrates? . . . .
That depends on the edits you make, and if Smart render or Smart Copy will work, otherwise the video must be re-rendered, the encoder the making new decisions on how it is rendered ie where to reduce the bitrate and where to increase it.
Re-encoding almost always results in some loss of quality but with the proper settings the loss can be virtually unnoticeable. It's a good idea to minimize unnecessary re-encoding but not the end of the world.
Re-encoding almost always results in some loss of quality but with the proper settings the loss can be virtually unnoticeable. It's a good idea to minimize unnecessary re-encoding but not the end of the world.
Hi, but I don’t quite understand how there can be a loss of quality if you encode it with exactly the same bitrate as the source.
. . . . How do you edit an MPEG-2 (VOB) video file then encode it while keeping the quality exactly the same? . . . . Surely it should work if you match the bitrates? . . . .
That depends on the edits you make, and if Smart render or Smart Copy will work, otherwise the video must be re-rendered, the encoder the making new decisions on how it is rendered ie where to reduce the bitrate and where to increase it.
John EB
But, again, if you match the bitrate with the source then how can there be a loss of quality?
I'm sure I will get slapped for this, but here goes :-)
Ask yourself what the word encoding means and what the primary job of an encoder is. It is to reduce the file size of information while trying to retain detail. Raw data from a sensor is not in itself an image file but a set of instructions that have to be encoded to start with to produce a readable set of images that can be laid down into a timeline before it even reaches an editing or playback program. Then when you edit anything, you change what is now there in the present timeline from the timeline it once represented. So the frames have to be re-read and reassembled into a file that then can be read but with alterations to fit the new timeline. Every frame has altered its position in the timeline from the first cut. Every frame has to be repositioned and told where to be and which frame it now is.
Remember that when you cut a file you have effectively given it a new end or beginning. When you push them together in an editor they are still separate files but can be read in sequence by the editor without stopping at the end of each file. If the file has accompanying audio, that has to be edited and joined in a different way to the image frames. Audio can't always be cut exactly where an image may end but instead exactly where the wave is at the zero point of amplitude in the waveform, or there will be a sharp and audible click in the soundtrack at that point. There are similar but different problems whith adjoining image frames that have been spliced together. There are separate parts of the code that keep the soundtrack and visuals in sync. Anything short of a sharp splice means another look at the information for evaluation and rendering. Even a sharp splice has to follow certain demands of the code to properly play back.
When you take any file from anywhere it has already been encoded at least once.
Even if you use the same codec and parameters, you are effectively asking the codec to do the same job again of reducing the file size again. While the result can be very close to the file it is copying there will be alterations in the form of smoothing of nearby pixels where gradients of colour and contrast are closely matched. You can only get an exact match where no encoding needs to take place, but as each clip needs to be altered to fit the timeline as a cohesive stream of information, this is almost impossible.
This explanation is a bit oversimplified but even if you copy an old photograph using old methods, the result of the copy is slightly differenct due to the film particles not being in exactly the same places or exactly the same size or shape on the new bit of film, assuming everything else is equal, such as exposure times etc. So each generation of copy you get away from the original gets more fuzzy. It's just the same in the digital domain if you do anything other than a straight copy, but for different reasons.
I'm sure I will get slapped for this, but here goes :-)
Ask yourself what the word encoding means and what the primary job of an encoder is. It is to reduce the file size of information while trying to retain detail. Raw data from a sensor is not in itself an image file but a set of instructions that have to be encoded to start with to produce a readable set of images that can be laid down into a timeline before it even reaches an editing or playback program. Then when you edit anything, you change what is now there in the present timeline from the timeline it once represented. So the frames have to be re-read and reassembled into a file that then can be read but with alterations to fit the new timeline. Every frame has altered its position in the timeline from the first cut. Every frame has to be repositioned and told where to be and which frame it now is.
Remember that when you cut a file you have effectively given it a new end or beginning. When you push them together in an editor they are still separate files but can be read in sequence by the editor without stopping at the end of each file. If the file has accompanying audio, that has to be edited and joined in a different way to the image frames. Audio can't always be cut exactly where an image may end but instead exactly where the wave is at the zero point of amplitude in the waveform, or there will be a sharp and audible click in the soundtrack at that point. There are similar but different problems whith adjoining image frames that have been spliced together. There are separate parts of the code that keep the soundtrack and visuals in sync. Anything short of a sharp splice means another look at the information for evaluation and rendering. Even a sharp splice has to follow certain demands of the code to properly play back.
When you take any file from anywhere it has already been encoded at least once.
Even if you use the same codec and parameters, you are effectively asking the codec to do the same job again of reducing the file size again. While the result can be very close to the file it is copying there will be alterations in the form of smoothing of nearby pixels where gradients of colour and contrast are closely matched. You can only get an exact match where no encoding needs to take place, but as each clip needs to be altered to fit the timeline as a cohesive stream of information, this is almost impossible.
This explanation is a bit oversimplified but even if you copy an old photograph using old methods, the result of the copy is slightly differenct due to the film particles not being in exactly the same places or exactly the same size or shape on the new bit of film, assuming everything else is equal, such as exposure times etc. So each generation of copy you get away from the original gets more fuzzy. It's just the same in the digital domain if you do anything other than a straight copy, but for different reasons.
Hi, so basically it is absolutely impossible to re-encode an MPEG-2 (VOB) file without losing quality?
I personally don't know of a way to do it. I don't think anyone is going to tell you it's impossible, but at home level, I would seriously doubt it. High end professionals are working with log file footage, not already compressed formats. Even then their output will look different by the time they have edited it down to a level it can either be viewed domestically or to a broadcast level but their main concern is one of matching individual scenes for continuity.
No-one else seeing your footage will ever see the same results you do, assuming they don't watch on the same monitor you do. People get too obsessed with perceived image quality. One generation away from the original really shouldn't make much difference assuming a reasonable amount of care is taken in the mastering and rendering, but after the fourth or fifth generational copy away from the original, you will really start to be able to tell a difference in quality easily.
Hi, so basically it is absolutely impossible to re-encode an MPEG-2 (VOB) file without losing quality?
I bet you aren't going to be able to see the loss in quality. Maybe if you re-encode several times you might begin to see it. I think you are worrying much about nothing.
Encoding is not digitally copying video data but applying an algorithm to calculate and reduce it. When you decode it you are applying another algorith to expand it. And all algorithms involve rounding. Plus, different encoders use different algorithms. So even if you use the same exact settings, if you apply a different encoder, or version of encoder, you'll get a different result.
I personally don't know of a way to do it. I don't think anyone is going to tell you it's impossible, but at home level, I would seriously doubt it. High end professionals are working with log file footage, not already compressed formats. Even then their output will look different by the time they have edited it down to a level it can either be viewed domestically or to a broadcast level but their main concern is one of matching individual scenes for continuity.
No-one else seeing your footage will ever see the same results you do, assuming they don't watch on the same monitor you do. People get too obsessed with perceived image quality. One generation away from the original really shouldn't make much difference assuming a reasonable amount of care is taken in the mastering and rendering, but after the fourth or fifth generational copy away from the original, you will really start to be able to tell a difference in quality easily.
Unless you render/encode from the same source/project every time?
Hi, so basically it is absolutely impossible to re-encode an MPEG-2 (VOB) file without losing quality?
I bet you aren't going to be able to see the loss in quality. Maybe if you re-encode several times you might begin to see it. I think you are worrying much about nothing.
Encoding is not digitally copying video data but applying an algorithm to calculate and reduce it. When you decode it you are applying another algorith to expand it. And all algorithms involve rounding. Plus, different encoders use different algorithms. So even if you use the same exact settings, if you apply a different encoder, or version of encoder, you'll get a different result.
So, say I had an MPEG-2 VOB file and re-encoded it to H.264 MPEG-4, what would happen then?
Unfortunately, there can be no re-rendering without examination and further rounding of the numbers of any source material other than when working with a LOG file and keeping the end result a log file. Even then, to get the file to a size that is usable (As log files can be truly huge and not fit for general playback outside of an editing environment) it would have to be encoded and rendered and the first step of degradation has set in.
All that newer codecs do is be more efficient at producing smaller sized end files and are cleverer at rounding the nearest numbers in such a way as our eyes find it harder to see the differences. However, you may notice that when reading back on older machines, the machines struggle more to play these files back smoothly and older processors can max out trying to keep up with the decoding requirements. Some devices may refuse to play back such files altogether or overheat trying.
I currently have a recording device that produces files at 4k 60fps using H.246 in either a mov. wrap or MP4 file format that I can't play back on my Windows machine unless inside of MEP and just re-rendering those files to a file my machine can play back on it's own via the Windows app can take ages and has required me to put an extreme heatsink onto my processor to prevent damage.
Just to do that work at reasonable near to real-time rendering speeds I'm going to have to build a new PC and perhaps new monitors and a NAS raid array to go with it. To give you an idea of the file sizes from that device, one minute of video at 4k 60fps is producing close to 500MB file sizes. The heat produced from the unit when recording keeps my hands warm in the winter months.
. . . . it is absolutely impossible to re-encode an MPEG-2 (VOB) file without losing quality? . . . .
Assuming we are referring Perceived, ie visual quality, then the slight loss of quality, as I have commented before, depends on the viewing device capabilities and resolution of the screen and in most cases is insignificant.
You cannot get an exact duplicate of a VOB when you have made even the simplest of edits ie a cut or pair of cuts to remove a section of the video - re-rendering has to occur for the following reasons (which is what @CubeAce was referring to in his post above).
VOBs are a restricted version of MPEG-1 or MPEG-2 streaming video format. The video is made up from Groups of Pictures (GOP) a sequence of images, consisting of 3 different types which enable compression by removing data from 2 of the types.
I frame (Intra coded image) – a full image that is independent of the other frame types. Each GOP starts with an I frame ie the first full image
P frame (Predictive coded image) – contains difference information relative to the previous I or P frame , each P image can only reference one image.
B frame (Bipredictive coded image) – contains difference information relative to previously decoded images. each B image can only reference two images, the one which precedes the B image in display order and the one which follows it, they must be I or P images.
A GOP structure may look like this IBBPBBPBBPBBI
When you make a cut in the video clip and delete the start of the clip the cut may be anywhere within a GOP, this breaks the GOP for example if the cut occurs in the middle of a GOP then its frame sequence may look like this PBBPBBI
This not an incomplete GOP structure so the encoder has to rebuild the GOP to the correct sequence as shown above, ie re-render, it creates a new I frame from the cut part and then takes enough frames from the following complete GOP to make a complete GOP and repeats this process for all the following GOPs until the next edit, where the cycle starts all over again.
I also agree with @ReefHound - you are worrying much about nothing.
I always add some sharpening to the complete movie using Effects, Movie Effects Settings, Sharpness and usually set the sharpness value to 30, this does help improve the perceived quality of the viewed video image.
Thank you for such a comprehensive explanation of the GOP structure. This explains why in the manual it states that cuts made may be out by a few frames when joined. (I think if I'm reading this correctly). The structure itself is also making more sense to me now although there are still things I'm not sure of and probably don't need to understand in full to make use of editing sequences.
Thank you for your highly detailed comment. So bearing in mind what you’ve just explained to me, where does Smart Render fit into this? What does that do if I am able to use it?
There will be some minor loss of quality due to re-rendering this can be mitigated to some extent by adding some overall sharpening to increase the perceived image quality.
Smart Render / Smart Copy is limited in what it can do and will not always be used eg where GOPs have to be reconstructed to meet the requirements of the MPEG-1/2 encoded video structure.
IMHO we have now come full circle with this topic and reached a point where further progress is not possible.
There will be some minor loss of quality due to re-rendering this can be mitigated to some extent by adding some overall sharpening to increase the perceived image quality.
Smart Render / Smart Copy is limited in what it can do and will not always be used eg where GOPs have to be reconstructed to meet the requirements of the MPEG-1/2 encoded video structure.
IMHO we have now come full circle with this topic and reached a point where further progress is not possible.
John EB
Thank you for your information. I had one more thing to add to this topic. You mentioned that some loss of quality is unavoidable due to re-rendering, which I accept. But what happens when I set the bitrates to match that of the source’s? Will there still be some loss of quality even if the bitrates match?
@ericlnz got there just before me, however as I have said before, adding some overall sharpening will mitigate / improve the perceived quality to some extent.
If I may pop in on this, since no one has stated a method [that I personally settled on and utilize] for transcoding ('converting to a different codec/format') without losing quality (losing much 'detail') - if I may share what I do:
When archiving old VHS tapes, as an example, if they were converted to DVD format (MPEG-2, 480p, etc; usually within a machine or via USB dongle), you can try to archive them into MPEG-4 format (h.264/avc/mpeg4-part10) with hardly any loss in visible quality by trying to at least double the Bitrate for the audio and video.
That is, if the input Bitrate (from say, DVD) is 8000k, Export the video into MPEG-4/AVC as 16000k (or higher). You can also do this with the audio, to try to preserve the fidelity of that; for example, if the DVD input audio bitrate is 224kbps, Export into MPEG-4/h264/avc with your audio set to 448k or 512k+.
This way, you will at least be sure to 'keep what is there' - at least, as far as video data and compression can allow, as you convert the video data... As stated by the very knowledgeable people above, there is no such thing as 100%/True, non-zero, detail-loss in video handling; but there are many steps that can be taken, to try to assure video fidelity (or at least humanly-perceived quality (as in the helpful 'sharpening' suggestion, above)).
[If the rendering program allows, you can also adjust settings such as the level of Analysis/Partitions/Weighting utilized in the compression itself. I am unsure if MEP allows this level of customization, but if you are using other/3rdparty programs for your 'final' rendering/output to MPEG-4, it is possible to adjust these types of settings (some of which can have a drastic effect on the retained perceptible quality)]
(Optionally, you can also increase the resolution of the video, as in, taking the input DVD resolution of 720x480 and rendering to MPEG4 as 1920x1080; but then you would also have to increase the Bitrate substantially, to encompass all of the new video data 'space' that it takes up (literally, the amount of pixels now utilized to render the video data stream frames). While this is done professionally (called Supersampling and other terms) - as when the 'final' video is rendered into the desired output format/resolution (say FullHD/1080p), it retains much of the perceived detail - it is time and disk-space consuming; and not really needed for home video use/resolutions.)
Anyway, I just wanted to contribute the idea of 'doubling the bitrate' that I personally use when archiving video and attempting to keep perceivable quality. GL with it, whatever you choose to do ~T
If I may pop in on this, since no one has stated a method [that I personally settled on and utilize] for transcoding ('converting to a different codec/format') without losing quality (losing much 'detail') - if I may share what I do:
When archiving old VHS tapes, as an example, if they were converted to DVD format (MPEG-2, 480p, etc; usually within a machine or via USB dongle), you can try to archive them into MPEG-4 format (h.264/avc/mpeg4-part10) with hardly any loss in visible quality by trying to at least double the Bitrate for the audio and video.
That is, if the input Bitrate (from say, DVD) is 8000k, Export the video into MPEG-4/AVC as 16000k (or higher). You can also do this with the audio, to try to preserve the fidelity of that; for example, if the DVD input audio bitrate is 224kbps, Export into MPEG-4/h264/avc with your audio set to 448k or 512k+.
This way, you will at least be sure to 'keep what is there' - at least, as far as video data and compression can allow, as you convert the video data... As stated by the very knowledgeable people above, there is no such thing as 100%/True, non-zero, detail-loss in video handling; but there are many steps that can be taken, to try to assure video fidelity (or at least humanly-perceived quality (as in the helpful 'sharpening' suggestion, above)).
[If the rendering program allows, you can also adjust settings such as the level of Analysis/Partitions/Weighting utilized in the compression itself. I am unsure if MEP allows this level of customization, but if you are using other/3rdparty programs for your 'final' rendering/output to MPEG-4, it is possible to adjust these types of settings (some of which can have a drastic effect on the retained perceptible quality)]
(Optionally, you can also increase the resolution of the video, as in, taking the input DVD resolution of 720x480 and rendering to MPEG4 as 1920x1080; but then you would also have to increase the Bitrate substantially, to encompass all of the new video data 'space' that it takes up (literally, the amount of pixels now utilized to render the video data stream frames). While this is done professionally (called Supersampling and other terms) - as when the 'final' video is rendered into the desired output format/resolution (say FullHD/1080p), it retains much of the perceived detail - it is time and disk-space consuming; and not really needed for home video use/resolutions.)
Anyway, I just wanted to contribute the idea of 'doubling the bitrate' that I personally use when archiving video and attempting to keep perceivable quality. GL with it, whatever you choose to do ~T
Thanks for your input there.
In my case, the format of my videos are MPEG-2 (VOB), the resolution is 720x576i, and the maximum bitrate (or data rate) is 9100kbps. So what bitrate would you recommend using when re-encoding to MPEG-2?