[FFmpeg-user] broken mp4 file from upd stream

Patrick patrick_fischer at gmx.de
Thu Feb 2 11:14:28 EET 2017


Hello

i'm using ffmpeg to record a tv stream from an udp multicast (mpeg-ts).

output is an codec copy mpeg-ts file and a html5 conform mp4 file
(faststart, h264, aac, ...)

most of the time it works very well but sometimes(1 of 10) the mp4 file
is broken.

it seems that the moov atom header will not be written or something else.

Does anyone have an idea?





ffmpeg -hide_banner -loglevel info -timeout 3000 -i
'udp://238.1.1.3:1234&timeout=2000' -codec copy -y
2017-02-01_19-55-38.ts -vcodec libx264 -preset ultrafast -profile:v
baseline -flags +cgop -bf 0 -crf 24 -pix_fmt yuv420p -g 25 -acodec aac
-strict experimental -ac 2 -ab 128k -ar 44100 -movflags +faststart -vb
2000k -y lores_2017-02-01_19-55-38.ts.mp4

ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (SUSE Linux)
  configuration: --prefix=/home/build/ffmpeg-static/target
--pkg-config-flags=--static
--extra-cflags='-I/home/build/ffmpeg-static/target/include -static'
--extra-ldflags='-L/home/build/ffmpeg-static/target/lib -static'
--bindir=/home/build/ffmpeg-static/bin --disable-ffplay
--disable-ffserver --enable-gpl --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264
--enable-nonfree
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100

[mpeg2video @ 0x25e9300] Invalid frame dimensions 0x0.
Input #0, mpegts, from 'udp://238.1.1.3:1234&timeout=2000':
  Duration: N/A, start: 63424.941422, bitrate: 3692 kb/s
  Program 10067
    Metadata:
      service_name    : Bloomberg Europe TV
      service_provider: Bloomberg TV
    Stream #0:0[0x528](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000
Hz, stereo, s16p, 192 kb/s
    Stream #0:1[0x550]: Video: mpeg2video (Main) ([2][0][0][0] /
0x0002), yuv420p(tv, top first), 544x576 [SAR 32:17 DAR 16:9], 3500
kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
  Program 10030
    Metadata:
      service_name    : CNBC Europe
      service_provider: CNBC
  Program 10050
    Metadata:
      service_name    : BBC World
      service_provider: BBC
  Program 10099
    Metadata:
      service_name    : Data System
      service_provider: SES ASTRA
  Program 10079
    Metadata:
      service_name    : RMC Decouverte HD
      service_provider: SES ASTRA
  Program 10081
    Metadata:
      service_name    : RMC Decouverte HD
      service_provider: SES ASTRA
  Program 10080
    Metadata:
      service_name    : Sonlife Broadcasting Network
      service_provider: SES ASTRA
  Program 10082
    Metadata:
      service_name    : Algerie 3
      service_provider: TDA
  Program 10083
    Metadata:
      service_name    : Canal Algerie
      service_provider: TDA
Output #0, mpegts, to '2017-02-01_19-55-38.ts':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #0:0: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, top first), 544x576 [SAR 32:17 DAR 16:9], q=2-31, 3500 kb/s,
25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1(eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, 192 kb/s
[libx264 @ 0x25e2560] using SAR=1/1
[libx264 @ 0x25e2560] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x25e2560] profile Constrained Baseline, level 3.0
[libx264 @ 0x25e2560] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft
2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=1
deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00
mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0
deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=11
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=25
keyint_min=2 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=24.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #1, mp4, to 'lores_2017-02-01_19-55-38.ts.mp4':
  Metadata:
    encoder         : Lavf57.56.100
    Stream #1:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 25 fps, 12800
tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.64.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 0 vbv_delay: -1
    Stream #1:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100
Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.64.101 aac
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #0:1 (copy)
  Stream #0:1 -> #1:0 (mpeg2video (native) -> h264 (libx264))
  Stream #0:0 -> #1:1 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
frame=  203 fps= 66 q=-1.0 q=18.0 size=    3848kB time=00:00:08.55
bitrate=3685.3kbits/s dup=16 drop=0 speed=2.78x
frame=  283 fps= 45 q=-1.0 q=19.0 size=    5274kB time=00:00:11.75
bitrate=3675.8kbits/s dup=16 drop=0 speed=1.86x
frame=  359 fps= 38 q=-1.0 q=18.0 size=    6877kB time=00:00:14.79
bitrate=3808.4kbits/s dup=16 drop=0 speed=1.56x
frame=  443 fps= 35 q=-1.0 q=26.0 size=    8492kB time=00:00:18.15
bitrate=3832.2kbits/s dup=16 drop=0 speed=1.43x
frame=  523 fps= 33 q=-1.0 q=19.0 size=    9915kB time=00:00:21.35
bitrate=3803.9kbits/s dup=16 drop=0 speed=1.34x
frame=  599 fps= 31 q=-1.0 q=19.0 size=   11527kB time=00:00:24.39
bitrate=3871.4kbits/s dup=16 drop=0 speed=1.27x
....

frame=31299 fps= 25 q=-1.0 q=23.0 size=  605124kB time=00:20:52.39
bitrate=3958.2kbits/s dup=16 drop=0 speed=   1x
frame=31380 fps= 25 q=-1.0 q=22.0 size=  606664kB time=00:20:55.63
bitrate=3958.0kbits/s dup=16 drop=0 speed=   1x
frame=31459 fps= 25 q=-1.0 q=19.0 size=  608262kB time=00:20:58.79
bitrate=3958.5kbits/s dup=16 drop=0 speed=   1x
frame=31538 fps= 25 q=-1.0 q=23.0 size=  609743kB time=00:21:01.95
bitrate=3958.2kbits/s dup=16 drop=0 speed=   1x
frame=31618 fps= 25 q=-1.0 q=26.0 size=  611281kB time=00:21:05.15
bitrate=3958.1kbits/s dup=16 drop=0 speed=   1x
av_interleaved_write_frame(): Immediate exit requested
[mp4 @ 0x25e0ea0] Starting second pass: moving the moov atom to the
beginning of the file
video:756360kB audio:50360kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown
[libx264 @ 0x25e2560] frame I:1266  Avg QP:18.44  size: 67910
[libx264 @ 0x25e2560] frame P:30369 Avg QP:21.73  size:  4671
[libx264 @ 0x25e2560] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x25e2560] mb P  I16..4:  2.1%  0.0%  0.0%  P16..4: 25.9% 
0.0%  0.0%  0.0%  0.0%    skip:72.0%
[libx264 @ 0x25e2560] coded y,uvDC,uvAC intra: 73.3% 58.6% 45.5% inter:
13.8% 10.5% 2.8%
[libx264 @ 0x25e2560] i16 v,h,dc,p: 36% 45% 10%  9%
[libx264 @ 0x25e2560] i8c dc,h,v,p: 35% 34% 25%  6%
[libx264 @ 0x25e2560] kb/s:1440.32
[aac @ 0x288e6e0] Qavg: 671.586
Conversion failed!
+ echo 'exit with exit code 1'




After record is done a tried to analyze the mp4 file.


ffmpeg -i lores_2017-02-01_19-55-38.ts.mp4
ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (SUSE Linux)
  configuration: --prefix=/home/build/ffmpeg-static/target
--pkg-config-flags=--static
--extra-cflags='-I/home/build/ffmpeg-static/target/include -static'
--extra-ldflags='-L/home/build/ffmpeg-static/target/lib -static'
--bindir=/home/build/ffmpeg-static/bin --disable-ffplay
--disable-ffserver --enable-gpl --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264
--enable-nonfree
  libavutil      55. 34.100 / 55. 34.100
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.100 / 57. 56.100
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x3efdf80] moov atom not found
lores_2017-02-01_19-55-38.ts.mp4: Invalid data found when processing input

mp4info shows

mp4info lores_2017-02-01_19-55-38.ts.mp4
mp4info version -r
lores_2017-02-01_19-55-38.ts.mp4:
ReadChildAtoms: "lores_2017-02-01_19-55-38.ts.mp4": In atom  missing
child atom moov
FindIntegerProperty: no such property - moov.mvhd.modificationTime
(src/mp4file.cpp,746)
mp4info: can't open lores_2017-02-01_19-55-38.ts.mp4



More information about the ffmpeg-user mailing list