Opened 9 years ago

Closed 9 years ago

#4266 closed defect (fixed)

FFM container now needs codec even with stream copy

Reported by: biskitt Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I use a small hand-made ffmpeg.exe, without some encoders. In this case, no h264 encoder: I use it only to dump rtsp streams, with stream copy.

Since 2.5.x, the encoder is needed, even with stream copy. The avformat_write_header() function failed EINVAL error (-22). Everything is fine if I use avi format, or a version before one of this two commit:
6690d4c3f53bd46144f3c13afcc77bcca3f7bb0b
745730c9c208c40f800d5d71ffa39aceab6ce044

It failed on this code, since I do not have the encoder:

const AVCodec *enc = ctx->codec ? ctx->codec : avcodec_find_encoder(ctx->codec_id);

if (!enc)
    return AVERROR(EINVAL);

I tried to get rid of this enc by myself, but it failed. I do not know the serialization system well enough to go on by myself.
Again, it works well with other containers (such as avi) of before those commits, so I do not think having the encoder for stream copy in ffm format is needed: I was able to ffplay the output.ffm produced by 2.4.x version without issue.

How to reproduce (from 2.5.2 version, same behaviour with git-master):

% ffmpeg -i rtsp://input -codec copy -flags +global_header -f ffm output.ffm
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan  8 2015 20:47:33 with gcc 4.8.1 (GCC)
  configuration: --disable-static --enable-shared --disable-w32threads --enable-
pthreads --disable-doc --prefix=redist --extra-cflags=-DPTW32_STATIC_LIB --extra
-ldflags=-static-libgcc
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
Input #0, rtsp, from 'rtsp://input':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.517600, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuv420p, 1280x720, 12 fps, 25 tbr, 90k tbn,
 24 tbc
Output #0, ffm, to 'output.ffm':
  Metadata:
    title           : Media Presentation
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264, yuv420p, 1280x720, q=2-31, 12 fps, 1000k tbn, 12 t
bc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Could not write header for output file #0 (incorrect codec parameters ?): Error
number -22 occurred

Change History (4)

comment:1 by mastered, 9 years ago

Does return 0; instead of return AVERROR(EINVAL); fixes the problem?
An option to skip private options could be added to fix it in some reasonable manner.

in reply to:  1 ; comment:2 by biskitt, 9 years ago

Replying to mastered:

Does return 0; instead of return AVERROR(EINVAL); fixes the problem?
An option to skip private options could be added to fix it in some reasonable manner.

I just tested you "return 0" on the 2.5.4 source, built with the same command line (without the encoder): it seems to work perfectly fine. I have my output file and I can re-use it, change its format, decode it, and other things.
Thanks!

I think it would be better to have an option in include private options, instead of an option to skip private options: more consistent with other the format container that do not need an encoder. But I might be missing something.

in reply to:  2 comment:3 by mastered, 9 years ago

Replying to biskitt:

I think it would be better to have an option in include private options, instead of an option to skip private options: more consistent with other the format container that do not need an encoder. But I might be missing something.

Yes, I didn't add an option. Just print a warning.

comment:4 by mastered, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.