Transcode to change aspect ratio from 4:3 to 16:9

About encoding, codec settings, muxers and filter usage
tenbob
Blank Cone
Blank Cone
Posts: 11
Joined: 03 May 2010 00:43

Transcode to change aspect ratio from 4:3 to 16:9

Postby tenbob » 03 Aug 2013 00:07

Hi. Can anyone help me with this aspect ratio conversion problem? I have a recording which is in the wrong aspect ratio. It's 720x576 and should be displayed in widescreen 16:9. Due to some mix-up at the encoding stage it is wrongly identified as 4:3. So when I play it in VLC it appears squashed by default. In the player I can manually change the aspect ratio to 16:9 and everything looks fine.

But I need to fix the source file permanently. In theory it should be possible to do it without transcoding. All the bits in the picture can stay exactly as they are. I assume it's just some labelling in the headers that needs to change so the picture is displayed correctly. I tried various ways to do this and failed completely.

So now I'm resigned to transcoding the entire video stream. But I still can't find a way to do it in VLC. I tried using a command like this.

Code: Select all

vlc myfile.mpg --aspect-ratio="16:9" :sout=#transcode{vcodec=mp2v,vb=4096,fps=25,height=576,width=720}:file{mux=ps,dst=vid020.mpg}
It looks like the --aspect-ratio option is being ignored. Maybe this only applies to the on-screen player. Is there Is there a way to do this conversion with VLC?

Chadnaut
New Cone
New Cone
Posts: 5
Joined: 20 Sep 2013 11:37

Stretch aspect ratio from 4:3 to 16:9

Postby Chadnaut » 20 Sep 2013 15:59

I have the same problem, a video that's 720x480 buts wants to play at 4:3.
The windows player can force it to 16:9, but streaming it at that (to appleTV) is strangely difficult.
After some quick experiments, here's one roundabout way of fixing it (works in vlc 2.0.7):

Use your own video's width and height as-is, then play around with the aspect value to stretch it. 16:14 worked for my video, which made the picture 16:9 but with black bars above and below.

Code: Select all

vlc -vvv "movie.mpg" --sout=#transcode{vcodec=mp2v,vb=4096,vfilter=canvas{width=720,height=480,aspect=16:14}}:file{mux=ps,dst="stretch.mpg"} vlc://quit
Now you'll want to crop those black bars. 58 lines off the top and bottom worked for me.

Code: Select all

vlc -vvv "stretch.mpg" --sout=#transcode{vcodec=mp2v,vb=4096,vfilter=croppadd{croptop=58,cropbottom=58}}:file{mux=ps,dst="cropped.mpg"} vlc://quit
Throw both those lines into a batch file, and REM out the second one so you can work on getting the aspect right first.
Transcode 30 seconds or so then close VLC to cancel it.
Check your output videos to see how close your stretching is, the un-rem and start cropping.

Now maybe someone can enlighten us on how to call two vfilters in one transcode...

Chadnaut
New Cone
New Cone
Posts: 5
Joined: 20 Sep 2013 11:37

Re: Transcode to change aspect ratio from 4:3 to 16:9

Postby Chadnaut » 22 Sep 2013 10:00

Since this basically transcodes the video to mp2v twice, it'll look like crap.
Might try using h264 instead... actually scratch that, I tested h264 and it wont stretch?

tenbob
Blank Cone
Blank Cone
Posts: 11
Joined: 03 May 2010 00:43

Re: Transcode to change aspect ratio from 4:3 to 16:9

Postby tenbob » 03 Apr 2014 19:24

Six months later and I have now found a way to correct the aspect ratio without transcoding and losing quality. Apparently it can't be done in VLC. But the program MP4Box does it perfectly.

MP4Box is a command line tool specifically for packaging and unpackaging container formats. That's all it does - it doesn't do any coding, etc. It won't accept FLV files, so I used VLC to convert them to MP4 first. This conversion only changed the container, keeping the internal streams the same.

My video was 640x480px and displayed wrongly in a 4:3 box when it should have been 16:9. So it was using square pixels when it should have used elongated ones. The shape of the new pixels should be 4:3 instead of the original 1:1. The video is in stream 2. So the MP4Box command looks like this ...

Code: Select all

mp4box file1.mp4 -out file2.mp4 -par 2=4:3
It worked like a charm.

Fymyte
New Cone
New Cone
Posts: 1
Joined: 13 Oct 2022 22:48

Re: Transcode to change aspect ratio from 4:3 to 16:9

Postby Fymyte » 13 Oct 2022 22:52

I know it was asked with mp4 container in mind, but I had the same issue with an mkv file. I managed to fix it using MKVToolNix.

In the GUI, add your mkv file to the "Source files", in the the box bellow "Tracks, chapters and tags", select your video stream.
In the right pan "Properties", go down to "Video properties" and "Set aspect ratio" to the one need"

Worked for me


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 6 guests