Hello, I’m new to this mailing list, so please let me know, if I’m at the wrong 
place to pose this question. 
As it might lead to modifying the source-code, I was wondering to pose it at 
ffmpeg-devel instead but decided for this mailing-group first …
 
Following problem:
When I transcode a long mp2 (for example one with 04:03:07.22, i.e. more than 4 
hours) 
to mp3 with a transcoding starting point close to the end (-ss 04:00:00) then 
it takes ffmpeg 
(depending on the disk and processor of course) on my machine almost 4 seconds 
to start the transcoding process. 
The server where I actually want to run it, seems to have slower disk and/or 
processor and has delays up to 18 seconds! 
The transcoding itself is fast with around 35x speed. But the delay at the 
beginning is a real problem for streaming.
If the transcoding start is at the beginning (i.e. dropping the '-ss' option), 
then there is no delay and the transcoding starts immediately.
The delays seem to be specific to the mp2-format. For a transcoding from e.g. 
the wma - format to mp3, there is no noticeable delay.
It seems that the decoder is somehow running through the whole file to 
determine the correct timestamp to start the transcoding from. 
So my question is, is there anything one can do about it? I might even be 
willing to try improving the source code on this matter 
(if I understand it and modulo the fact that I’m not very familiar with c), 
or is there no point in trying to improve it, because the delay is due to the 
mp2-format itself? 
(I.e. maybe there are no timecodes stored with the frames, and one has to count 
the packages to determine the timecode, or something like that?)

In the following is my command-line input and the output in debug-loglevel. The 
delay happens right after the lines:
"[mp3 @ 0x7fe2fc001400] Estimating duration from bitrate, this may be inaccurate
[mp3 @ 0x7fe2fc001400] After avformat_find_stream_info() pos: 58368 bytes 
read:98432 seeks:2 frames:50  "
and before the lines
"Input #0, mp3, from 'M0495978.MP2':
  Duration: 04:03:07.22, start: 0.000000, bitrate: 384 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
Successfully opened the file. „

The complete input/output:
ffmpeg  -ss 4:0:0 -i M0495978.MP2 -loglevel debug testLocal.mp3

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
  built with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads 
--enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx 
--enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 
--enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb 
--enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 
--disable-doc --arch=x86_64 --enable-runtime-cpudetect
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-ss' ... matched as option 'ss' (set the start time offset) 
with argument '4:0:0'.
Reading option '-i' ... matched as input file with argument 'M0495978.MP2'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) 
with argument 'debug'.
Reading option 'testLocal.mp3' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file M0495978.MP2.
Applying option ss (set the start time offset) with argument 4:0:0.
Successfully parsed a group of options.
Opening an input file: M0495978.MP2.
[file @ 0x7fdfb57067a0] Setting default whitelist 'file,crypto'
[mp3 @ 0x7fdfb6000a00] Format mp3 probed with size=8192 and score=51
[mp3 @ 0x7fdfb6000a00] Skipping 0 bytes of junk at 0.
[mp3 @ 0x7fdfb6000a00] Before avformat_find_stream_info() pos: 0 bytes 
read:65664 seeks:2
[mp3 @ 0x7fdfb6000a00] All info found
[mp3 @ 0x7fdfb6000a00] Estimating duration from bitrate, this may be inaccurate
[mp3 @ 0x7fdfb6000a00] After avformat_find_stream_info() pos: 58368 bytes 
read:98432 seeks:2 frames:50

Input #0, mp3, from 'M0495978.MP2':
  Duration: 04:03:07.22, start: 0.000000, bitrate: 384 kb/s
    Stream #0:0, 50, 1/14112000: Audio: mp2, 48000 Hz, stereo, s16p, 384 kb/s
Successfully opened the file.
Parsing a group of options: output file testLocal.mp3.
Successfully parsed a group of options.
Opening an output file: testLocal.mp3.
[file @ 0x7fdfb5707740] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 0:0 @ 0x7fdfb5500460] Setting 'time_base' to value 
'1/48000'
[graph 0 input from stream 0:0 @ 0x7fdfb5500460] Setting 'sample_rate' to value 
'48000'
[graph 0 input from stream 0:0 @ 0x7fdfb5500460] Setting 'sample_fmt' to value 
's16p'
[graph 0 input from stream 0:0 @ 0x7fdfb5500460] Setting 'channel_layout' to 
value '0x3'
[graph 0 input from stream 0:0 @ 0x7fdfb5500460] tb:1/48000 samplefmt:s16p 
samplerate:48000 chlayout:0x3
[audio format for output stream 0:0 @ 0x7fdfb5500d00] Setting 'sample_fmts' to 
value 's32p|fltp|s16p'
[audio format for output stream 0:0 @ 0x7fdfb5500d00] Setting 'sample_rates' to 
value '44100|48000|32000|22050|24000|16000|11025|12000|8000'
[audio format for output stream 0:0 @ 0x7fdfb5500d00] Setting 'channel_layouts' 
to value '0x4|0x3'
[AVFilterGraph @ 0x7fdfb5706520] query_formats: 5 queried, 12 merged, 0 already 
done, 0 delayed
Output #0, mp3, to 'testLocal.mp3':
  Metadata:
    TSSE            : Lavf57.25.100
    Stream #0:0, 0, 1/48000: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p
    Metadata:
      encoder         : Lavc57.24.102 libmp3lame
Stream mapping:
  Stream #0:0 -> #0:0 (mp2 (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
    Last message repeated 2 times
[output stream 0:0 @ 0x7fdfb5500b40] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
[libmp3lame @ 0x7fdfb600b600] Trying to remove 47 more samples than there are 
in the queue
size=    2926kB time=00:03:07.22 bitrate= 128.0kbits/s speed=35.9x    
video:0kB audio:2926kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 0.007911%
Input file #0 (M0495978.MP2):
  Input stream #0:0 (audio): 7801 packets read (8986752 bytes); 7801 frames 
decoded (8986752 samples); 
  Total: 7801 packets (8986752 bytes) demuxed
Output file #0 (testLocal.mp3):
  Output stream #0:0 (audio): 7801 frames encoded (8986752 samples); 7802 
packets muxed (2995968 bytes); 
  Total: 7802 packets (2995968 bytes) muxed
7801 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7fdfb57077a0] Statistics: 1 seeks, 7804 writeouts
[AVIOContext @ 0x7fdfb5706860] Statistics: 700285184 bytes read, 3 seeks
_______________________________________________
Libav-user mailing list
Libav-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to