[FFmpeg-user] ffmpeg stream copy does NOT set AV_PKT_FLAG_KEY when input_format h264

Soho Soho123 soho123.2012 at gmail.com
Fri Mar 22 12:36:02 CET 2013


> Is your problem only reproducible if you select ffm as
> output format or also if you output to a .h264 file?


It seem does not releated to output file format.
Becasue the size of output file is "0", there is no anything be output.
in ffmpeg.c function do_streamcopy,
the check below will return directly:

if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
        !ost->copy_initial_nonkeyframes){
        return;
    }

I have to remove the check in do_streamcopy, then I can get output.
Or nothing is output.


the log about my test:

#ffserver -f /etc/ffserver.conf &
# ffserver version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 21 2013 14:21:02 with gcc 4.4.5-1.5.5p4 (GCC)
  configuration: --enable-cross-compile --cross-prefix=sdk-linux-
--arch=mips --target-os=linux --disable
-doc --disable-htmlpages --disable-manpages --disable-podpages
--disable-txtpages --disable-mips32r2 --dis
able-ffplay --disable-postproc --disable-runtime-cpudetect
--disable-swscale-alpha --disable-mipsdspr1 --disable-mipsdspr2
--disable-mipsfpu --enable-small --prefix=/ffmpeg/romfs
--bindir=/ffmpeg/romfs --disable-bsfs --disable-filters --enable-gpl
--enable-libx264 --extra-cflags=-I/lib/crosslib/include
--extra-libs='-L/lib/crosslib/lib -lx264'
--enable-filter='aformat,aresample
,copy,format,fps,framestep,resample' --disable-encoders
--enable-encoder='h264,libx264,libx264rgb' --enabl
e-encoder=yuv4 --enable-encoder=mjpeg --disable-decoders
--enable-decoder=mjpeg --enable-decoder=h264 --en
able-decoder=mpegvideo --enable-decoder=mpeg2video --enable-decoder=y
libavutil      52. 18.100 / 52. 18.
100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
Fri Mar 22 19:21:52 2013 FFserver started.

# ffmpeg  -loglevel debug -f video4linux2 -r 10 -s 640x480
-input_format h264 -i /dev/video1  -vcodec copy
http://localhost:8090/feed1.ffm
ffmpeg version 1.2 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 21 2013 14:21:02 with gcc 4.4.5-1.5.5p4 (GCC)
  configuration: --enable-cross-compile --cross-prefix=sdk-linux-
--arch=mips --target-os=linux --disable
-doc --disable-htmlpages --disable-manpages --disable-podpages
--disable-txtpages --disable-mips32r2 --dis
able-ffplay --disable-postproc --disable-runtime-cpudetect
--disable-swscale-alSetting frame interval to 1/10 (1000000).
pUsing frame interval 100000.0 us (10.0 fps).
ha --disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu
--enable-small --prefix=/ffmpeg/romfs --bindir=/ffmpeg/romfs
--disable-bsfs --disable-filters --enable-gpl
--enable-libx264 --extra-cflags=-I/lib/crosslib/include
--extra-libs='-L/lib/crosslib/lib -lx264' --enable
-filter='aformat,aresample,copy,format,fps,framestep,resample'
--disable-encoders --enable-encoder='h264,l
ibx264,libx264rgb' --enable-encoder=yuv4 --enable-encoder=mjpeg
--disable-decoders --enable-decoder=mjpeg
--enable-decoder=h264 --enable-decoder=mpegvideo
--enable-decoder=mpeg2video --enable-decoder=y  libavutil
      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set
libav* logging level) with argument 'debug'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'video4linux2'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz
value, fraction or abbreviation)) with argument '10'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or
abbreviation)) with argument '640x480'.
Reading option '-input_format' ... matched as AVOption 'input_format'
with argument 'h264'.
Reading option '-i' ... matched as input file with argument '/dev/video1'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video
codec ('copy' to copy stream)) with argument 'copy'.
Reading option 'http://localhost:8090/feed1.ffm' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set libav* logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file /dev/video1.
Applying option f (force format) with argument video4linux2.
Applying option r (set frame rate (Hz value, fraction or
abbreviation)) with argument 10.
Applying option s (set frame size (WxH or abbreviation)) with argument 640x480.
Successfully parsed a group of options.
Opening an input file: /dev/video1.
[video4linux2,v4l2 @ 0x69e660] fd:3 capabilities:4000001
[video4linux2,v4l2 @ 0x69e660] Selecting input_channel: 0
[video4linux2,v4l2 @ 0x69e660] input_channel: 0, input_name: Camera 1
[video4linux2,v4l2 @ 0x69e660] Setting time per frame to 1/10
[video4linux2,v4l2 @ 0x69e660] End of v4l2_read_header
[h264 @ 0x69f190] Using externally provided dimensions
[video4linux2,v4l2 @ 0x69e660] All info found
[video4linux2,v4l2 @ 0x69e660] Estimating duration from bitrate, this
may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video1':
  Duration: N/A, start: 84.090000, bitrate: N/A
    Stream #0:0, 8, 1/1000000: Video: h264, yuv420p, 640x480,
1/2000000, -1 kb/s, 10 fps, 10 tbr, 1000k tb
n, 2000k tbc
Successfully opened the file.
Parsing a group of options: output file http://localhost:8090/feed1.ffm.
Applying option vcodec (force video codec ('copy' to copy stream))
with argument copy.
Successfully parsed a group of options.
Opening an output file: http://localhost:8090/feed1.ffm.
[ffm @ 0x73f920] Format ffm probed with size=2048 and score=101
[AVIOContext @ 0x74a600] Statistics: 4096 bytes read, 0 seeks
Fri Mar 22 19:22:26 2013 127.0.0.1 - - [GET] "/feed1.ffm HTTP/1.1" 200 4175
Successfully opened the file.
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
  Metadata:
    creation_time   : now
    encoder         : Lavf54.63.104
    Stream #0:0, 0, 1/1000000: Video: h264, yuv420p, 640x480,
1/1000000, q=2-31, -1 kb/s, 10 fps, 1000k tb
n, 1000k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 size=       4kB time=00:00:00.00
bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=       4kB
time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=
4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=
    4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0
size=       4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0
q=-1.0 size=       4kB time=00:00:00.00 bitrate=N/A    frame=    0
fps=0.0 q=-1.0 size=       4kB time=00:00:00.00 bitrate=N/A    frame=
  0 fps=0.0 q=-1.0 size=       4kB time=00:00:00.00 bitrate=N/A
frame=    0 fps=0.0 q=-1.0 size=       4kB time=00:00:00.00
bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=       4kB
time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=
4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0 size=
    4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0 q=-1.0
size=       4kB time=00:00:00.00 bitrate=N/A    frame=    0 fps=0.0
q=-1.0 Lsize=       4kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead inf%
Output file is empty, nothing was encoded (check -ss / -t / -frames
parameters if used)
Fri Mar 22 19:22:33 2013 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 4096
#


More information about the ffmpeg-user mailing list