Opened 12 years ago

Closed 12 years ago

#2046 closed enhancement (fixed)

support changes to DAR/SAR during -codec copy

Reported by: dave rice Owned by:
Priority: wish Component: ffmpeg
Version: git-master Keywords: aspect
Cc: Alex-Frst Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I would like to make adjustments to DAR without having to re-encode video. FFmpeg ignores options like -aspect and -vf setdar when using -c copy.

How to reproduce:

I create a sample file like this:
ffmpeg -f lavfi -i testsrc=s=720x480:d=1 -pix_fmt yuv420p 720x480_3-2.mov

I then try to adjust the DAR of file 720x480_3-2.mov to 4/3. like this

ffmpeg -i 720x480_3-2.mov -aspect 4/3 -c copy 720x480_4-3.mov
ffmpeg version 1.0.git-ffmpeg4archivists Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 29 2012 11:38:09 with gcc 4.2.1 (GCC) (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/Users/digitilization/github/ffmpeg4archivists/ffmpeg --as=yasm --extra-version=ffmpeg4archivists --extra-libs=-L/Users/digitilization/github/ffmpeg4archivists/libs --disable-shared --enable-static --disable-ffserver --enable-gpl --enable-pthreads --enable-postproc --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libspeex --enable-bzlib --enable-zlib --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libvo-aacenc --enable-libvpx --enable-libopus --enable-filters --enable-runtime-cpudetect --disable-debug --enable-libfreetype --enable-libopenjpeg --cc=/usr/bin/gcc-4.2
  libavutil      52.  9.102 / 52.  9.102
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 39.100 / 54. 39.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.104 /  3. 23.104
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '720x480_3-2.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf54.39.100
  Duration: 00:00:01.00, start: 0.000000, bitrate: 108 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 1:1 DAR 3:2], 99 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
    Metadata:
      handler_name    : DataHandler
Output #0, mov, to '720x480_4-3.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf54.39.100
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 720x480 [SAR 1:1 DAR 3:2], q=2-31, 99 kb/s, 25 fps, 12800 tbn, 12800 tbc
    Metadata:
      handler_name    : DataHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=   25 fps=0.0 q=-1.0 Lsize=      13kB time=00:00:00.88 bitrate= 123.6kbits/s    
video:12kB audio:0kB subtitle:0 global headers:0kB muxing overhead 8.819528%

And the output is still 3/2 DAR. The result is the same with -vf options. I was able to make this adjustment using muxmovie's -hscale option but would like to be able to do this in ffmpeg.

Change History (7)

comment:1 by Peter B., 12 years ago

I also would have needed this functionality several times already with external video material to be archived.

comment:2 by Elon Musk, 12 years ago

hmm there are two distinct cases:

  1. sar/dar is stored in container - afaik this should work
  2. sar/dar is stored in bistream - reencode is needed - though one could need to just replace few bits...

comment:3 by Alex-Frst, 12 years ago

http://forum.doom9.org/showthread.php?t=152419

cmdline:
ffmpeg -i infile -vcodec copy -acodec copy -vbsf h264_changesps=arg1arg2[/arg3] outfile

args can be:
sar=x:y ---- Set sar to x:y, 0:0 will remove sar info

Patches can be found on https://direct264.svn.sourceforge.net/svnroot/direct264/Patches

comment:4 by Carl Eugen Hoyos, 12 years ago

Cc: Alex-Frst added

Please post patches (against current git head) on ffmpeg-devel where they can be reviewed.

in reply to:  2 comment:5 by Carl Eugen Hoyos, 12 years ago

Keywords: aspect added; dar removed
Priority: normalwish

Replying to richardpl:

  1. sar/dar is stored in container - afaik this should work

How is this (changing SAR and/or DAR with -codec copy) supposed to work?

in reply to:  4 comment:6 by Alex-Frst, 12 years ago

Replying to cehoyos:

Please post patches (against current git head) on ffmpeg-devel where they can be reviewed.

The patch is not mine. I just share link for possible solution.

comment:7 by Carl Eugen Hoyos, 12 years ago

Component: undeterminedFFmpeg
Resolution: fixed
Status: newclosed

The original request was implemented by Nicolas George in b1cc12d

The direct264 patchset looks very interesting nonetheless.

Note: See TracTickets for help on using tickets.