[FFmpeg-user] fault-tolerant streaming and local saving at the same time
Daniel Tisch
tisch.daniel at gmail.com
Fri Dec 2 18:52:32 EET 2016
>
> > 1) Choose some (preferably lossless) codec to use in mpegts
> > instead of raw data.
>
> FFmpeg contains its own lossless codec, ffv1.
>
mpegts does not support ffv1 either. ffmpeg can write ffv1 to mpegts
without warning (just like for yuv), but can not read that back.
user at host:~$ tools/ffmpeg/ffmpeg -i ~/Videos/Moments_of_Everyday_Life.mp4
-an -vcodec ffv1 -f mpegts Videos/test.ts
ffmpeg version N-82721-g89092fa Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-gpl --enable-version3 --enable-nonfree
--enable-openssl --enable-avresample --enable-avisynth --enable-libmp3lame
--enable-libpulse --disable-librtmp --enable-libtheora --enable-libvorbis
--enable-libx264
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.108 / 57. 66.108
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libavresample 3. 2. 0 / 3. 2. 0
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'/home/dani/Videos/Moments_of_Everyday_Life.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2012-03-13T03:50:30.000000Z
Duration: 00:01:07.94, start: 0.000000, bitrate: 7994 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1280x720 [SAR 1:1 DAR 16:9], 7804 kb/s, 23.98 fps, 23.98 tbr, 23976
tbn, 47.95 tbc (default)
Metadata:
creation_time : 2012-03-13T03:50:30.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2012-03-13T03:50:30.000000Z
handler_name : Mainconcept MP4 Sound Media Handler
Output #0, mpegts, to 'Videos/test.ts':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf57.58.101
Stream #0:0(eng): Video: ffv1, yuv420p, 1280x720 [SAR 1:1 DAR 16:9],
q=2-31, 200 kb/s, 23.98 fps, 90k tbn, 23.98 tbc (default)
Metadata:
creation_time : 2012-03-13T03:50:30.000000Z
handler_name : Mainconcept MP4 Video Media Handler
encoder : Lavc57.66.108 ffv1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> ffv1 (native))
Press [q] to stop, [?] for help
frame= 1627 fps= 95 q=-0.0 Lsize= 424439kB time=00:01:07.81
bitrate=51269.8kbits/s speed=3.97x
video:393553kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 7.848062%
user at host:~$ tools/ffmpeg/ffmpeg -i Videos/test.ts -vcodec mpeg4 -y
Videos/output.flv
ffmpeg version N-82721-g89092fa Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-gpl --enable-version3 --enable-nonfree
--enable-openssl --enable-avresample --enable-avisynth --enable-libmp3lame
--enable-libpulse --disable-librtmp --enable-libtheora --enable-libvorbis
--enable-libx264
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.108 / 57. 66.108
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libavresample 3. 2. 0 / 3. 2. 0
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mpegts, from 'Videos/test.ts':
Duration: 00:01:07.82, start: 1.400000, bitrate: 51269 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Data: bin_data ([6][0][0][0] / 0x0006)
Output #0, flv, to 'Videos/output.flv':
Output file #0 does not contain any stream
Adding "-vcodec ffv1" before -i produces the same output.
> > 2) Choose some other muxer instead of mpegts.
>
> mkv does have a live option but it is not really suitable
> for rawvideo either.
>
I can not found any matroska related live option (or similar).
After all I tried to go for mpegts with lossless H.264 for the video and
high bitrate AAC for the audio, as there seem not to be any lossless audio
alternative, that is compatible with mpegts.
However, now I get the following errors on the receiving side. I am not
sure, but guessing that this might come from lost UDP packets?
user at host:~$ tools/ffmpeg/ffmpeg -f mpegts -i udp://127.0.0.1:20000 -acodec
mp3 -vcodec flv -y Videos/output.flv
ffmpeg version N-82721-g89092fa Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-gpl --enable-version3 --enable-nonfree
--enable-openssl --enable-avresample --enable-avisynth --enable-libmp3lame
--enable-libpulse --disable-librtmp --enable-libtheora --enable-libvorbis
--enable-libx264
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.108 / 57. 66.108
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libavresample 3. 2. 0 / 3. 2. 0
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mpegts, from 'udp://127.0.0.1:20000':
Duration: N/A, start: 1.460200, bitrate: N/A
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr,
90k tbn, 47.95 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F),
44100 Hz, stereo, fltp, 320 kb/s
Output #0, flv, to 'Videos/output.flv':
Metadata:
encoder : Lavf57.58.101
Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p,
1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 1k tbn, 23.98 tbc
Metadata:
encoder : Lavc57.66.108 flv
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002),
44100 Hz, stereo, fltp
Metadata:
encoder : Lavc57.66.108 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[h264 @ 0x345d140] Invalid NAL unit 0, skipping.00:00:03.34
bitrate=2394.3kbits/s speed=6.58x
[h264 @ 0x345d140] error while decoding MB 69 42, bytestream -15
[h264 @ 0x345d140] concealing 220 DC, 220 AC, 220 MV errors in I frame
[h264 @ 0x2e11c60] Invalid NAL unit 8, skipping.00:00:18.12
bitrate=1671.9kbits/s speed=1.28x
[h264 @ 0x2e11c60] error while decoding MB 4 41, bytestream -13
[h264 @ 0x2e11c60] Cannot use next picture in error concealment
[h264 @ 0x2e11c60] concealing 365 DC, 365 AC, 365 MV errors in P frame
[h264 @ 0x332f0c0] Invalid NAL unit 8, skipping.00:00:18.60
bitrate=1660.1kbits/s speed=1.27x
[h264 @ 0x332f0c0] error while decoding MB 59 42, bytestream -33
[h264 @ 0x332f0c0] concealing 230 DC, 230 AC, 230 MV errors in P frame
[h264 @ 0x332b8a0] Invalid NAL unit 8, skipping.00:00:20.14
bitrate=1637.0kbits/s speed=1.24x
[h264 @ 0x332b8a0] error while decoding MB 3 44, bytestream -9
[h264 @ 0x332b8a0] concealing 126 DC, 126 AC, 126 MV errors in P frame
frame= 677 fps= 28 q=31.0 Lsize= 5113kB time=00:00:28.59
bitrate=1464.6kbits/s speed=1.16x
video:4642kB audio:443kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.547867%
I am lost at this point. If it is really caused by lost UDP packets and not
by some unlikely misconfiguration, then I really do not know, how to
achieve reliable parallel streaming and local saving.
Any ideas?
Thanks,
Daniel
More information about the ffmpeg-user
mailing list