Cut a video with Handbrake's "strict anamorphic" settings

Started by p.f.moore, April 22, 2013, 10:35:21 PM

Previous topic - Next topic

p.f.moore

I would like to cut a short section out of a video which I converted using Handbrake, which makes use of Handbrake's "strict anamorphic" settings. I do *not* want to re-encode the video (mainly to avoid a lengthy and unneeded encoding step).

If I try to do the cut using audio and video "Copy" mode, the resulting video seems to lose the anamorphic settings - looking in "G-Spot" for instance, shows the original with storage aspect ratio 5:4 and display aspect ration 16:9, and recommended display size 1024x576. But the clipped version shows both display and storage aspect ratio as 5:4 and the recommended display size as 720x576. In practice, both of my test case videos seemed to play OK in VLC, but I have certainly had problems in the past on some devices, although I can't recall exactly where to provide specific instructions on how to reproduce the problem visually (the output of G-Spot is easy to check, though).

What can I do to simply cut the video, without altering any of the encoding properties or metadata?

Thanks,
Paul

Jan Gruuthuse

#1
When using video/audio copy there are some settings in avidemux 2.6.3 in Output Format [Configure] when MKV Muxer is selected:
[ ] Force display width and Display width. Use a 5 seconds clip to test it out ;)
I believe it is:
[v] Force display width
Display width: 1024
I could still be wrong?

p.f.moore

Thanks, but that's not quite what I want. I don't want to use the MKV container - I'm using MP4 and I really just want to copy the container format from the input, as with the video and audio streams. In particular, I do not want to set a fixed display size on the output. I want the display size to be copied precisely from the input.

Maybe I'm missing something fundamental here. It seems to me that most tools for video encoding don't take the approach that I would expect, which is "copy everything unchanged except for places where the user explicitly requests a change". Avidemux is by far the best I've found in this regard, except in terms of the container format/information, which is why I'm finding this issue so frustrating  :(

Paul

Jan Gruuthuse

Gspot is a little dated: (February 23, 2007), was one of my favorites then in those  [|]  days, mediainfo is up to date.
If devices is more like flatscreen TV's then this is most likely related to European video SD 576i 16/9 and 4/3 where 16/9 footage is shown in 4:3. That is a container (box where the encoded video and encode audio track(s) goes into)  issue.
Avidemux is not touching the encoded video/encode audio with copy video/audio.
Only when re-encoding you change properties of video:
QuoteTV program 576i is either [ ] 4:3 or [   ] 16:9 (wide screen). If you re-encode 576i 16:9 and you resize in Video filter with these settings  1024 x 576 The video now will show 16:9 on vlc or or on flatscreen tv's. Can't explain it other way.

styrol

QuoteAvidemux is not touching the encoded video/encode audio with copy video/audio.
Only when re-encoding you change properties of video:
Well, it does not touch the audio and video streams but it may touch the header by changing some properties (e.g. DAR). And ignoring / not writing some info in the header anymore is changing some properties indeed.

Jan Gruuthuse

#5
I can't confirm avidemux 2.63. video/audio copy from handbrake 1024x576 encoded video aspect ratio issue?
Source video 1024x576 from handbrake, avidemux copies with mp4 muxer and mp4v2 muxer: rapidshare download 58 MB
Source and target mp4 play the same on flat screen internal media player.

styrol

Quote from: styrol(e.g. DAR)
I did not test the handbrake anamorphic output issue. But I have many MP4 videos edited with avidemux in copy mode having lost the correct DAR. And I use another software to correct the values. So certainly some properties must have changed.

Jan Gruuthuse

SAR DAR PAR info once you start mixing up these ....
If you encoded 720 x 576 widescreen into 1024 x 576to show always widescreen: Aspect Ratios for Broadcast
QuoteThe reason for this discrepancy is that digital video does not use square pixels.
When we described an image of 4 x 3 pixels, we naturally assumed that the pixels were tiny squares, whereas in the digital video world, they are not.
if encoded video pixel resolution @ 1024 x 576 (always 16:9)
if encoded video pixel resolution @  720 x 576 and SAR/DAR was changed to reflect 16:9 then your in trouble as not all embedded players read these, hence the problem. Samsung flatscreens and others

p.f.moore

For what it's worth, it seems that you can put the original metadata back using ffmpeg.

ffmpeg -i original.mp4 -i output_from_avidemux.mp4 -map 1 -map_metadata 0 -c copy corrected_output.mp4

Feels like a bit of a hack, but it seems to work...
Paul

styrol

Quote from: p.f.mooreFor what it's worth, it seems that you can put the original metadata back using ffmpeg.
That's what Avidemux does not.
Quote from: Jan GruuthuseSAR DAR PAR info once you start mixing up these ....
I know what those terms mean.

Jan Gruuthuse

#10
I doubt transferring metadata is adjusting PAR/DAR/SAR information in mp4 container.
FFmpeg Metadata
ffprobe should tell what is going on, be aware to use recent versions of ffmpeg as they had versions preferring SAR over PAR.
ffprobe --help should tell if to use:
ffprobe -i ~/Videos/avidemux1024x567mp4.mp4
below Libav developers ffprobe
ffprobe -show_format ~/Videos/Handbrake1024x576.m4v
Quoteavprobe version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2007-2013 the Libav developers
  built on Apr  2 2013 17:02:36 with gcc 4.6.3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/jan/Videos/Handbrake1024x576.m4v':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2013-04-24 07:15:24
    title           : 720ptest
    encoder         : HandBrake rev0 2013042399
  Duration: 00:01:30.84, start: 0.000000, bitrate: 4968 kb/s
    Stream #0.0(und): Video: h264 (Main), yuv420p, 1024x576 [PAR 1:1 DAR 16:9], 4801 kb/s, 50 fps, 50 tbr, 90k tbn, 100 tbc
    Metadata:
      creation_time   : 2013-04-24 07:15:24
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 159 kb/s
    Metadata:
      creation_time   : 2013-04-24 07:15:24
[FORMAT]
filename=/home/jan/Videos/Handbrake1024x576.m4v
nb_streams=2
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime/MPEG-4/Motion JPEG 2000 format
start_time=0.000000
duration=90.840000
size=56417701.000000
bit_rate=4968533.000000
TAG:major_brand=mp42
TAG:minor_version=0
TAG:compatible_brands=mp42isomavc1
TAG:creation_time=2013-04-24 07:15:24
TAG:title=720ptest
TAG:encoder=HandBrake rev0 2013042399
[/FORMAT]

ffprobe -show_format ~/Videos/avidemux1024x567mp4.mp4
Quoteavprobe version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2007-2013 the Libav developers
  built on Apr  2 2013 17:02:36 with gcc 4.6.3
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1d7e7a0] multiple edit list entries, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1d7e7a0] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/jan/Videos/avidemux1024x567mp4.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.59.106
  Duration: 00:00:08.39, start: 0.002000, bitrate: 4521 kb/s
    Stream #0.0(und): Video: h264 (Main), yuv420p, 1024x576 [PAR 1:1 DAR 16:9], 4389 kb/s, 50 fps, 50 tbr, 50k tbn, 100 tbc
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 159 kb/s
[FORMAT]
filename=/home/jan/Videos/avidemux1024x567mp4.mp4
nb_streams=2
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime/MPEG-4/Motion JPEG 2000 format
start_time=0.002000
duration=8.398000
size=4746355.000000
bit_rate=4521414.000000
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf54.59.106
[/FORMAT]

ffprobe -show_format ~/Videos/corrected_output.mp4
Quoteavprobe version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2007-2013 the Libav developers
  built on Apr  2 2013 17:02:36 with gcc 4.6.3
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x6f07a0] multiple edit list entries, a/v desync might occur, patch welcome
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/jan/Videos/corrected_output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2013-04-24 07:15:24
    title           : 720ptest
    encoder         : Lavf53.21.1
  Duration: 00:00:08.43, start: 0.000000, bitrate: 4499 kb/s
    Stream #0.0(und): Video: h264 (Main), yuv420p, 1024x576 [PAR 1:1 DAR 16:9], 4389 kb/s, 50 fps, 50 tbr, 50k tbn, 100 tbc
    Metadata:
      creation_time   : 2013-04-24 07:15:24
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 159 kb/s
    Metadata:
      creation_time   : 2013-04-24 07:15:24
[FORMAT]
filename=/home/jan/Videos/corrected_output.mp4
nb_streams=2
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime/MPEG-4/Motion JPEG 2000 format
start_time=0.000000
duration=8.438000
size=4745853.000000
bit_rate=4499505.000000
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:creation_time=2013-04-24 07:15:24
TAG:title=720ptest
TAG:encoder=Lavf53.21.1
[/FORMAT]

Jan Gruuthuse

#11
while we are at it digging deep, those of you work with photography, you are mostly familiar with exif format and tools.
This one does read videofiles to: ExifTool by Phil Harvey Read, Write and Edit Meta Information! available for Mac OS X, windows, Unix systems.
exiftool -u /home/jan/Videos/Handbrake1024x576.m4v
ExifTool Version Number         : 9.28
File Name                       : Handbrake1024x576.m4v
Directory                       : /home/jan/Videos
File Size                       : 54 MB
File Modification Date/Time     : 2013:04:24 09:15:51+02:00
File Access Date/Time           : 2013:04:24 12:32:12+02:00
File Inode Change Date/Time     : 2013:04:24 12:32:12+02:00
File Permissions                : rw-rw-r--
File Type                       : MP4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.0
Compatible Brands               : mp42, isom, avc1
Movie Data Size                 : 56331767
Movie Header Version            : 0
Create Date                     : 2013:04:24 07:15:24
Modify Date                     : 2013:04:24 07:15:51
Time Scale                      : 90000
Duration                        : 0:01:30
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Initial Object Descriptor       : (Binary data 16 bytes, use -b option to extract)
Track Header Version            : 0
Track Create Date               : 2013:04:24 07:15:24
Track Modify Date               : 2013:04:24 07:15:51
Track ID                        : 1
Track Duration                  : 0:01:30
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1024
Image Height                    : 576
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 1024
Source Image Height             : 576
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : JVT/AVC Coding
Bit Depth                       : 24
Video Frame Rate                : 50
Composition Time To Sample      : (Binary data 35640 bytes, use -b option to extract)
Sync Sample Table               : (Binary data 104 bytes, use -b option to extract)
Idependent And Disposable Samples: (Binary data 4546 bytes, use -b option to extract)
Unknown edts                    : (Binary data 28 bytes, use -b option to extract)
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2013:04:24 07:15:24
Media Modify Date               : 2013:04:24 07:15:51
Media Time Scale                : 48000
Media Duration                  : 0:01:30
Media Language Code             : und
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 2
Audio Bits Per Sample           : 16
Audio Sample Rate               : 48000
Time To Sample Table            : (Binary data 16 bytes, use -b option to extract)
Sample Sizes                    : (Binary data 17044 bytes, use -b option to extract)
Sample To Chunk                 : (Binary data 32 bytes, use -b option to extract)
Chunk Offset                    : (Binary data 4268 bytes, use -b option to extract)
Track 2 Name                    : Stereo
Handler Type                    : Metadata
Title                           : 720ptest
Encoder                         : HandBrake rev0 2013042399
Free                            : (Binary data 124 bytes, use -b option to extract)
Avg Bitrate                     : 4.96 Mbps
Image Size                      : 1024x576
Rotation                        : 0