Ticket #2043 (closed defect: invalid)
unexpected behaviour when segmenting x264 encoded rawvideo sources
| Reported by: | elkq | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avformat |
| Version: | git-master | Keywords: | h264 segment mpegts |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | yes |
Description
ffmpeg fails to segment rawvideo sources that have been encoded with libx264.
The following command line fails:
ffmpeg -report -v 9 -loglevel 99 -s 352x288 -i /tmp/container_cif.yuv -c:v libx264 -an -sn -map 0 -f segment -segment_time 4 -segment_list hls.m3u8 -segment_format mpegts hls%03d.ts
But a similar command line without the segmentation suceeeds:
ffmpeg -report -v 9 -loglevel 99 -s 352x288 -i /tmp/container_cif.yuv -c:v libx264 -an -sn -map 0 -f mpegts not_hls.ts
The source YUV file in this example is one of the test sequences from the Arizona State University Video Trace Library: http://trace.eas.asu.edu/yuv/container/container_cif.7z
Dump of failure report:
ffmpeg started on 2012-12-18 at 16:18:08
Report written to "ffmpeg-20121218-161808.log"
Command line:
ffmpeg -report -v 9 -loglevel 99 -s 352x288 -i /tmp/container_cif.yuv -c:v libx264 -an -sn -map 0 -f segment -segment_time 4 -segment_list hls.m3u8 -segment_format mpegts "hls%03d.ts"
ffmpeg version N-47415-gd913883 Copyright (c) 2000-2012 the FFmpeg developers
built on Dec 4 2012 12:59:22 with gcc 4.7 (Ubuntu/Linaro 4.7.2-2ubuntu1)
configuration: --enable-gpl --enable-nonfree --enable-shared --enable-libfaac --enable-libx264 --enable-libvpx
libavutil 52. 11.101 / 52. 11.101
libavcodec 54. 78.101 / 54. 78.101
libavformat 54. 42.100 / 54. 42.100
libavdevice 54. 3.102 / 54. 3.102
libavfilter 3. 23.105 / 3. 23.105
libswscale 2. 1.103 / 2. 1.103
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
[rawvideo @ 0x135be00] Format rawvideo probed with size=2048 and score=50
[rawvideo @ 0x135be00] File position before avformat_find_stream_info() is 0
[rawvideo @ 0x135be00] All info found
[rawvideo @ 0x135be00] Estimating duration from bitrate, this may be inaccurate
[rawvideo @ 0x135be00] File position after avformat_find_stream_info() is 152064
Input #0, rawvideo, from '/tmp/container_cif.yuv':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0, 1, 1/25: Video: rawvideo (I420 / 0x30323449), yuv420p, 352x288, 1/25, 25 tbr, 25 tbn, 25 tbc
[buffer @ 0x1358de0] Setting entry with key 'video_size' to value '352x288'
[buffer @ 0x1358de0] Setting entry with key 'pix_fmt' to value '0'
[buffer @ 0x1358de0] Setting entry with key 'time_base' to value '1/25'
[buffer @ 0x1358de0] Setting entry with key 'pixel_aspect' to value '0/1'
[buffer @ 0x1358de0] Setting entry with key 'sws_param' to value 'flags=2'
[buffer @ 0x1358de0] Setting entry with key 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x135c640] w:352 h:288 pixfmt:yuv420p tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[libx264 @ 0x1363840] using mv_range_thread = 24
[libx264 @ 0x1363840] using cpu capabilities: MMX2 SSE2 SSE3 Cache64 BMI1
[libx264 @ 0x1363840] profile High, level 1.3
[libx264 @ 0x1363840] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mpegts @ 0x1982060] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, segment, to 'hls%03d.ts':
Metadata:
encoder : Lavf54.42.100
Stream #0:0, 0, 1/90000: Video: h264, yuv420p, 352x288, 1/25, q=-1--1, 90k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x1363840] using mv_range_thread = 24
[libx264 @ 0x1363840] frame= 0 QP=23.61 NAL=3 Slice:I Poc:0 I:396 P:0 SKIP:0 size=16513 bytes
[mpegts @ 0x1982060] H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)
av_interleaved_write_frame(): Invalid argument
Statistics: 7755264 bytes read, 0 seeks
Change History
comment:1 Changed 5 months ago by cehoyos
- Keywords h264 segment added
- Resolution set to invalid
- Status changed from new to closed
- Component changed from FFmpeg to undetermined
comment:2 in reply to: ↑ description Changed 5 months ago by saste
- Analyzed by developer set
- Keywords mpegts added
- Component changed from undetermined to avformat
- Reproduced by developer set
Replying to elkq:
ffmpeg fails to segment rawvideo sources that have been encoded with libx264.
The following command line fails:
ffmpeg -report -v 9 -loglevel 99 -s 352x288 -i /tmp/container_cif.yuv -c:v libx264 -an -sn -map 0 -f segment -segment_time 4 -segment_list hls.m3u8 -segment_format mpegts hls%03d.ts
This works if you specify -f ssegment, see commit a9a7e215e5207e674338b7ca9eb74e96ae5faf99.
The riddle is due to the fact that libavformat needs to know if the output is stream-based or file-based when opening the segment muxer, and this can't be known in advance with the segment muxer, when the internal muxer has not been selected yet.
Error feedback can be improved, on the other hand this behavior cannot be easily fixed.



Please add "-flags -global_header" to your command line.