Combining -copyts with segmentation gives unexpected results
I try to record an opus stream into segment files while retaining timestamps. But ffmpeg creates a lot of very small files much faster than what I set for -segment_time. Latest ffmpeg version that I tested was 5.1.1. My command is something like ffmpeg -i somestream.opus -c copy -copyts -f segment -segment_time 10 -reset_timestamps 0 -strftime 0 recording-%05d.opus (You can find opus streams at https://dir.xiph.org/codecs/Opus) By the way, is there any advantage in using stream_segment instead of segment here? I noticed that if I increase -segment_time, ffmpeg stops creating very small files after some time and starts to work more like expected. Someone else has had a similar kind of issue with other kind of streams years ago: https://superuser.com/q/800648/490855 Am I doing something wrong or is there a bug in ffmpeg?
On 12/18/2022 2:52 PM, Jarno Suni wrote:
Am I doing something wrong or is there a bug in ffmpeg?
Yes :), not posting the complete command output (it's always necessary when posting question). And please remember to not top-post replies. Later, z!
Ok, here is an example command: $ ffmpeg -i http://volosatoff.ru:8008/euro.opus -c copy -copyts -t 25 -f segment -segment_time 10 -reset_timestamps 0 -strftime 0 recording-%05d.opus Output in terminal: ffmpeg version 4.4.2-1sergeyd9.9~18.04.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04) configuration: --prefix=/usr --extra-version='1sergeyd9.9~18.04.1' --libdir=/usr/lib/i386-linux-gnu --shlibdir=/usr/lib/i386-linux-gnu --incdir=/usr/include/i386-linux-gnu --arch=i386 --enable-gpl --enable-version3 --enable-nonfree --disable-libtesseract --disable-stripping --enable-gnutls --enable-libaom --enable-libass --enable-libbluray --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-frei0r --enable-libx264 --enable-libmfx --enable-ffnvcodec --enable-nvenc --enable-nvdec --ignore-tests='hapenc-hap-none,hapenc-hapa-none,hapenc-hapq-none' --enable-shared libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 [ogg @ 0x9541480] 636 bytes of comment header remain Input #0, ogg, from 'http://volosatoff.ru:8008/euro.opus': Metadata: icy-br : 128 icy-description : EuroDance 90s (Opus 128 kbps) icy-genre : EuroDance icy-name : VOLOSATOE RADIO icy-pub : 1 icy-url : http://fm.spb.ru Duration: N/A, start: 14371671.000000, bitrate: N/A Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp Metadata: ENCODER : opusenc from opus-tools 0.2-3-gf5f571b ENCODER_OPTIONS : --bitrate 128 [segment @ 0x9552e00] Opening 'recording-00000.opus' for writing Output #0, segment, to 'recording-%05d.opus': Metadata: icy-br : 128 icy-description : EuroDance 90s (Opus 128 kbps) icy-genre : EuroDance icy-name : VOLOSATOE RADIO icy-pub : 1 icy-url : http://fm.spb.ru encoder : Lavf58.76.100 Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp Metadata: ENCODER : opusenc from opus-tools 0.2-3-gf5f571b ENCODER_OPTIONS : --bitrate 128 Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help size=N/A time=00:00:00.00 bitrate=N/A speed= 0x video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown It produces one small file, not two 10 s files and one 5 s file or something. If you leave the -t option out, the command produces small (less than 1kB) files fast, not one in 10 s. You can try these by a more fresh ffmpeg executable.
I also tried by ffmpeg version N-109444-geef763c705 and the same thing happened.
I just saw this about Google Magritte "Magritte is an image redaction library to disguise the identity of persons in photos and video streams." "Google announced its machine learning tool called Magritte was going open source. According to information sent to Gizmodo, the tool detects objects inside images or video and automatically applies blur when they appear on screen. Google mentioned the object does not matter, and blur can be applied to, for example, licence plates or tattoos. " https://google.github.io/magritte/ https://www.gizmodo.com.au/2022/12/google-opens-up-tool-to-make-your-private... https://google.github.io/magritte/getting_started/demos.html Do you think it's possible some kind community-minded soul would be motivated enough to develop a Google Magritte based FFmpeg filter ? Or, perhaps, it would be somehow embedded into FFmpeg (which seems unlikely) ? Late Edit: oh, I just noticed it needs mediapipe and OpenCV and "often needs certain files available at runtime (e.g., face detection models)" so I guess the answer is no. Cheers
participants (3)
-
Carl Zwanzig -
hydra3333@gmail.com -
Jarno Suni