我尝试使用以下代码将 UDP 流(由DVB信号生成)转换为 HLS m3u8文件:
ffmpeg -i udp://239.1.2.1:60001 -acodec aac -strict -2 -vcodec libx264 -hls_wrap 100 -f hls /var/www/html/ts/1.m3u8
UDP流包含1个通道(在本例中为IRIB-TV1)。
当我运行此代码时,ffmpeg会检测从DVB卡流式传输的所有服务和频道:
Input #0, mpegts, from 'udp://239.1.2.1:60001':
Duration: N/A, start: 77906.812644, bitrate: N/A
Program 101
Metadata:
service_name : IRIB-TV1
service_provider: IRIB
Stream #0:0[0x3f2]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x3f3](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 102
Metadata:
service_name : IRIB-TV2
service_provider: IRIB
Program 103
Metadata:
service_name : IRIB-TV3
service_provider: IRIB
Program 104
Metadata:
service_name : IRIB-TV4
service_provider: IRIB
正如您在UDP流中看到ffmpeg finf 4频道,但VLC只播放频道1(IRIB-TV1)。
现在我有2个问题:
1 - 我可以通过此ffmpeg代码获取所有频道和服务吗?
2 - 我可以从这个ffmpeg代码中选择一个特殊的流吗?(我知道ffmpeg可以选择一个带有 -map otion的流,但我想选择输出日志中的其他service_name)
输出文件:
ffmpeg version 2.4.3-1ubuntu1~trusty6 Copyright (c) 2000-2014 the FFmpeg developers
built on Nov 22 2014 17:07:19 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/usr --extra-version='1ubuntu1~trusty6' --build-suffix=-ffmpeg --toolchain=hardened --extra-cflags= --extra-cxxflags= --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-fontconfig --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-opengl --enable-x11grab --enable-libxvid --enable-libx265 --enable-libdc1394 --enable-libiec61883 --enable-libzvbi --enable-libzmq --enable-frei0r --enable-libx264 --enable-libsoxr --enable-openal --enable-libopencv
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-timeout' ... matched as AVOption 'timeout' with argument '6000000'.
Reading option '-i' ... matched as input file with argument 'udp://239.1.2.1:60001?fifo_size=50000'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'copy'.
Reading option '-preset' ... matched as AVOption 'preset' with argument 'ultrafast'.
Reading option '-flags' ... matched as AVOption 'flags' with argument '-global_header'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'hls'.
Reading option '-hls_time' ... matched as AVOption 'hls_time' with argument '20'.
Reading option '-hls_wrap' ... matched as AVOption 'hls_wrap' with argument '5'.
Reading option '/var/www/html/ts/1.m3u8' ... 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 udp://239.1.2.1:60001?fifo_size=50000.
Successfully parsed a group of options.
Opening an input file: udp://239.1.2.1:60001?fifo_size=50000.
[udp @ 0x1967040] end receive buffer size reported is 131072
[mpegts @ 0x1977380] Format mpegts probed with size=2048 and score=100
[mpegts @ 0x1977380] stream=0 stream_type=1b pid=3f2 prog_reg_desc=
[mpegts @ 0x1977380] stream=1 stream_type=11 pid=3f3 prog_reg_desc=
[mpegts @ 0x1977380] Before avformat_find_stream_info() pos: 0 bytes read:14476 seeks:0
[mpegts @ 0x1977380] parser not found for codec none, packets or times may be invalid.
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[mpegts @ 0x1977380] probing stream 1 pp:2500
[mpegts @ 0x1977380] Probe with size=853, packets=1 detected loas with score=51
[mpegts @ 0x1977380] probed stream 1
[aac_latm @ 0x199e4e0] initializing latmctx
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0x199cc60] decode_slice_header error
[h264 @ 0x199cc60] no frame!
[h264 @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[h264 @ 0x199cc60] Frame num gap 397 393
[h264 @ 0x199cc60] Frame num gap 397 394
[h264 @ 0x199cc60] Frame num gap 397 395
[h264 @ 0x199cc60] mmco: unref short failure
Last message repeated 1 times
[h264 @ 0x199cc60] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0x199cc60] no picture ooo
[h264 @ 0x199cc60] Increasing reorder buffer to 2
[h264 @ 0x199cc60] no picture ooo
Last message repeated 1 times
[h264 @ 0x199cc60] no picture
Last message repeated 1 times
[h264 @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
Last message repeated 3 times
[mpegts @ 0x1977380] max_analyze_duration 5000000 reached at 5034667 microseconds
[mpegts @ 0x1977380] After avformat_find_stream_info() pos: 1142476 bytes read:1143604 seeks:0 frames:397
Input #0, mpegts, from 'udp://239.1.2.1:60001?fifo_size=50000':
Duration: N/A, start: 43581.024200, bitrate: N/A
Program 101
Metadata:
service_name : IRIB-TV1
service_provider: IRIB
Stream #0:0[0x3f2], 274, 1/90000: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 1/50, 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x3f3](per), 123, 1/90000: Audio: aac_latm ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
Program 102
Metadata:
service_name : IRIB-TV2
service_provider: IRIB
Program 103
Metadata:
service_name : IRIB-TV3
service_provider: IRIB
Program 104
Metadata:
service_name : IRIB-TV4
service_provider: IRIB
Program 105
Metadata:
service_name : IRIB-TV5
service_provider: IRIB
Program 106
Metadata:
service_name : IRINN
service_provider: IRIB
Program 107
Metadata:
service_name : AMOOZESH
service_provider: IRIB
Program 108
Metadata:
service_name : QURAN
service_provider: IRIB
Program 119
Metadata:
service_name : SALAMAT
service_provider: IRIB
Program 120
Metadata:
service_name : NASIM
service_provider: IRIB
Program 151
Metadata:
service_name : RADIO IRAN
service_provider: IRIB
Program 152
Metadata:
service_name : RADIO PAYAM
service_provider: IRIB
Program 153
Metadata:
service_name : RADIO JAVAN
service_provider: IRIB
Program 154
Metadata:
service_name : RADIO MAAREF
service_provider: IRIB
Program 155
Metadata:
service_name : RADIO QURAN
service_provider: IRIB
Program 156
Metadata:
service_name : RADIO FARHANG
service_provider: IRIB
Program 157
Metadata:
service_name : RADIO SALAMAT
service_provider: IRIB
Program 158
Metadata:
service_name : RADIO VARZESH
service_provider: IRIB
Program 159
Metadata:
service_name : RADIO EGHTESAD
service_provider: IRIB
Program 160
Metadata:
service_name : RADIO TEHRAN
service_provider: IRIB
Program 161
Metadata:
service_name : RADIO AVAA
service_provider: IRIB
Program 162
Metadata:
service_name : RADIO NAMAYESH
service_provider: IRIB
Program 163
Metadata:
service_name : RADIO SABA
service_provider: IRIB
Program 164
Metadata:
service_name : English Radio World Service
service_provider: IRIB
Program 166
Metadata:
service_name : Arabic Radio World Service
service_provider: IRIB
Program 167
Metadata:
service_name : RADIO BAHARAN
service_provider: IRIB
Program 169
Metadata:
service_name : RADIO TELAVAT
service_provider: IRIB
Program 170
Metadata:
service_name : RADIO GOFTEGO
service_provider: IRIB
Successfully opened the file.
Parsing a group of options: output file /var/www/html/ts/1.m3u8.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument copy.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument copy.
Applying option f (force format) with argument hls.
Successfully parsed a group of options.
Opening an output file: /var/www/html/ts/1.m3u8.
Successfully opened the file.
[mpegts @ 0x1967180] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Last message repeated 1 times
[mpegts @ 0x1967180] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, hls, to '/var/www/html/ts/1.m3u8':
Metadata:
encoder : Lavf56.4.101
Stream #0:0, 0, 1/90000: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 720x576 [SAR 12:11 DAR 15:11], 1/25, q=2-31, 25 fps, 90k tbn, 25 tbc
Stream #0:1(per), 0, 1/90000: Audio: aac_latm ([17][0][0][0] / 0x0011), 48000 Hz, stereo
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[NULL @ 0x199cc60] Current profile doesn't provide more RBSP data in PPS, skipping
[AVIOContext @ 0x19a9860] Statistics: 0 seeks, 896 writeouts=N/A
[hls @ 0x1a65ca0] EXT-X-MEDIA-SEQUENCE:0
[AVIOContext @ 0x1d162e0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0x1966b40] Statistics: 0 seeks, 27 writeouts
[hls @ 0x1a65ca0] EXT-X-MEDIA-SEQUENCE:0
[AVIOContext @ 0x199b7a0] Statistics: 0 seeks, 1 writeouts
frame= 826 fps= 69 q=-1.0 Lsize=N/A time=00:00:20.63 bitrate=N/A
video:2611kB audio:68kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (udp://239.1.2.1:60001?fifo_size=50000):
Input stream #0:0 (video): 872 packets read (2779202 bytes);
Input stream #0:1 (audio): 405 packets read (69222 bytes);
Total: 1277 packets (2848424 bytes) demuxed
Output file #0 (/var/www/html/ts/1.m3u8):
Output stream #0:0 (video): 826 packets muxed (2673485 bytes);
Output stream #0:1 (audio): 405 packets muxed (69222 bytes);
Total: 1231 packets (2742707 bytes) muxed
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x1967ce0] Statistics: 3884832 bytes read, 0 seeks
Received signal 2: terminating.
答案 0 :(得分:2)
根据docs(示例8)的语法是
ffmpeg -i udp://239.1.2.1:60001 -map 0:p:102 -acodec aac -strict -2 -vcodec libx264 -hls_wrap 100 -f hls /var/www/html/ts/1.m3u8
但是我没有看到101之后为程序声明的任何流,所以请检查它们是否可用。