Opened 5 years ago

Closed 2 years ago

Last modified 2 years ago

#7911 closed defect (invalid)

Try to change the speed of a video without transcoding

Reported by: François Lafont Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hi,

Warning, I'm a noob in videos, ffmpeg etc. I want to change the speed of a video and keep the same quality (just change the speed when the video is read by a player. NB: I don't care about the sound here). After some helps in a forum, here what I have tryied on my Ubuntu 18.04:

cd /tmp
git clone https://github.com/FFmpeg/FFmpeg.git && cd FFmpeg

mkdir /tmp/ffmpeg # the prefix
./configure --prefix=/tmp/ffmpeg --disable-x86asm && make && make install

cd /tmp/ffmpeg
mv ~/myvideo.mp4 .



$ ./bin/ffmpeg -report -r 10 -i myvideo.mp4 -an -c copy myvideo-slow.mp4
ffmpeg started on 2019-05-19 at 16:38:21
Report written to "ffmpeg-20190519-163821.log"
ffmpeg version N-93886-gfbdb3aa179 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04)
  configuration: --prefix=/tmp/ffmpeg --disable-x86asm
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 52.101 / 58. 52.101
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 53.101 /  7. 53.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myvideo.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2019-05-19T14:25:04.000000Z
    location        : +48.7278+002.2696/
    location-eng    : +48.7278+002.2696/
    com.android.version: 9
    com.android.capture.fps: 240.000000
  Duration: 00:00:03.59, start: 0.000000, bitrate: 72359 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/smpte170m), 1920x1080, 72552 kb/s, SAR 1:1 DAR 16:9, 239.64 fps, 240 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : SoundHandle
Output #0, mp4, to 'myvideo-slow.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    com.android.capture.fps: 240.000000
    location        : +48.7278+002.2696/
    location-eng    : +48.7278+002.2696/
    com.android.version: 9
    encoder         : Lavf58.27.103
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 72552 kb/s, 239.64 fps, 240 tbr, 10240 tbn, 10 tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  854 fps=0.0 q=-1.0 Lsize=   31571kB time=00:00:03.55 bitrate=72657.5kbits/s speed= 193x    
video:31561kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.030221%



$ cat ffmpeg-20190519-163821.log 
ffmpeg started on 2019-05-19 at 16:38:21
Report written to "ffmpeg-20190519-163821.log"
Command line:
./bin/ffmpeg -report -r 10 -i myvideo.mp4 -an -c copy myvideo-slow.mp4
ffmpeg version N-93886-gfbdb3aa179 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04)
  configuration: --prefix=/tmp/ffmpeg --disable-x86asm
  libavutil      56. 28.100 / 56. 28.100
  libavcodec     58. 52.101 / 58. 52.101
  libavformat    58. 27.103 / 58. 27.103
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 53.101 /  7. 53.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '10'.
Reading option '-i' ... matched as input url with argument 'myvideo.mp4'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option 'myvideo-slow.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url myvideo.mp4.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 10.
Successfully parsed a group of options.
Opening an input file: myvideo.mp4.
[NULL @ 0x55f03efa4ac0] Opening 'myvideo.mp4' for reading
[file @ 0x55f03efa6e00] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] ISO: File Type Major Brand: mp42
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] rfps: 240.000000 0.000580
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] rfps: 240.000000 0.018833
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] Before avformat_find_stream_info() pos: 32444092 bytes read:43140 seeks:1 nb_streams:2
[h264 @ 0x55f03efa8840] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55f03efa8840] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 3
[h264 @ 0x55f03efa8840] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (34 bits)
[h264 @ 0x55f03efa8840] Format yuv420p chosen by get_format().
[h264 @ 0x55f03efa8840] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (31 bits)
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (34 bits)
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (31 bits)
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (34 bits)
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (31 bits)
[h264 @ 0x55f03efa8840] nal_unit_type: 14(Prefix), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 1
[h264 @ 0x55f03efa8840] Unknown NAL code: 14 (34 bits)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] Probe buffer size limit of 5000000 bytes reached
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f03efa4ac0] After avformat_find_stream_info() pos: 5025103 bytes read:5099880 seeks:2 frames:128
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'myvideo.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2019-05-19T14:25:04.000000Z
    location        : +48.7278+002.2696/
    location-eng    : +48.7278+002.2696/
    com.android.version: 9
    com.android.capture.fps: 240.000000
  Duration: 00:00:03.59, start: 0.000000, bitrate: 72359 kb/s
    Stream #0:0(eng), 128, 1/90000: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/smpte170m), 1920x1080, 72552 kb/s, SAR 1:1 DAR 16:9, 239.64 fps, 240 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
    Stream #0:1(eng), 0, 1/48000: Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    Metadata:
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : SoundHandle
Successfully opened the file.
Parsing a group of options: output url myvideo-slow.mp4.
Applying option an (disable audio) with argument 1.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: myvideo-slow.mp4.
[file @ 0x55f03efea400] Setting default whitelist 'file,crypto'
Successfully opened the file.
Output #0, mp4, to 'myvideo-slow.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    com.android.capture.fps: 240.000000
    location        : +48.7278+002.2696/
    location-eng    : +48.7278+002.2696/
    com.android.version: 9
    encoder         : Lavf58.27.103
    Stream #0:0(eng), 0, 1/10240: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 72552 kb/s, 239.64 fps, 240 tbr, 10240 tbn, 10 tbc (default)
    Metadata:
      rotate          : 90
      creation_time   : 2019-05-19T14:25:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of -90.00 degrees
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
No more output streams to write to, finishing.
frame=  854 fps=0.0 q=-1.0 Lsize=   31571kB time=00:00:03.55 bitrate=72657.5kbits/s speed= 193x    
video:31561kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.030221%
Input file #0 (myvideo.mp4):
  Input stream #0:0 (video): 854 packets read (32318908 bytes); 
  Input stream #0:1 (audio): 0 packets read (0 bytes); 
  Total: 854 packets (32318908 bytes) demuxed
Output file #0 (myvideo-slow.mp4):
  Output stream #0:0 (video): 854 packets muxed (32318908 bytes); 
  Total: 854 packets (32318908 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x55f03efaa900] Statistics: 2 seeks, 127 writeouts
[AVIOContext @ 0x55f03efaf280] Statistics: 32407367 bytes read, 4 seeks

After this, the speed of the new video is unchanged.
Thanks for your help.

Change History (2)

comment:1 by François Lafont, 5 years ago

FYI, I have reproduced the problem with this video:

http://archive.flaf.fr/misc/myvideo.mp4

comment:2 by Balling, 2 years ago

Resolution: invalid
Status: newclosed

All samples are gone but that is not how to "change the speed of a video".

You should use ffmpeg -itsscale 0.016667 -i input.mp4 -c copy -an output.mp4 to get 60 times faster speed for example.

Possibly you would need something like this if the timebase is bad: https://stackoverflow.com/a/55233982

Last edited 2 years ago by Balling (previous) (diff)
Note: See TracTickets for help on using tickets.