[FFmpeg-user] Could not write header for output file #0 (incorrect codec parameters ?)

MrNice wxcvbn2006 at iol.ie
Mon Jul 20 16:07:47 CEST 2015


On 19/07/15 19:59, Carl Eugen Hoyos wrote:
> ffmpeg -i /dev/video0 out.avi

Boot my desktop this morning and first try:

 ./ffmpeg -i /dev/video0 out.avi
ffmpeg version N-73517-g47d0773 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 2338.288325, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576,
165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf56.40.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x576,
q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.47.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
frame=  214 fps= 25 q=2.0 Lsize=     183kB time=00:00:08.56 bitrate=
175.4kbits/s
video:173kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 6.181012%
***************************************************************

Record started, the file has no video (black screen), I think it's OK.
I tried with other recording commands to be sure but didn't change any
set-up then I did a second try:

 ./ffmpeg -i /dev/video0 out.avi
ffmpeg version N-73517-g47d0773 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576,
165888 kb/s, 25 fps, 25 tbr, 1000k tbn, 1000k tbc
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf56.40.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 720x576,
q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.47.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Could not write header for output file #0 (incorrect codec parameters
?): Immediate exit requested
Exiting normally, received signal 2.
**************************************************************

I tried few times I got the same error.
I don't know what has done the issue.
I reboot the desktop then try again.
Now no error. Any idea what has caused the issue? Where I could have a
look if it happen again?

So I try my original command and I have some questions at the very bottom:

 ./ffmpeg -debug 1 -f pulse -ar 44100 -ac 2 -channel_layout stereo -i
alsa_input.pci-0000_00_14.2.analog-stereo -f v4l2 -channel 1 -i
/dev/video0 -c:a copy /Store3/Test/t_`date +%Y%m%d_%H%M`.mkv
ffmpeg version N-73517-g47d0773 Copyright (c) 2000-2015 the FFmpeg
developers
  built with gcc 5.1.1 (GCC) 20150618 (Red Hat 5.1.1-4)
  configuration: --enable-libpulse
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
 matched as AVOption 'debug' with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'pulse'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate
(in Hz)) with argument '44100'.
Reading option '-ac' ... matched as option 'ac' (set number of audio
channels) with argument '2'.
Reading option '-channel_layout' ... matched as option 'channel_layout'
(set channel layout) with argument 'stereo'.
Reading option '-i' ... matched as input file with argument
'alsa_input.pci-0000_00_14.2.analog-stereo'.
Reading option '-f' ... matched as option 'f' (force format) with
argument 'v4l2'.
Reading option '-channel' ... matched as AVOption 'channel' with
argument '1'.
Reading option '-i' ... matched as input file with argument '/dev/video0'.
Reading option '-c:a' ... matched as option 'c' (codec name) with
argument 'copy'.
Reading option '/Store3/Test/t_20150720_1419.mkv' ... matched as output
file.
Finished splitting the commandline.
Parsing a group of options: global .
Successfully parsed a group of options.
Parsing a group of options: input file
alsa_input.pci-0000_00_14.2.analog-stereo.
Applying option f (force format) with argument pulse.
Applying option ar (set audio sampling rate (in Hz)) with argument 44100.
Applying option ac (set number of audio channels) with argument 2.
Applying option channel_layout (set channel layout) with argument stereo.
Successfully parsed a group of options.
Opening an input file: alsa_input.pci-0000_00_14.2.analog-stereo.
[pulse @ 0x1d1ada0] All info found
Input #0, pulse, from 'alsa_input.pci-0000_00_14.2.analog-stereo':
  Duration: N/A, start: 1437398340.784791, bitrate: 1411 kb/s
    Stream #0:0, 1, 1/1000000: Audio: pcm_s16le, 44100 Hz, stereo, s16,
1411 kb/s
Successfully opened the file.
Parsing a group of options: input file /dev/video0.
Applying option f (force format) with argument v4l2.
Successfully parsed a group of options.
Opening an input file: /dev/video0.
[video4linux2,v4l2 @ 0x1d33fa0] fd:6 capabilities:85220001
[video4linux2,v4l2 @ 0x1d33fa0] Selecting input_channel: 1
[video4linux2,v4l2 @ 0x1d33fa0] Current input_channel: 1, input_name:
S-Video, input_std: ffffff
[video4linux2,v4l2 @ 0x1d33fa0] Querying the device for the current
frame size
[video4linux2,v4l2 @ 0x1d33fa0] Setting frame size to 720x576
[video4linux2,v4l2 @ 0x1d33fa0] Trying to set codec:rawvideo pix_fmt:yuv420p
    Last message repeated 1 times
[video4linux2,v4l2 @ 0x1d33fa0] Trying to set codec:rawvideo pix_fmt:yuv422p
[video4linux2,v4l2 @ 0x1d33fa0] Trying to set codec:rawvideo pix_fmt:yuyv422
[video4linux2,v4l2 @ 0x1d33fa0] The V4L2 driver is using the interlaced mode
[video4linux2,v4l2 @ 0x1d33fa0] Current standard: PAL, id: ff,
frameperiod: 1/25
[video4linux2,v4l2 @ 0x1d33fa0] All info found
Input #1, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 11683.470323, bitrate: 165888 kb/s
    Stream #1:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (YUY2
/ 0x32595559), yuyv422, 720x576, 1/1000000, 165888 kb/s, 25 fps, 25 tbr,
1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: output file /Store3/Test/t_20150720_1419.mkv.
Applying option c:a (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: /Store3/Test/t_20150720_1419.mkv.
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'video_size' to
value '720x576'
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'pix_fmt' to value '1'
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'time_base' to value
'1/1000000'
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'pixel_aspect' to
value '0/1'
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'sws_param' to value
'flags=2'
[graph 0 input from stream 1:0 @ 0x1d06dc0] Setting 'frame_rate' to
value '25/1'

----------------------------------------------------------------------
[graph 0 input from stream 1:0 @ 0x1d06dc0] w:720 h:576 pixfmt:yuyv422
tb:1/1000000 fr:25/1 sar:0/1 sws_param:flags=2
----------------------------------------------------------------------

[format @ 0x1d073a0] compat: called with args=[yuv420p]
[format @ 0x1d073a0] Setting 'pix_fmts' to value 'yuv420p'
[auto-inserted scaler 0 @ 0x1cfcc20] Setting 'flags' to value '0x4'
[auto-inserted scaler 0 @ 0x1cfcc20] w:iw h:ih flags:'0x4' interl:0
[format @ 0x1d073a0] auto-inserting filter 'auto-inserted scaler 0'
between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x1cfca40] query_formats: 4 queried, 2 merged, 1
already done, 0 delayed
[auto-inserted scaler 0 @ 0x1cfcc20] w:720 h:576 fmt:yuyv422 sar:0/1 ->
w:720 h:576 fmt:yuv420p sar:0/1 flags:0x4
[mpeg4 @ 0x1d370a0] intra_quant_bias = 0 inter_quant_bias = -64

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[matroska @ 0x1d359e0] Codec for stream 1 does not use global headers
but container format requires global headers
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Output #0, matroska, to '/Store3/Test/t_20150720_1419.mkv':
  Metadata:
    encoder         : Lavf56.40.100
    Stream #0:0, 0, 1/1000: Video: mpeg4, 1 reference frame (FMP4 /
0x34504D46), yuv420p, 720x576, 1/25, q=2-31, 200 kb/s, 25 fps, 1k tbn,
25 tbc
    Metadata:
      encoder         : Lavc56.47.100 mpeg4
    Stream #0:1, 0, 1/1000: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
44100 Hz, stereo, 1411 kb/s
Stream mapping:
  Stream #1:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Cliping frame in rate conversion by 0.000008
Cliping frame in rate conversion by 0.000114
[matroska @ 0x1d359e0] Writing block at offset 715, size 4520, pts 0,
dts 0, duration 40, keyframe 1
[matroska @ 0x1d359e0] Starting new cluster at offset 5242 bytes, pts
40dts 40
[matroska @ 0x1d359e0] Writing block at offset 5257, size 65472, pts 0,
dts 0, duration 371, keyframe 1
[matroska @ 0x1d359e0] Writing block at offset 70737, size 4520, pts 40,
dts 40, duration 40, keyframe 1
Cliping frame in rate conversion by 0.000221
[matroska @ 0x1d359e0] Starting new cluster at offset 75264 bytes, pts
80dts 80
[matroska @ 0x1d359e0] Writing block at offset 75279, size 4527, pts 80,
dts 80, duration 40, keyframe 1
Cliping frame in rate conversion by 0.001961
[matroska @ 0x1d359e0] Starting new cluster at offset 79813 bytes, pts
120dts 120
[matroska @ 0x1d359e0] Writing block at offset 79828, size 4523, pts
120, dts 120, duration 40, keyframe 1
Cliping frame in rate conversion by 0.198814
[matroska @ 0x1d359e0] Starting new cluster at offset 84358 bytes, pts
160dts 160
[matroska @ 0x1d359e0] Writing block at offset 84373, size 4522, pts
160, dts 160, duration 40, keyframe 1
Cliping frame in rate conversion by 0.198891
[matroska @ 0x1d359e0] Starting new cluster at offset 88902 bytes, pts
200dts 200
[matroska @ 0x1d359e0] Writing block at offset 88917, size 4527, pts
200, dts 200, duration 40, keyframe 1
Cliping frame in rate conversion by 0.199287
[matroska @ 0x1d359e0] Writing block at offset 93451, size 1943, pts
240, dts 240, duration 40, keyframe 0
Cliping frame in rate conversion by 0.199699
[matroska @ 0x1d359e0] Writing block at offset 95401, size 2251, pts
280, dts 280, duration 40, keyframe 0
Cliping frame in rate conversion by 0.200020
[matroska @ 0x1d359e0] Writing block at offset 97659, size 2263, pts
320, dts 320, duration 40, keyframe 0
Cliping frame in rate conversion by 0.200172
[matroska @ 0x1d359e0] Writing block at offset 99929, size 1541, pts
360, dts 360, duration 40, keyframe 0
Cliping frame in rate conversion by 0.201424
[matroska @ 0x1d359e0] Writing block at offset 101477, size 46412, pts
371, dts 371, duration 263, keyframe 1
[matroska @ 0x1d359e0] Writing block at offset 147897, size 1099, pts
400, dts 400, duration 40, keyframe 0
Cliping frame in rate conversion by 0.200722
[matroska @ 0x1d359e0] Writing block at offset 149003, size 1082, pts
440, dts 440, duration 40, keyframe 0
Cliping frame in rate conversion by 0.201118
[matroska @ 0x1d359e0] Writing block at offset 150092, size 757, pts
480, dts 480, duration 40, keyframe 0
Cliping frame in rate conversion by 0.201424
[matroska @ 0x1d359e0] Writing block at offset 150856, size 1499, pts
520, dts 520, duration 40, keyframe 0

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[video4linux2,v4l2 @ 0x1d33fa0] Thread message queue blocking; consider
raising the thread_queue_size option (current value: 8)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

[matroska @ 0x1d359e0] Writing block at offset 152362, size 65472, pts
634, dts 634, duration 371, keyframe 1
[matroska @ 0x1d359e0] end duration = 1005
frame=   14 fps=0.0 q=2.4 Lsize=     213kB time=00:00:01.00
bitrate=1735.0kbits/s
video:39kB audio:173kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.475269%
Input file #0 (alsa_input.pci-0000_00_14.2.analog-stereo):
  Input stream #0:0 (audio): 3 packets read (177356 bytes);
  Total: 3 packets (177356 bytes) demuxed
Input file #1 (/dev/video0):
  Input stream #1:0 (video): 14 packets read (11612160 bytes); 14 frames
decoded;
  Total: 14 packets (11612160 bytes) demuxed
Output file #0 (/Store3/Test/t_20150720_1419.mkv):
  Output stream #0:0 (video): 14 frames encoded; 14 packets muxed (39574
bytes);
  Output stream #0:1 (audio): 3 packets muxed (177356 bytes);
  Total: 17 packets (216930 bytes) muxed
14 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x1d3ae20] Statistics: 54 seeks, 57 writeouts
***************************************************************************



1- highlighted with ++++++++++++++
Stream 1 (video) has a warning for the header. How to remove it?

2- highlighted with :::::::::::::::
Thread message queue blocking;
What does this warning mean?  How to remove it?

The objective is to get lossless audio and video from what the Dazzle
DVC100 provide.
3- highlighted with ---------------
codec:rawvideo is pix_fmt:yuyv422

./ffmpeg -f v4l2 -list_formats all -i /dev/video0
[video4linux2,v4l2 @ 0x3548400] Raw       :     yuyv422 : 16 bpp YUY2,
4:2:2, packed : {144-720, 1}x{115-576, 1}
[video4linux2,v4l2 @ 0x3548400] Raw       :    rgb565le :   16 bpp RGB
565, LE : {144-720, 1}x{115-576, 1}
[video4linux2,v4l2 @ 0x3548400] Raw       : bayer_bggr8 : 8 bpp Bayer
BGBG..GRGR : {144-720, 1}x{115-576, 1}
[video4linux2,v4l2 @ 0x3548400] Raw       : bayer_grbg8 : 8 bpp Bayer
GRGR..BGBG : {144-720, 1}x{115-576, 1}
[video4linux2,v4l2 @ 0x3548400] Raw       : bayer_gbrg8 : 8 bpp Bayer
GBGB..RGRG : {144-720, 1}x{115-576, 1}
[video4linux2,v4l2 @ 0x3548400] Raw       :     yuv411p :        12 bpp
YUV411 : {144-720, 1}x{115-576, 1}

AFAIK, yuyv422 is better than yuv420p. I tried to use yuyv422 but I have
the error:
Incompatible pixel format 'yuyv422' for codec 'mpeg4', auto-selecting
format 'yuv420p'

What is the codec I could use the get 422?

4- I'd guess you have huge knowledge on VHS video tape conversion.
I have S-VHS tapes. I have a JVC S-VHS player with TBC.
Is my ffmpeg command good to get the best quality?
What codec, container do you advise?
After conversion, I'll use a simple video editor like Kdenlive for basic
video editing.

Many thanks


More information about the ffmpeg-user mailing list