Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7652 closed defect (invalid)

video_size input option doesn't work for compressed raw stream

Reported by: Ilya87 Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

1 - extract raw compressed video stream with mplayer -dumpvideo
2 - ffmpeg -loglevel trace -video_size 1920x1080 -f h264 -c:v h264 -r 24 -i sintel.h264 -c copy 123.mkv
ffmpeg 92906-g54109b1d14
from https://ffmpeg.zeranoe.com/builds/ (Windows 10 x64 shared)

Output:
ffmpeg version N-92906-g54109b1d14 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 25.100 / 56. 25.100
  libavcodec     58. 43.100 / 58. 43.100
  libavformat    58. 25.100 / 58. 25.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-video_size' ... matched as AVOption 'video_size' with argument '1920x1080'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'h264'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '24'.
Reading option '-i' ... matched as input url with argument 'sintel.h264'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '123.mkv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url sintel.h264.
Applying option f (force format) with argument h264.
Applying option c:v (codec name) with argument h264.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 24.
Successfully parsed a group of options.
Opening an input file: sintel.h264.
[h264 @ 000001d374d92f40] Opening 'sintel.h264' for reading
[file @ 000001d374d94800] Setting default whitelist 'file,crypto'
Option video_size not found.

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

Change History (7)

comment:1 by Carl Eugen Hoyos, 5 years ago

Component: avutilundetermined
Keywords: vide_size dimensions removed
Resolution: invalid
Status: newclosed

The option is only useful for rawvideo (and some devices) but cannot be used for h.264.

comment:2 by Hendrik, 5 years ago

Compressed video has an inherent size by itself, stored in the bitstream. Overriding it makes no sense.

comment:3 by Ilya87, 5 years ago

Resolution: invalid
Status: closedreopened

But ffmpeg can't read dimensions (video width and height) without from this file, so this option is necesary.
Output:
ffmpeg version N-92906-g54109b1d14 Copyright (c) 2000-2019 the FFmpeg developers

built with gcc 8.2.1 (GCC) 20181201
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 43.100 / 58. 43.100
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 46.101 / 7. 46.101
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100

Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'h264'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '24'.
Reading option '-i' ... matched as input url with argument 'sintel.h264'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '123.mkv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input url sintel.h264.
Applying option f (force format) with argument h264.
Applying option c:v (codec name) with argument h264.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 24.
Successfully parsed a group of options.
Opening an input file: sintel.h264.
[h264 @ 000001b680682ec0] Opening 'sintel.h264' for reading
[file @ 000001b680683740] Setting default whitelist 'file,crypto'
[h264 @ 000001b680682ec0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[h264 @ 000001b68068d380] missing picture in access unit with size 12585771
[AVBSFContext @ 000001b6822d0f40] Invalid NAL unit 0, skipping.
[h264 @ 000001b68068d380] Invalid NAL unit 0, skipping.
[h264 @ 000001b68068d380] no frame!
[h264 @ 000001b680682ec0] Probe buffer size limit of 5000000 bytes reached
[h264 @ 000001b680682ec0] Stream #0: not enough frames to estimate rate; consider increasing probesize
[h264 @ 000001b680682ec0] decoding for stream 0 failed
[h264 @ 000001b680682ec0] stream 0: start_time: -7686143364045.646 duration: -7686143364045.646
[h264 @ 000001b680682ec0] format: start_time: -9223372036854.775 duration: -9223372036854.775 bitrate=0 kb/s
[h264 @ 000001b680682ec0] Could not find codec parameters for stream 0 (Video: h264, 1 reference frame, none(left)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[h264 @ 000001b680682ec0] After avformat_find_stream_info() pos: 12585771 bytes read:12585771 seeks:0 frames:1
Input #0, h264, from 'sintel.h264':

Duration: N/A, bitrate: N/A

Stream #0:0, 1, 1/1200000: Video: h264, 1 reference frame, none(left), 24 tbr, 1200k tbn, 48 tbc

Successfully opened the file.
Parsing a group of options: output url 123.mkv.
Applying option c (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: 123.mkv.
File '123.mkv' already exists. Overwrite ? [y/N] y
[file @ 000001b6822d0380] Setting default whitelist 'file,crypto'
Successfully opened the file.
[matroska @ 000001b68069a800] dimensions not set
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:

Stream #0:0 -> #0:0 (copy)

Last message repeated 1 times

[AVIOContext @ 000001b6822d0440] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 000001b68068b8c0] Statistics: 12585771 bytes read, 0 seeks

comment:4 by Hendrik, 5 years ago

Dimensions missing is just one symptom, your extracted stream is likely just entirely invalid. H.264 streams need configuration data, more then just the dimensions, more then you could ever provide on the command line. Without that, its impossible to properly decode it.

Don't just dump random compressed video into a file. There is more to it then that.

comment:5 by Cigaes, 5 years ago

Resolution: invalid
Status: reopenedclosed

Providing the image size cannot help. Lossy codecs do not work that way.

How did you obtain that file? Can anything else read it?

comment:6 by Ilya87, 5 years ago

https://mega.nz/#F!u5lmVCbR!A3ShoYx5o4RDTpx24tgYdQ
mplayer.exe sintel.mkv -dumpvideo -dumpfile sintel.h264
ffmpeg -loglevel trace -video_size 2560x1090 -f h264 -c:v h264 -r 24 -i sintel.h264 -c copy 123.mkv

comment:7 by Hendrik, 5 years ago

MKVs usually contain MP4-style H.264. You cannot dump that into a file and expect it to work. In other words, your resulting file is invalid.

Generally, you are best advised to use a tool thats designed for processing video, like ffmpeg itself, if you want to seperate the video out of an existing file.

Note: See TracTickets for help on using tickets.