Deinterlace and change framerate with -vcodec copy
Hello everyone! I would like ask for an advice. I have some mpegts files captured from DVB card. They contain some video streams and some audio streams. I know how to extract the streams from the mpegts file and how to use them to create a mkv file, for example. I do it like this:ffmpeg -i DVBchannel.mpegts -vcodec copy -acodec copy movie.mkv But I have a problem with the resulting file. The original video streams (in file DVBchannel.mpegts) are interlaced at 50fps. I want the final file to play as simply as possible (e.g. without the deinterlace filters), so I would like to deinterlace the video in advance. But I assume it is not possible with -vcodec copy. Or am I mistaken? If it would be achievable, it would probably only work with those video codecs, for which it is possible to somehow easily combine the two adjacent video frames into one. Anyway, is there such a codec? My point here is that I do not want to reencode the video "just" to deinterlace it. But as far as I know it is necessary in order to use the deinterlacing filters. Am I correct? To my knowledge, the deinterlace filters just somehow combine the frames together, but they do not change the framerate. And here, I _want_ the framerate to be changed from 50fps to 25fps. So, basically, I _want_ half of the frames to be deleted. But, I want the resulting frames to be complete, not just odd or even lines. So, is it possible with -vcodec copy? And my second question is about the framerate itself. Let's say I have managed to get a 25fps noninterlaced file movie.mkv. Is there any "easy" way to change the framerate to 24fps? By "easy" I mean without reencoding (or: with -vcodec copy). This, in my opinion, should be possible, because it seems like a rather minor change. Here I would like to emphasize that what I want to change is the _framerate_ not the number of frames. So, I expect the video to be longer (take more time to play) after such a framerate change. Here: http://www.hdslr-cinema.com/news/workflow/convert-between-framerates/the author mentions that such a framerate change is referred to as "conforming". I tried the intermediate rawvideo format method described on the mentioned website, but it is not a solution for me, because it requires reencoding. I would really like to do it with -vcodec copy. Is is possible? It it is, which codecs allow for framerate changes like this? Thank you for your time. Peter Basista
On 21/05/2011 01:52, Peter Basista wrote:
Hello everyone! I would like ask for an advice. I have some mpegts files captured from DVB card. They contain some video streams and some audio streams. I know how to extract the streams from the mpegts file and how to use them to create a mkv file, for example. I do it like this:ffmpeg -i DVBchannel.mpegts -vcodec copy -acodec copy movie.mkv But I have a problem with the resulting file. The original video streams (in file DVBchannel.mpegts) are interlaced at 50fps.
I want the final file to play as simply as possible (e.g. without the deinterlace filters), so I would like to deinterlace the video in advance. But I assume it is not possible with -vcodec copy. Or am I mistaken? If it would be achievable, it would probably only work with those video codecs, for which it is possible to somehow easily combine the two adjacent video frames into one. Anyway, is there such a codec? My point here is that I do not want to reencode the video "just" to deinterlace it. But as far as I know it is necessary in order to use the deinterlacing filters. Am I correct? To my knowledge, the deinterlace filters just somehow combine the frames together, but they do not change the framerate. And here, I _want_ the framerate to be changed from 50fps to 25fps. So, basically, I _want_ half of the frames to be deleted. But, I want the resulting frames to be complete, not just odd or even lines. So, is it
No, I very much doubt that is true. There are no DVB broadcasters that I know of which transmit at 100 fields per second, which is what you are implying. Please supply the output of "ffmpeg -i DVBchannel.mpegts" possible with -vcodec copy?
And my second question is about the framerate itself. Let's say I have managed to get a 25fps noninterlaced file movie.mkv. Is there any "easy" way to change the framerate to 24fps? By "easy" I mean without reencoding (or: with -vcodec copy). This, in my opinion, should be possible, because it seems like a rather minor change. Here I would like to emphasize that what I want to change is the _framerate_ not the number of frames. So, I expect the video to be longer (take more time to play) after such a framerate change. Here: http://www.hdslr-cinema.com/news/workflow/convert-between-framerates/the author mentions that such a framerate change is referred to as "conforming". I tried the intermediate rawvideo format method described on the mentioned website, but it is not a solution for me, because it requires reencoding. I would really like to do it with -vcodec copy. Is is possible? It it is, which codecs allow for framerate changes like this? Thank you for your time. Peter Basista
_______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Hello everyone!>>>> I would like ask for an advice.>>>> I have some mpegts files captured from DVB card.>> They contain some video streams and some audio streams.>> I know how to extract the streams from the mpegts file>> and how to use them to create a mkv file, for example.>> I do it like this:>> ffmpeg -i DVBchannel.mpegts -vcodec copy -acodec copy movie.mkv>>>> But I have a problem with the resulting file. The original>> video streams (in file DVBchannel.mpegts) are interlaced at 50fps. No, I very much doubt that is true. There are no DVB broadcasters that I> know of which transmit at 100 fields per second, which is what you are> implying. Please supply the output of "ffmpeg -i DVBchannel.mpegts" Okay, I am sorry, you are right. I have posted somethingthat is definitely confusing. I should have written 50 fields per second, not frames per second.By "interlaced at 50fps" I was trying to tell that the video contains50 fields (or half frames) per second. But I did not know aboutthe difference between frames and fields before you replied.So, thank you for pointing that out. You wanted me to post output from ffmpeg -i DVBchannel.mpegts, so here it is: Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)Input #0, mpegts, from 'DVBchannel.mpegts': Duration: 01:23:55.58, start: 54068.412678, bitrate: 5916 kb/s Program 1 Stream #0.0[0x44d]: Video: h264 (Main), yuv420p, 1440x1080 [PAR 4:3 DAR 16:9], 55.22 fps, 50 tbr, 90k tbn, 50 tbc Stream #0.1[0x44e](eng): Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s I have reformulated the remaining part of my original email, so I repost it. I want the final file to play as simply as possible(e.g. without the deinterlace filters), so I would like to deinterlacethe video in advance. But I assume it is not possible with -vcodec copy.Or am I mistaken? My point here is that I do not want to reencode the video "just"to deinterlace it. I want to do it as simply as possible, utilizingas much previous encoding work as possible. But as far as I know,it is necessary to completely reencode the video in order touse the deinterlacing filters. Am I correct? To my knowledge, the deinterlace filters just somehowcombine the fields (half frames) together, but they do not changethe framerate. So, my first question is: Is there a video codecfor which it is possible to deinterlace video with -vcodec copy?I would really appreciate if it would be possible for h264. And my second question is about the framerate itself. Let's say I have managed to get a 25fps noninterlaced file movie.mkv.Is there any "easy" way to change the framerate to 24fps?By "easy" I mean without reencoding (or: with -vcodec copy). This, in my opinion, should be possible, because it seems likea rather minor change. Here I would like to emphasize thatwhat I want to change is the framerate, not the number of frames. So, I expect the video to be longer (take more time to play)after such a framerate change. Here:http://www.hdslr-cinema.com/news/workflow/convert-between-framerates/the author mentions that such a framerate changeis referred to as "conforming". I tried the intermediate rawvideo format method describedon the mentioned website, but it is of no use for me,because it requires reencoding. I would really like to do itwith -vcodec copy. Is is possible? If it is, which codecsallow for framerate changes like this? Does h264 support it? Thank you for your time. Peter Basista
But I assume it is not possible with -vcodec copy. Or am I mistaken? You are not mistaken. Deinterlacing only works on uncompressed video and changes the video data (or more accurately, it creates new video data
To my knowledge, the deinterlace filters just somehow combine the frames together, but they do not change the framerate. It depends on the strategy used by the filter. Yadif, for example, can
And here, I _want_ the framerate to be changed from 50fps to 25fps. So, basically, I _want_ half of the frames to be deleted. But, I want the resulting frames to be complete, not just odd or even lines. 2 fields = 1 frame. Each field is half of the picture. Uncompressed, 50 fields contain the same amount of data as 25 frames. Let's say I have managed to get a 25fps noninterlaced file movie.mkv. Is there any "easy" way to change the framerate to 24fps? By "easy" I mean without reencoding (or: with -vcodec copy). You could simply drop every 25th frame or simply change the headers (I recommend changing container headers) to tell the player to play 24fps (which will make it slower, and you'll lose sync if you don't adjust the audio). If you're trying to get the original 23.976fps of a movie from a 50i source, I can't really give much advice because I don't know all the
On 2011.05.20 07:52 PM, Peter Basista wrote: based on the input), so it is impossible to deinterlace without decoding. produce one frame for each field, doubling the framerate, or it can produce a frame for each pair of fields, leaving the framerate the same. details involved in handling film content in PAL broadcast systems.
This, in my opinion, should be possible, because it seems like a rather minor change. Here I would like to emphasize that what I want to change is the _framerate_ not the number of frames. So, I expect the video to be longer (take more time to play) after such a framerate change. In this case, you should be able to change the framerate in the container headers. mkvtoolnix would be suitable for manipulating Matroska containers.
But I assume it is not possible with -vcodec copy. Or am I mistaken? You are not mistaken. Deinterlacing only works on uncompressed video and changes the video data (or more accurately, it creates new video data based on the input), so it is impossible to deinterlace without decoding.
Thank you for pointing that out and explaining it in more detail. Mark has already suggested the same view, so I think it is clear now.
To my knowledge, the deinterlace filters just somehow combine the frames together, but they do not change the framerate. It depends on the strategy used by the filter. Yadif, for example, can produce one frame for each field, doubling the framerate, or it can produce a frame for each pair of fields, leaving the framerate the same.
We have been discussing this as well. But thank you anyway for more information.
And here, I _want_ the framerate to be changed from 50fps to 25fps. So, basically, I _want_ half of the frames to be deleted. But, I want the resulting frames to be complete, not just odd or even lines. 2 fields = 1 frame. Each field is half of the picture. Uncompressed, 50 fields contain the same amount of data as 25 frames.
Yes, now I know that. Mark has pointed that out and explained some details. It should be clear now.
Let's say I have managed to get a 25fps noninterlaced file movie.mkv. Is there any "easy" way to change the framerate to 24fps? By "easy" I mean without reencoding (or: with -vcodec copy). You could simply drop every 25th frame
Actually, according to information from Mark, this would require reencoding. And I agree with that, because it sounds reasonable. You have to somehow fill in the "blank spot" created by a dropped frame. Let's say you delete frame number 100. Then you have to completely change the way frame 101 is computed, because it was originally computed from frame 100, which is now gone. So, you will have to encode at least the transition from the frame 99 to 100 and from 100 to 101 into one new transition (from frame 99 to frame 101)... So, I believe encoding is required, at least for the frames just after the dropped frames. But, as I mentioned, this is not what I would like to do.
or simply change the headers (I recommend changing container headers) to tell the player to play 24fps (which will make it slower, and you'll lose sync if you don't adjust the audio). If you're trying to get the original 23.976fps of a movie from a 50i source, I can't really give much advice because I don't know all the details involved in handling film content in PAL broadcast systems.
All right, that's okay. Actually you made the point. This is exactly what I am trying to achieve. Although I am not sure at the moment what should the target frame rate be (24 fps or 23.976 fps), it is not important right now. The challenge is to decrease the frame rate in general without changing the number of frames and without reencoding.
This, in my opinion, should be possible, because it seems like a rather minor change. Here I would like to emphasize that what I want to change is the _framerate_ not the number of frames. So, I expect the video to be longer (take more time to play) after such a framerate change. In this case, you should be able to change the framerate in the container headers. mkvtoolnix would be suitable for manipulating Matroska containers.
Thank you for a suggestion. I will try that. But even if I succeed in changing the container's headers in a way that the video will play at 96% speed, I am not sure if I want to do it. The reason is simple. If someone later extracts the video out of this container, what would its frame rate be? I suppose it will remain unchanged at the "old" value, which means 25 fps. And this is what I want to avoid. I want the fps change to be more robust than that. I don't want the careless container changes to blow the fps change away. That's why I consider changing PTS (presentation time stamps) of the video frames as suggested by Mark as better, more stable solution. The only problem is I don't know how to do it. (yet) :) Peter Basista
On 2011.05.22 01:43 PM, Peter Bašista wrote:
Let's say I have managed to get a 25fps noninterlaced file movie.mkv. Is there any "easy" way to change the framerate to 24fps? By "easy" I mean without reencoding (or: with -vcodec copy). You could simply drop every 25th frame
Actually, according to information from Mark, this would require reencoding. And I agree with that, because it sounds reasonable. You have to somehow fill in the "blank spot" created by a dropped frame. I was a little simplistic there. If nothing depends on a frame for information, that frame can be dropped (IIRC, B-frames can be discarded; otherwise all frames must be I-frames). However, especially with the short GOPs in broadcast streams, you are still likely to drop a lot of P-frames and even a few I-frames, which would result in a lot of GOPs being corrupted. As a general rule, Mark is right. But even if I succeed in changing the container's headers in a way that the video will play at 96% speed, I am not sure if I want to do it. The reason is simple. If someone later extracts the video out of this container, what would its frame rate be? Depends on the video stream. x264 writes the frame rate into the video streams it creates (this is overridden by the container, however). I don't know if this is common with other encoders. I suppose it will remain unchanged at the "old" value, which means 25 fps. And this is what I want to avoid. I want the fps change to be more robust than that. I don't want the careless container changes to blow the fps change away.
That's why I consider changing PTS (presentation time stamps) of the video frames as suggested by Mark as better, more stable solution. The only problem is I don't know how to do it. (yet) :) It is possible to change such information in a video stream, but I'm not familiar with the tools. There are ways to go from 50i to 24p, but IIRC, it's not usually pretty and it will require decoding. I can't help much with the process, though, since I've never had to do it (almost all the material I work with just need to be deinterlaced, and the little that needs to be converted to 24p is originally 60i).
On Mon, May 23, 2011 at 4:30 PM, Andrew Berg wrote:
That's why I consider changing PTS (presentation time stamps) of the video frames as suggested by Mark as better, more stable solution. The only problem is I don't know how to do it. (yet) :) It is possible to change such information in a video stream, but I'm not familiar with the tools. There are ways to go from 50i to 24p,
It would be pretty sufficient for me to change the video attributes from "25 fps, 50 fields per second, interlaced" to "24 fps, 48 fields per second, still interlaced". I have given up deinterlacing, because I have spotted this sentence in the manual page of ffmpeg: "... but deinterlacing introduces losses." which was enough for me to give it up.
but IIRC, it's not usually pretty and it will require decoding. I can't help much with the process, though, since I've never had to do it (almost all the material I work with just need to be deinterlaced, and the little that needs to be converted to 24p is originally 60i).
So, I will try to summarize and I will welcome any corrections: Deinterlacing: 1) is only possible with reencoding 2) always introduces losses The way to do it with ffmpeg: ffmpeg -i input.file -vcodec <video codec> [video codec options] -deinterlace -an output.file Changing framerate while maintaining the total number of frames: 1) is possible without reencoding 2) is lossless 3) can be done at least in these two fashions: a) by altering the video container flags b) by changing the presentation time stamps (PTS) Now, the only question that remains unanswered is: "Which tools could be used to perform such a frame rate change?" I don't know if the current ffmpeg can do it in any of the described ways. Does anyone know? If it is currently not possible with ffmpeg, I think it would be a feature very well appreciated. Peter Basista
I have given up deinterlacing, because I have spotted this sentence in the manual page of ffmpeg:
"... but deinterlacing introduces losses."
which was enough for me to give it up. Yadif is very good. It's also worth mentioning that deinterlacing is necessary to display interlaced content on a progressive display. Media
On 2011.05.23 12:36 PM, Peter Bašista wrote: players and HDTVs do this during rendering. Technically, deinterlacing filters irreversibly alter the video, but only very poor quality filters hurt quality, so such wording in the man page is misleading. You can search this list (and the MEncoder-users list) for tons of discussion on deinterlacing. In short, it's almost always a good idea to deinterlace with a high-quality filter like Yadif.
So, I will try to summarize and I will welcome any corrections:
Deinterlacing: 1) is only possible with reencoding Video filters require decoding; it is not necessary to reencode the changed video. In most cases, you will want to encode the uncompressed video, but it's an important distinction - filters can be applied losslessly when rendering instead of encoding. 2) always introduces losses High-quality filters introduce very minimal loss.
In any case, be sure to change the frame rate to 24000/1001 fps instead of 24fps. Also, you might need to adjust the samplerate of the audio if the original was adjusted (which I would assume is the case, but I've never been in PAL land). It /might/ be possible to make your audio sync up untouched with container options, but I'm not sure how to go about doing that.
On Mon, May 23, 2011 at 9:18 PM, Andrew Berg wrote:
I have spotted this sentence in the manual page of ffmpeg:
"... but deinterlacing introduces losses."
which was enough for me to give it up. Yadif is very good. It's also worth mentioning that deinterlacing is necessary to display interlaced content on a progressive display. Media players and HDTVs do this during rendering. Technically, deinterlacing filters irreversibly alter the video, but only very poor quality filters hurt quality, so such wording in the man page is misleading. You can search this list (and the MEncoder-users list) for tons of discussion on deinterlacing. In short, it's almost always a good idea to deinterlace with a high-quality filter like Yadif.
All right, I take that into account. But I will seriously consider deinterlacing the video, encoding it and storing it deinterlaced only very occasionally. My primary objective is to avoid reencoding whenever possible. I will rather keep using the deinterlace filters during playback.
So, I will try to summarize and I will welcome any corrections:
Deinterlacing: 1) is only possible with reencoding Video filters require decoding; it is not necessary to reencode the changed video. In most cases, you will want to encode the uncompressed video, but it's an important distinction - filters can be applied losslessly when rendering instead of encoding.
Then let me correct myself: Deinterlace video filters: 1) require video decoding 2) can only be applied to uncompressed video fields / frames This means that unless you want the uncompressed video, you will have to encode it afterwards.
2) always introduces losses High-quality filters introduce very minimal loss.
I'll keep that in mind. Would it be okay to say: Deinterlace video filters: 3) may introduce only a very minimal losses 4) but they are never lossless
In any case, be sure to change the frame rate to 24000/1001 fps instead of 24fps.
Can you explain why? Here: http://avisynth.org/mediawiki/AssumeFPS I have read that according to some standards (NTSC, PAL ... maybe some others), fps is required to be specified as a ratio. But why 24000/1001 and not 24000/1000?
Also, you might need to adjust the samplerate of the audio if the original was adjusted (which I would assume is the case, but I've never been in PAL land). It /might/ be possible to make your audio sync up untouched with container options, but I'm not sure how to go about doing that.
Thank you for reminding me about that. I know there might be issues with V/A sync. But I suppose they can be handled with a little effort. The main problem (change the video frame rate without changing the total number of frames), unfortunately, still remains unsolved. Peter Basista
On 2011.05.23 03:19 PM, Peter Bašista wrote:
My primary objective is to avoid reencoding whenever possible. I will rather keep using the deinterlace filters during playback. That's not a bad idea. Then let me correct myself: Deinterlace video filters: 1) require video decoding 2) can only be applied to uncompressed video fields / frames
This means that unless you want the uncompressed video, you will have to encode it afterwards. Yes. I'll keep that in mind. Would it be okay to say:
Deinterlace video filters: 3) may introduce only a very minimal losses 4) but they are never lossless Yes. I would recommend doing some lossless (or near-lossless - CRF 15 or lower works well if write speed and/or disk space is an issue) encodes with Yadif and comparing it to what you get from your media player's deinterlacer.
In any case, be sure to change the frame rate to 24000/1001 fps instead of 24fps.
Can you explain why? Because usually, film is that rate and not exactly 24fps (just like NTSC is 30000/1001fps and not exactly 30fps). The reason for this is that 24000/1001fps is easier to telecine into the NTSC standard than 24fps.
participants (4)
-
Andrew Berg -
Mark Himsley -
Peter Basista -
Peter Bašista