Using ffmpeg to convert stream with delayed audio stream

0

I am trying to use ffmpeg to convert this TS stream file to MP4. Note how there is no audio until around the 10-second mark. Whenever I try to convert (or copy) this TS file, I get no audio. I suspect this is because ffmpeg can't find an audio stream at the start of the file, but how do I get it to find the audio that begins later on?

For example, this is the output when I run this line ffmpeg -i beinold.ts -vf scale=1280:720 bein.mp4. I added the scale because otherwise, ffmpeg would return the whole MP4 as 270p, which is the resolution of the first few seconds. Note the lack of errors. Even running with -analyzeduration 15000000 does not work.

ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[mpegts @ 0x7fe58e801200] PES packet size mismatch
    Last message repeated 1 times
[mpegts @ 0x7fe58e801200] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[mpegts @ 0x7fe58e801200] Could not find codec parameters for stream 2 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'beinold.ts':
  Duration: 00:00:50.05, start: 0.466722, bitrate: 3065 kb/s
  Program 1 
    Metadata:
      service_name    : 
      service_provider: 
    Stream #0:0[0x64]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 480x270 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc
    Stream #0:1[0xc8](eng): Audio: aac ([15][0][0][0] / 0x000F), 0 channels
    Stream #0:2[0xc9](spa): Audio: aac ([15][0][0][0] / 0x000F), 0 channels
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fe58f000c00] using SAR=1/1
[libx264 @ 0x7fe58f000c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x7fe58f000c00] profile High, level 3.1
[libx264 @ 0x7fe58f000c00] 264 - core 148 r2795 aaa9aa8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 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
Output #0, mp4, to 'bein.mp4':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[h264 @ 0x7fe58e07c600] Increasing reorder buffer to 107.87 bitrate=3195.9kbits/s speed=1.34x     
[h264 @ 0x7fe58f800000] Increasing reorder buffer to 2
frame= 1500 fps= 31 q=-1.0 Lsize=   25728kB time=00:00:49.94 bitrate=4219.6kbits/s dup=7 drop=0 speed=1.04x    
video:25708kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.078066%
[libx264 @ 0x7fe58f000c00] frame I:7     Avg QP:22.72  size: 96187
[libx264 @ 0x7fe58f000c00] frame P:398   Avg QP:25.43  size: 37357
[libx264 @ 0x7fe58f000c00] frame B:1095  Avg QP:29.51  size:  9848
[libx264 @ 0x7fe58f000c00] consecutive B-frames:  0.7%  4.3%  5.2% 89.9%
[libx264 @ 0x7fe58f000c00] mb I  I16..4:  8.9% 54.3% 36.8%
[libx264 @ 0x7fe58f000c00] mb P  I16..4:  3.1% 10.7%  4.1%  P16..4: 35.4% 23.6% 12.2%  0.0%  0.0%    skip:11.0%
[libx264 @ 0x7fe58f000c00] mb B  I16..4:  0.2%  0.5%  0.2%  B16..8: 39.2% 10.9%  2.9%  direct: 4.9%  skip:41.1%  L0:40.6% L1:49.6% BI: 9.8%
[libx264 @ 0x7fe58f000c00] 8x8 transform intra:58.3% inter:57.1%
[libx264 @ 0x7fe58f000c00] coded y,uvDC,uvAC intra: 71.3% 67.7% 37.4% inter: 21.0% 18.7% 1.9%
[libx264 @ 0x7fe58f000c00] i16 v,h,dc,p: 13% 51% 10% 26%
[libx264 @ 0x7fe58f000c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 28% 17%  5%  6%  6%  8%  6%  8%
[libx264 @ 0x7fe58f000c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 28% 17%  5%  7%  7%  7%  5%  6%
[libx264 @ 0x7fe58f000c00] i8c dc,h,v,p: 46% 27% 18%  9%
[libx264 @ 0x7fe58f000c00] Weighted P-Frames: Y:0.3% UV:0.3%
[libx264 @ 0x7fe58f000c00] ref P L0: 61.9% 14.4% 17.9%  5.8%  0.0%
[libx264 @ 0x7fe58f000c00] ref B L0: 93.8%  5.2%  1.0%
[libx264 @ 0x7fe58f000c00] ref B L1: 97.5%  2.5%
[libx264 @ 0x7fe58f000c00] kb/s:4207.72

Ike348

Posted 2018-01-30T05:05:00.850

Reputation: 3

Answers

0

This works here:

ffmpeg -analyzeduration 15M -i beinold.ts -c copy bein.mp4

Audio starts around 9s. Resolution is preserved i.e. if the player supports decoder reinit, then you should see switch in resolution when that happens in the stream. VLC does, as does Potplayer (Windows).

Gyan

Posted 2018-01-30T05:05:00.850

Reputation: 21 016

Looks like I just needed a 15M. I found ffmpeg -analyzeduration 15M -i beinold.ts -ss 10 -acodec copy -vf scale=1280:720 bein.mp4 does what I prefer, as I don't want any resolution switch, and I could do without the 10 seconds at 270p and no audio. There doesn't seem to be a way to get rid of resolution switch without re-encoding, but oh well. All that goes beyond the question though, and this answers the question at hand. Thanks so much! – Ike348 – 2018-01-30T07:07:36.603

If you copy to a TS first and then remux that to MP4, you should be able to skip the 270p. – Gyan – 2018-01-30T07:55:11.790

0

Try winff video converter (graphical utility) to make this process easier.. It works fine there..

Drakonoved

Posted 2018-01-30T05:05:00.850

Reputation: 314