Opened 4 years ago

Last modified 4 years ago

#3999 open defect

Input option -r does not work for all formats without reencoding

Reported by: Ilya87 Owned by:
Priority: normal Component: ffmpeg
Version: git-master Keywords: fps
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

according to https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
% ffmpeg -i input.mp4 -filter:v "setpts=2.0*PTS" -c copy output.mp4

Filtergraph 'setpts=2.0*PTS' was defined for video output stream 0:0 but codec copy was selected.                                                         
Filtering and streamcopy cannot be used together.

I couldn't make the -r option change situation.

But as I can understand video duration can be increased without reencoding. And this is done in mkvmerge's stretch option: "Stretch this track's timecodes. This entry can have two formats. It is either a positive floating point number, or a fraction like e.g. 1200/1253. Works best on video and subtitle tracks."
Mkvmerge just changes fps and duration accordingly. In this situation I think ffmpeg should check that only setpts filter is set and process video without encoding. 
Or there might be another way to do the same thing mkvmerge does?

ffmpeg version 2.4.1
built on Sep 22 2014 05:50:26 with gcc 4.9.1 (GCC) 20140903 (prerelease)

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

122_cut.mkv (2.3 MB) - added by cehoyos 4 years ago.

Change History (7)

comment:1 Changed 4 years ago by cehoyos

Unfortunately, this has currently no similarity with a valid ticket.

The wiki page does not mention that setpts may work without reencoding and in fact, it cannot work (and it cannot be made working).
The input option -r allows to do what you want, but it does not always work.

Please test current FFmpeg git head and if it allows to reproduce the issue provide a short input file that you want to slow down and the command line with -r that does not work together with the complete, uncut console output.

comment:2 Changed 4 years ago by Ilya87

https://yadi.sk/i/b2o6CYnmbny9q - original file
ffmpeg -i 122.mkv
ffmpeg version N-66581-g105654e Copyright (c) 2000-2014 the FFmpeg developers

built on Oct 3 2014 12:40:48 with clang version 3.5.0 (branches/release_35) (llvm/branches/release_35 218565)
configuration: --prefix=/usr --enable-libvpx --cc=clang --cxx=clang++ --enable-libopus --enable-vdpau --enable-libx265 --enable-vaapi --disable-indev=jack --disable-outdev=oss --disable-indev=oss --enable-libopenjpeg --enable-gpl --enable-version3 --enable-libxvid --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-libtheora --enable-postproc --enable-libvorbis --enable-shared --enable-gray --disable-static --enable-pthreads --enable-libass --enable-libfreetype --enable-x11grab --extra-cflags='-march=native -O3 -mfpmath=sse -pipe -fstack-protector --param=ssp-buffer-size=4' --disable-debug
libavutil 54. 9.100 / 54. 9.100
libavcodec 56. 2.101 / 56. 2.101
libavformat 56. 7.102 / 56. 7.102
libavdevice 56. 1.100 / 56. 1.100
libavfilter 5. 1.102 / 5. 1.102
libswscale 3. 1.100 / 3. 1.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 1.100 / 53. 1.100

Input #0, matroska,webm, from '122.mkv':

Metadata:

encoder : libebml v1.3.0 + libmatroska v1.4.1
creation_time : 2014-10-03 08:37:49

Duration: 00:00:12.10, start: 0.120000, bitrate: 4038 kb/s

Stream #0:0: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 9800 kb/s, 50 fps, 50 tbr, 1k tbn, 50 tbc (default)
Metadata:

BPS : 4032408
BPS-eng : 4032408
DURATION : 00:00:12.100000000
DURATION-eng : 00:00:12.100000000
NUMBER_OF_FRAMES: 303
NUMBER_OF_FRAMES-eng: 303
NUMBER_OF_BYTES : 6099018
NUMBER_OF_BYTES-eng: 6099018
_STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
_STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
_STATISTICS_WRITING_DATE_UTC: 2014-10-03 08:37:49
_STATISTICS_WRITING_DATE_UTC-eng: 2014-10-03 08:37:49
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

Command line: ffmpeg -r 10 -i 122.mkv -c copy 123.mkv
After this ffplay shows 10 fps in terminal (50 fps in input file is also wrong info - 25 fps is right), but decodes at 25 fps speed as original.

comment:3 Changed 4 years ago by cehoyos

Do I understand correctly that it is not possible to provide the command line that does not produce the expected output together with the complete, uncut console output?

comment:4 Changed 4 years ago by Ilya87

Do you mean when changing fps using ffmpeg?

ffmpeg -r 10 -i 122.mkv -c copy 123.mkv
ffmpeg version N-66581-g105654e Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct  3 2014 12:40:48 with clang version 3.5.0 (branches/release_35) (llvm/branches/release_35 218565)
  configuration: --prefix=/usr --enable-libvpx --cc=clang --cxx=clang++ --enable-libopus --enable-vdpau --enable-libx265 --enable-vaapi --disable-indev=jack --disable-outdev=oss --disable-indev=oss --enable-libopenjpeg --enable-gpl --enable-version3 --enable-libxvid --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-libtheora --enable-postproc --enable-libvorbis --enable-shared --enable-gray --disable-static --enable-pthreads --enable-libass --enable-libfreetype --enable-x11grab --extra-cflags='-march=native -O3 -mfpmath=sse -pipe -fstack-protector --param=ssp-buffer-size=4' --disable-debug
  libavutil      54.  9.100 / 54.  9.100
  libavcodec     56.  2.101 / 56.  2.101
  libavformat    56.  7.102 / 56.  7.102
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.102 /  5.  1.102
  libswscale      3.  1.100 /  3.  1.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  1.100 / 53.  1.100
Input #0, matroska,webm, from '122.mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.1
    creation_time   : 2014-10-03 08:37:49
  Duration: 00:00:12.10, start: 0.120000, bitrate: 4038 kb/s
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 9800 kb/s, 50 fps, 50 tbr, 1k tbn, 50 tbc (default)
    Metadata:
      BPS             : 4032408
      BPS-eng         : 4032408
      DURATION        : 00:00:12.100000000
      DURATION-eng    : 00:00:12.100000000
      NUMBER_OF_FRAMES: 303
      NUMBER_OF_FRAMES-eng: 303
      NUMBER_OF_BYTES : 6099018
      NUMBER_OF_BYTES-eng: 6099018
      _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
      _STATISTICS_WRITING_DATE_UTC: 2014-10-03 08:37:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2014-10-03 08:37:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Output #0, matroska, to '123.mkv':
  Metadata:
    encoder         : Lavf56.7.102
    Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=2-31, max. 9800 kb/s, 50 fps, 1k tbn, 10 tbc (default)
    Metadata:
      BPS             : 4032408
      BPS-eng         : 4032408
      DURATION        : 00:00:12.100000000
      DURATION-eng    : 00:00:12.100000000
      NUMBER_OF_FRAMES: 303
      NUMBER_OF_FRAMES-eng: 303
      NUMBER_OF_BYTES : 6099018
      NUMBER_OF_BYTES-eng: 6099018
      _STATISTICS_WRITING_APP: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
      _STATISTICS_WRITING_APP-eng: mkvmerge v7.2.0 ('On Every Street') 64bit built on Sep 21 2014 04:29:13
      _STATISTICS_WRITING_DATE_UTC: 2014-10-03 08:37:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2014-10-03 08:37:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  303 fps=0.0 q=-1.0 Lsize=    5961kB time=00:00:12.06 bitrate=4048.9kbits/s    
video:5956kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.076176%
Last edited 4 years ago by cehoyos (previous) (diff)

comment:5 Changed 4 years ago by Ilya87

As I see ffmpeg shows output 50 fps while ffplay shows 10 fps in terminal for 123.mkv

comment:6 Changed 4 years ago by cehoyos

  • Keywords fps added; Stretching removed
  • Reproduced by developer set
  • Status changed from new to open
  • Summary changed from Stretching (increasing duration) of video without reencoding to Input option -r does not work for all formats without reencoding
  • Version changed from 2.4.1 to git-master

One workaround is to use the following commands:

$ ffmpeg -r 10 -i 122.mkv -vcodec copy out.avi
$ ffmpeg -fflags +genpts -i out.avi -vcodec copy out.mkv

Changed 4 years ago by cehoyos

Note: See TracTickets for help on using tickets.