Ffmpeg save http h264 stream to mp4 file problem

For the developers that use FFmpeg in their software.
Post Reply
pikwas
Posts: 1
Joined: Tue Dec 18, 2018 11:11 pm

Ffmpeg save http h264 stream to mp4 file problem

Post by pikwas » Tue Dec 18, 2018 11:22 pm

Hello, I have some problems with saving stream from h264 IP encoder to pendrive plugged in usb. My rule is:

fmpeg -fflags discardcorrupt -i http://192.168.11.227:86/main -fs 1500M -acodec copy -vcodec copy -f mp4 /mnt/sda1/$(date +%d_%m_%Y"_"%H_%M_%S).mp4

Problem is that sometimes saved file is broken. It is without moov atoms. Sometimes its ok and can be played. I could fix it with mp4filex and good sample file but I need to find reason why they are somtimes broken. I`m stopping ffmpeg (in linux by ctrl+c) or just by killing process. Here are outputs from AtomicParsley from good and broken files:


I was trying with -moovflags faststart but it wont help and mooving flags takes long time in bigger records.
For my observation there is some weird thing, when I`m running my rule led on pendrive is blinking with long stops. It looks like too big buffer size ? Could it be the reason of loosing moov atoms ?


Bad:

Code: Select all

AtomicParsley 14_12_2018_14_02_24.mp4 -T
Atom ftyp @ 0 of size: 32, ends @ 32
Atom free @ 32 of size: 8, ends @ 40
Atom mdat @ 40 of size: 803942998 (0*), ends @ 803943038
                         (*)denotes length of atom goes to End-of-File
------------------------------------------------------
Total size: 803943038 bytes; 2 atoms total.
Media data: 803942998 bytes; 40 bytes all other atoms (0.000% atom overhead).
Total free atom space: 8 bytes; 0.000% waste. Padding available: 0 bytes.
------------------------------------------------------
AtomicParsley version: 0.9.6 (utf8)
------------------------------------------------------

Good:

Code: Select all

 AtomicParsley 14_11_2018_09_06_38.mp4 -T
Atom ftyp @ 0 of size: 32, ends @ 32
Atom free @ 32 of size: 8, ends @ 40
Atom mdat @ 40 of size: 9916371, ends @ 9916411
Atom moov @ 9916411 of size: 45923, ends @ 9962334
     Atom mvhd @ 9916419 of size: 108, ends @ 9916527
     Atom trak @ 9916527 of size: 12958, ends @ 9929485
         Atom tkhd @ 9916535 of size: 92, ends @ 9916627
         Atom edts @ 9916627 of size: 36, ends @ 9916663
             Atom elst @ 9916635 of size: 28, ends @ 9916663
         Atom mdia @ 9916663 of size: 12822, ends @ 9929485
             Atom mdhd @ 9916671 of size: 32, ends @ 9916703
             Atom hdlr @ 9916703 of size: 45, ends @ 9916748
             Atom minf @ 9916748 of size: 12737, ends @ 9929485
                 Atom vmhd @ 9916756 of size: 20, ends @ 9916776
                 Atom dinf @ 9916776 of size: 36, ends @ 9916812
                     Atom dref @ 9916784 of size: 28, ends @ 9916812
                         Atom url  @ 9916800 of size: 12, ends @ 9916812
                 Atom stbl @ 9916812 of size: 12673, ends @ 9929485
                     Atom stsd @ 9916820 of size: 169, ends @ 9916989
                         Atom avc1 @ 9916836 of size: 153, ends @ 9916989
                             Atom avcC @ 9916922 of size: 51, ends @ 9916973
                             Atom pasp @ 9916973 of size: 16, ends @ 9916989                                                                                            ~
                     Atom stts @ 9916989 of size: 24, ends @ 9917013
                     Atom stss @ 9917013 of size: 32, ends @ 9917045
                     Atom ctts @ 9917045 of size: 4536, ends @ 9921581
                     Atom stsc @ 9921581 of size: 40, ends @ 9921621
                     Atom stsz @ 9921621 of size: 3936, ends @ 9925557
                     Atom stco @ 9925557 of size: 3928, ends @ 9929485
     Atom trak @ 9929485 of size: 32751, ends @ 9962236
         Atom tkhd @ 9929493 of size: 92, ends @ 9929585
         Atom edts @ 9929585 of size: 36, ends @ 9929621
             Atom elst @ 9929593 of size: 28, ends @ 9929621
         Atom mdia @ 9929621 of size: 32615, ends @ 9962236
             Atom mdhd @ 9929629 of size: 32, ends @ 9929661
             Atom hdlr @ 9929661 of size: 45, ends @ 9929706
             Atom minf @ 9929706 of size: 32530, ends @ 9962236
                 Atom smhd @ 9929714 of size: 16, ends @ 9929730
                 Atom dinf @ 9929730 of size: 36, ends @ 9929766
                     Atom dref @ 9929738 of size: 28, ends @ 9929766
                         Atom url  @ 9929754 of size: 12, ends @ 9929766
                 Atom stbl @ 9929766 of size: 32470, ends @ 9962236
                     Atom stsd @ 9929774 of size: 106, ends @ 9929880
                         Atom mp4a @ 9929790 of size: 90, ends @ 9929880
                             Atom esds @ 9929826 of size: 54, ends @ 9929880
                     Atom stts @ 9929880 of size: 12024, ends @ 9941904
                     Atom stsc @ 9941904 of size: 10252, ends @ 9952156
                     Atom stsz @ 9952156 of size: 6152, ends @ 9958308
                     Atom stco @ 9958308 of size: 3928, ends @ 9962236
     Atom udta @ 9962236 of size: 98, ends @ 9962334
         Atom meta @ 9962244 of size: 90, ends @ 9962334
             Atom hdlr @ 9962256 of size: 33, ends @ 9962289
             Atom ilst @ 9962289 of size: 45, ends @ 9962334
                 Atom ©too @ 9962297 of size: 37, ends @ 9962334
                     Atom data @ 9962305 of size: 29, ends @ 9962334

 ~ denotes an unknown atom
------------------------------------------------------
Total size: 9962334 bytes; 53 atoms total.
Media data: 9916371 bytes; 45963 bytes all other atoms (0.461% atom overhead).
Total free atom space: 8 bytes; 0.000% waste.
------------------------------------------------------
AtomicParsley version: 0.9.6 (utf8)
------------------------------------------------------

Post Reply
'