You are not logged in.

#1 2013-04-19 07:40:10

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Transcoding a video with the same quality

I have several appliances that can read videos (for example a TV from a USB key). They understand some formats (depending on the device). What I would like to do is to find a pogram that transcode a video from any format to a desired format preserving the quality. This is the last thing that pose problem. ffmpeg can transcode videos but by default degrade the quality; there are many options but they are confusing. mencoder has the same unfriendliness. Is there a simple way to autodetect the original quality and to preserve it as far as possible.

Last edited by olive (2013-04-19 07:46:16)

Offline

#2 2013-04-19 08:01:14

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: Transcoding a video with the same quality

The only way to preserve the quality is... to not transcode. *Any* transcoding will degrade quality, it's impossible not to.

Offline

#3 2013-04-19 08:16:08

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Transcoding a video with the same quality

Gusar wrote:

The only way to preserve the quality is... to not transcode. *Any* transcoding will degrade quality, it's impossible not to.

You may be right in theory (for lossy transcoding) but it is definitively possible to preserve the quality as much as possible: to have a video with the same visual quality, something that look the same. The default of ffmpeg degrade the quality a lot.

Offline

#4 2013-04-19 08:37:03

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: Transcoding a video with the same quality

You're contradicting yourself. Something that preserves the quality as much as possible can't also "look the same".

The only way to minimize the degradation is throwing lots of bitrate at the problem, which means creating a transcode that's larger than the video you transcoded from. Unless your source is "high quality" such as DVD/Bluray/DVB recording, in which case simply take that and encode it into the format you need. But I have a feeling you're not talking about that, you're talking about transcoding random videos you downloaded off the net.

Offline

#5 2013-04-19 08:47:59

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Transcoding a video with the same quality

Gusar wrote:

You're contradicting yourself. Something that preserves the quality as much as possible can't also "look the same".

The only way to minimize the degradation is throwing lots of bitrate at the problem, which means creating a transcode that's larger than the video you transcoded from. Unless your source is "high quality" such as DVD/Bluray/DVB recording, in which case simply take that and encode it into the format you need. But I have a feeling you're not talking about that, you're talking about transcoding random videos you downloaded off the net.

Yes that's what I am talking about: random videos downloaded from the net. By looking the same: I mean looking the same while watching it under normal conditions, not by doing a deep analysis. If I do the operation 1000 times, I am aware that the degrading will become noticeable. Preserving the bitrate is a possibility but compression of videos are more subtle and complex than just the bitrate ans depend of the format (there is also the resolution for example). I am sure it is possible by finding the bitrate and several other parameters and to pass a lot of options to mencoder/ffmpeg but I want something automatic without having to look at all these parameters by hand. I want for example to be able to transcode a bunch of random video to mp4 (for example) in a script without having to make a deep study of the videos manually one by one.

Last edited by olive (2013-04-19 08:49:57)

Offline

#6 2013-04-19 08:51:01

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: Transcoding a video with the same quality

You want the holy grail, without lifting a finger to get it. That's not how the world works. Especially not when you're pirating.

Last edited by Gusar (2013-04-19 08:52:31)

Offline

#7 2013-04-19 08:58:41

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Transcoding a video with the same quality

Gusar wrote:

You want the holy grail, without lifting a finger to get it. That's not how the world works. Especially not when you're pirating.

I am not pirating. A lot of videos available from the net are freely available and watchable and are not pirated. You argument is the same as claiming that anyone who download a software from the net is pirating (Hello archlinux users). The only "pirating" I do is to put a freely available youtube video to a USB key to view it with my TV instead of directly watching it in youtube; but that's legal in my country.

Offline

#8 2013-04-19 09:04:03

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: Transcoding a video with the same quality

Yeah, yeah, I know all the arguments smile

And I have a simpler solution for you - if watching youtube videos is really all this is about, hook up a computer to the TV. And voila, no transcoding necessary. The other option is you learn to use an encoder properly. There's plenty of guides for that around. As an Arch user, reading guides and learning shouldn't be an issue.

Offline

#9 2013-04-19 09:13:09

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Transcoding a video with the same quality

olive wrote:

autodetect the original quality and to preserve it

This could only work if the destination format is capable of every algorithm that was used by the source format to encode the source video.

For "autodetect", the problem is that the calculations for e.g. MPEG4 have so many potential twists and turns, and best-fitting of lookup tables, and performing calculations (and going down particular code paths) based on the results of the previous calculations. Unscrambling all that is a nightmare.

Offline

#10 2013-04-19 09:52:26

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Transcoding a video with the same quality

brebs wrote:
olive wrote:

autodetect the original quality and to preserve it

This could only work if the destination format is capable of every algorithm that was used by the source format to encode the source video.

For "autodetect", the problem is that the calculations for e.g. MPEG4 have so many potential twists and turns, and best-fitting of lookup tables, and performing calculations (and going down particular code paths) based on the results of the previous calculations. Unscrambling all that is a nightmare.

I am sure it is possible to have at least a good approximation of my goal whatever the source or destination is. As I have said, I am not looking in rigorously the same quality, just something that give the same feeling. Unscrambling all the options is indeed a nightmare and should be done separately for every videos. I am confident that a program that do what I want is possible (but I am unsure if it exists).

Offline

#11 2013-04-19 10:37:04

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Transcoding a video with the same quality

Of course it's possible, but it seems nobody has written it yet. smile

As you are talking about youtube videos only, my suggestion would be to always download them in the same format, and then put in some time to find the best options for transcoding that particular format to one that works well with your TV.

Offline

#12 2013-04-19 11:09:23

crazyg4merz
Member
Registered: 2013-04-14
Posts: 40

Re: Transcoding a video with the same quality

use

ffmpeg -i <path-to-file>

to find out the video's specs before encoding it.
and then use the closest possible options to encode it. For example the video has a video bitrate of 1000k/s and 196k/s audio bitrate using a x264 and vorbis codecs, then use the -b:v 1000k -c:v libx264 -b:a 196k -c:a libvorbis and use some -crf switch to encode. I can't see any visible quality degrading if I use a default -crf 18. U can always cancel the process and preview it before it finished the encoding and try again with another switches.

Offline

#13 2013-04-19 16:30:32

teckk
Member
Registered: 2013-02-21
Posts: 590

Re: Transcoding a video with the same quality

What I would like to do is to find a pogram that transcode a video from any format to a desired format preserving the quality.

Are you wanting to change containers without any loss?

ffmpeg -i file.flv -c:a copy -c:v copy file.mp4
mencoder file.flv -aoc copy -ovc copy -o file.mp4

You can dump the audio to pcm, the re-encode it however you want. If it's already a lossy format like mp3, then going to another lossy format will loose some quality. if you don't want to loose quality then copy it.

mplayer file.flv -vc dummy -vo null -ao pcm:file=audio.wav

Same with the video, copy it if you don't want any quality loss. A dvd with mpeg video at 7000kbs can be reduced to x264 at 2500kbps with out any visual quality loss. The videos will be less than half the size of the .vob.

The default of ffmpeg degrade the quality a lot.

Only if you tell it to. -b:v or -b:a can be whatever you want.

Offline

#14 2013-04-20 11:05:06

crazyg4merz
Member
Registered: 2013-04-14
Posts: 40

Re: Transcoding a video with the same quality

teckk wrote:

What I would like to do is to find a pogram that transcode a video from any format to a desired format preserving the quality.

Are you wanting to change containers without any loss?

ffmpeg -i file.flv -c:a copy -c:v copy file.mp4
mencoder file.flv -aoc copy -ovc copy -o file.mp4

You can dump the audio to pcm, the re-encode it however you want. If it's already a lossy format like mp3, then going to another lossy format will loose some quality. if you don't want to loose quality then copy it.

mplayer file.flv -vc dummy -vo null -ao pcm:file=audio.wav

Same with the video, copy it if you don't want any quality loss. A dvd with mpeg video at 7000kbs can be reduced to x264 at 2500kbps with out any visual quality loss. The videos will be less than half the size of the .vob.

The default of ffmpeg degrade the quality a lot.

Only if you tell it to. -b:v or -b:a can be whatever you want.

Doing copy to both audio and video means u don't do anything to it. The file will stay the same and u might as well don't do anything to it. But the author didn't mention the purpose of decoding the video if he doesn't want any loss in quality, so maybe u re right about he only want to change the container of the file. :-)

Offline

#15 2013-05-03 19:10:21

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: Transcoding a video with the same quality

olive wrote:

Is there a simple way to autodetect the original quality and to preserve it as far as possible.

See the FFmpeg and x264 Encoding Guide and the FFmpeg and AAC Encoding Guide if you decide you must re-encode both video and audio.

As for the video, if using (lib)x264, use the -crf option. General usage is to choose the highest value that still gives an acceptable quality. See the link above for examples and more details.

Offline

#16 2013-05-03 19:14:08

DrZaius
Member
Registered: 2008-01-02
Posts: 193

Re: Transcoding a video with the same quality

crazyg4merz wrote:

use

ffmpeg -i <path-to-file>

to find out the video's specs before encoding it.
and then use the closest possible options to encode it. For example the video has a video bitrate of 1000k/s and 196k/s audio bitrate using a x264 and vorbis codecs, then use the -b:v 1000k -c:v libx264 -b:a 196k -c:a libvorbis and use some -crf switch to encode.

This is not a recommended procedure.

  • Not all encoders are equal in terms of required bitrate for a given quality.

  • How do you know whoever made the video knew what they were doing?

  • -b:v and -crf are mutually exclusive.

Offline

Board footer

Powered by FluxBB