Hello,
If I have this kind of video:
Can I use ffmpeg to decode it? Do I have to use libavcodec? Or are there any other ways?Code:General Complete name : video.avi Format : AVI Format/Info : Audio Video Interleave File size : 3.62 MiB Duration : 17 s 17 ms Overall bit rate : 1 785 kb/s Video ID : 0 Format : AVC Format/Info : Advanced Video Codec Format profile : Baseline@L3 Format settings, CABAC : No Format settings, RefFrames : 2 frames Format settings, GOP : M=1, N=28 Codec ID : H264 Duration : 17 s 17 ms Bit rate : 1 772 kb/s Width : 704 pixels Height : 480 pixels Display aspect ratio : 3:2 Frame rate : 29.970 (30000/1001) FPS Standard : NTSC Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.175 Stream size : 3.59 MiB (99%)
What if I have a video that was encoded by libx264? Can I decode it using libavcodec as well?
Do I have to convert my video into raw video before decoding it?
Thank you...
+ Reply to Thread
Results 1 to 23 of 23
-
-
ffmpeg can decode it just fine. It doesn't matter which AVC/H.264 encoder created the file, it can decode all of them ((lib)x264 is one of many AVC/H.264 encoders).
I'm not sure what you mean by that. Converting AVC to any other format (including "raw") implies decoding. ffmpeg can convert to other formats with a single command/run. You don't need to run it in two steps.
Now I answered if it can. Yes. Maybe you wanted to ask how to convert to something specific? -
AVC encoding is usually lossy. You cannot recover the original 100% (that would make it lossless). You can convert to the original format (if ffmpeg has encoders/muxers for it) but the quality will not be the same.
-
Ok, now I'm more confused than before I ask this question.
Let me clarify something. I thought that H264, x264, and AVC are all refer to the same thing. Are they not?
FFmpeg has libx264 for encoder. It also has libavcodec with H264 native decoder. So, I should be able to convert to original format. But how do I do that? Do I apply encoding using libx264? Or decode it using H264 native decoder?
I know how to do encoding using libx264. But, wouldn't encoding the video decrease its quality? I mean, isn't it like doing double compression? Please correct me if I'm wrong.
I don't know how to decode using libavcodec though... So, please give some pointer if I have to do this. -
H.264 and AVC are different names for the same thing - a specific video format (specification). x264 is one software implementation that encodes video to a bitstream of said H.264/AVC specification.
Sometimes people use the words meaning the same thing ignoring these differences - either they don't know better or don't care.
Decoding means converting to an uncompressed video stream. Is that the "original format"? I don't know. You haven't told what the video originally was. Maybe it was captured with a camera to VHS? ffmpeg cannot create VHS.
Yes, every time you apply a lossy encoding you have additional loss => quality decreases even further.
ffmpeg chooses the correct decoder automatically.
After reading your posts I only get more confused. What is it that you want to achieve in the end?
Newbies often ask "how do I do X" without telling us what they want to achieve. In the end it turns out they want to "achieve Z" and to do that they should be "doing Y, not X".
So: what is it that you want to have in the end? And why? -
Alright, please forgive me...
Actually, it's a CCTV footage that I download from a website. So, I don't know what's the original format as well. I just assume that the original video is in RGB. I want to observe whether decoding it by H264 will increase the quality or not. I also wonder what would happen if I convert the video into RGB (without decoding) or change it into YUV 4:4:4. Will it increase or decrease the quality. Something like that...
So, what do you think? What should I do? -
h.264 and AVC are the names of the specification for encoding. x264 is a particular encoder that conforms to that spec. That is, x264 is an encoder that produces h.264 video.
h.264/AVC is a lossy compression format. Once you have encoded something to h.264 specs you can never get back the original video from that encoded file, only some that looks like it. How closely it matches depends on how much the video was compressed and what settings were used. That can vary from something that's visually nearly indistinguishable from the original to something that looks almost nothing like the original.
Re-encoding a video always involves first decoding (decompressing) the video to uncompressed frames, then encoding (compressing) those uncompressed frames with the new codec/settings. So any time you re-compress a video with ffmpeg you are decompressing the video first. Unless you specify an external decoder (for example, using an AviSynth script) you will be using ffmpeg's internal h.264 decoder.Last edited by jagabo; 10th Aug 2017 at 16:52.
-
You will not increase quality at all.
If you watch a video it is already being decoded. You are not the guy from "The Matrix" that watches the screen with weird code, right? Every video player decodes. Many even use the ffmpeg decoders.
You are speaking of CCTV footage. So my guess it you have footage of maybe a criminal or a criminal's car and want to "enhance" it so you can make out the face or the number of the car license plate or something like that. ffmpeg won't really help with that (or only very limited).
This is a job for a specialist. You could post the video here but in the past people have done it and no one on this forum was able to help. -
-
So, I tried to apply upsampling from YUV 4:2:0 to 4:4:4 and RGB to a CCTV footage using FFmpeg. I also applied the same thing to belle-nuit test chart.
You're right. I couldn't see any change in the CCTV footage, while from belle-nuit test chart I got something like this:
I don't understand. Why did that happen to the CCTV result? -
Pretty much all digital distribution methods use YUV 4:2:0. So your CCTV video (h.264?) is likely already 4:2:0. The damage has already been done. Upscaling to 4:4:4 just resizes the U and V planes (typically with a bilinear or bicubic filter).
-
-
Converting 4:4:4 to 4:2:0 is a lossy process. You throw away 3/4 of all color information. It's not reversable. How 4:2:0 to 4:4:4 will look depends on the scaling algo (just like upscaling SD to HD .. well, which it basically is). Don't expect any miracles from ffmpeg. Even from the better algos. The reason 4:2:0 is often used is we humans have a hard time noticing it anyways.
But scientists like the ones at Google are working on image recovery with impressive results. Haven't seen anything usable for us low-life endusers yet, though. -
That's true. So, theoretically the scaling algorithm only have 1/4 of the color information. Even with the better algorithm, the scaling result will highly depend on those information.
-
You can play around with different scaling algorithms for the chroma. But with very sharp video you get oversharpening halos if you use sharp resizers like Lanczos, Spline64, even Bicubic. A Point (AKA Nearest Neighbor) resize gets you sharp edges without halos but will generally look bad. An exception will be color charts with only vertical and horizontal edges aligned at even pixel boundaries -- who's chroma was downscaled with a point resize as well.
-
Thanks jagabo. I will try them and report it here.
I can try them using something like this, right?
Code:-vf scale=flags=lanczos
-
You can use scaler flags - example
Code:scale=iw*2:-8:sws_flags=spline+accurate_rnd+full_chroma_int+full_chroma_inp
Similar Threads
-
ffmpeg hardware encoding H264
By marcorocchini in forum Newbie / General discussionsReplies: 53Last Post: 21st Jul 2017, 12:54 -
Creating an easy to decode file with FFMPEG
By przewalski in forum Newbie / General discussionsReplies: 1Last Post: 17th Nov 2015, 08:50 -
Decode h264 stream from WiFi video camera for Android
By windranger in forum Newbie / General discussionsReplies: 4Last Post: 8th Nov 2015, 02:16 -
(FFMPEG) Muxing h264 and aac
By Simon_ in forum Video ConversionReplies: 5Last Post: 7th Sep 2013, 09:24 -
virtualdub can't seem to decode h264 properly
By muffinman123 in forum Video ConversionReplies: 8Last Post: 19th May 2013, 16:29