FFmpeg konvertiert G.711-Audio in AAC-Audio

Ist es überhaupt möglich, G.711-Audio in einem Stream mit ffmpeg in AAC-Audio zu konvertieren? Meine Kamera streamt problemlos in Chrome (Video + Audio), aber alle anderen Browser haben kein Audio. Ich würde mich über jede Hilfe / Input / Vorschläge / Kommentare freuen. Vielen Dank im Voraus!

Hier ist der Code:

ffmpeg -rtsp_transport tcp -i rtsp://login:password@1.1.1.1:554/11 -map 0 -c:v copy -c:a copy -f 
segment -segment_list /usr/local/nginx/html/hls/mystream.m3u8 -segment_list_type hls - 
segment_list_size 10 -segment_list_flags +live /usr/local/nginx/html/hls/mystream%01d.ts

Ich habe natürlich schon einmal versucht, -c:a aac dort einzufügen, aber es hilft nicht.

Es gibt Millionen von Online-Tutorials und Beispielen zum Konvertieren einer Datei. Aber in meinem Fall ist es keine Datei, sondern ein Live-Stream. Übersehe ich hier etwas? Muss ich meine endgültige Ausgabedatei namens mystream.m3u8 vielleicht irgendwie konvertieren?

PS Derzeit streamt meine Kamera in libx264 für Video und G.711 für Audio, aber ich kann sie leicht ändern, um in libx265 für Video und G.726 für Audio zu streamen, sollte dies hilfreich sein, um sowohl Video als auch Audio abzuspielen. Dies sind die einzigen beiden Optionen, die in meiner Kamera verfügbar sind, und ich kann sie nicht auf etwas anderes einstellen.

PSS: Hier ist das kopierte Protokoll, Gyan. Ich bin mir aber nicht sicher, ob das hilft. Ich sehe da nichts Ungewöhnliches. Können Sie sagen, was falsch ist?

ffmpeg started on 2020-04-08 at 04:54:52
Report written to "ffmpeg-20200408-045452.log"
Command line:
ffmpeg -rtsp_transport tcp -i rtsp://login:pass@1.1.1.1:1/111 -map 0 -c:v copy -c:a aac -f segment -segment_list /usr/local/nginx/html/hls/mystream.m3u8 -segment_list_type hls -segment_list_size 10 -segment_list_flags +live "/usr/local/nginx/html/hls/mystream%01d.ts" -loglevel verbose -report -t 30
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --en  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Splitting the commandline.
Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-i' ... matched as input url with argument 'rtsp://login:pass@1.1.1.1:554/111'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'aac'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'segment'.
Reading option '-segment_list' ... matched as AVOption 'segment_list' with argument '/usr/local/nginx/html/hls/mystream.m3u8'.
Reading option '-segment_list_type' ... matched as AVOption 'segment_list_type' with argument 'hls'.
Reading option '-segment_list_size' ... matched as AVOption 'segment_list_size' with argument '10'.
Reading option '-segment_list_flags' ... matched as AVOption 'segment_list_flags' with argument '+live'.
Reading option '/usr/local/nginx/html/hls/mystream%01d.ts' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'verbose'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '30'.
Trailing options were found on the commandline.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument verbose.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://login:pass@1.1.1.1:554/111.
Successfully parsed a group of options.
Opening an input file: rtsp://login:pass@1.1.1.1:554/111.
[tcp @ 0x564b593fe780] No default whitelist set
[tcp @ 0x564b593fe780] Original list of addresses:
[tcp @ 0x564b593fe780] Address 8.2.1.11 port 554
[tcp @ 0x564b593fe780] Interleaved list of addresses:
[tcp @ 0x564b593fe780] Address 8.2.1.1 port 554
[tcp @ 0x564b593fe780] Starting connection attempt to 8.2.1.1 port 554
[tcp @ 0x564b593fe780] Successfully connected to 8.2.1.1 port 554
[rtsp @ 0x564b593fc540] SDP:
v=0
o=StreamingServer 3331435948 1116907222000 IN IP4 192.168.0.199
s=10
c=IN IP4 0.0.0.0
t=0 0
a=control:*
m=video 0 RTP/AVP 96
a=control:trackID=0
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42002A;sprop-parameter-sets=Z0IAKpY1QPAET8s3AQEBAg==,aM48gA==
a=framesize:96 1920-1080
m=audio 0 RTP/AVP 8
a=control:trackID=1
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=fmtp:8 packetization-mode=1

[rtsp @ 0x564b593fc540] video codec set to: h264
[rtsp @ 0x564b593fc540] RTP Packetization Mode: 1
[rtsp @ 0x564b593fc540] RTP Profile IDC: 42 Profile IOP: 0 Level: 2a
[rtsp @ 0x564b593fc540] Extradata set to 0x564b594005f0 (size: 28)
[rtsp @ 0x564b593fc540] audio codec set to: pcm_alaw
[rtsp @ 0x564b593fc540] audio samplerate set to: 8000
[rtsp @ 0x564b593fc540] audio channels set to: 1
[rtsp @ 0x564b593fc540] setting jitter buffer size to 0
[rtsp @ 0x564b593fc540] setting jitter buffer size to 0
[rtsp @ 0x564b593fc540] hello state=0
[h264 @ 0x564b59400100] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] unknown SEI type 229
[h264 @ 0x564b59400100] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x564b59400100] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x564b59400100] unknown SEI type 229
[h264 @ 0x564b59400100] Format yuvj420p chosen by get_format().
[h264 @ 0x564b59400100] Reinit context to 1920x1088, pix_fmt: yuvj420p
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x564b59400100] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[rtsp @ 0x564b593fc540] All info found
[rtsp @ 0x564b593fc540] rfps: 29.500000 0.018596
[rtsp @ 0x564b593fc540] rfps: 29.583333 0.012613
[rtsp @ 0x564b593fc540] rfps: 29.666667 0.007793
[rtsp @ 0x564b593fc540] rfps: 29.666667 0.007793
[rtsp @ 0x564b593fc540] rfps: 29.750000 0.004137
[rtsp @ 0x564b593fc540] rfps: 29.750000 0.004137
[rtsp @ 0x564b593fc540] rfps: 29.833333 0.001644
[rtsp @ 0x564b593fc540] rfps: 29.833333 0.001644
[rtsp @ 0x564b593fc540] rfps: 29.916667 0.000314
[rtsp @ 0x564b593fc540] rfps: 29.916667 0.000314
[rtsp @ 0x564b593fc540] rfps: 30.000000 0.000149
[rtsp @ 0x564b593fc540] rfps: 60.000000 0.000595
[rtsp @ 0x564b593fc540] rfps: 120.000000 0.002380
[rtsp @ 0x564b593fc540] rfps: 240.000000 0.009520
[rtsp @ 0x564b593fc540] rfps: 29.970030 0.000074
[rtsp @ 0x564b593fc540] rfps: 59.940060 0.000297
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://login:pass@1.1.1.1:554/111':
  Metadata:
    title           : 10
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 28, 1/90000: Video: h264 (Baseline), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1920x1080 (1920x1088), 29.97 tbr, 90k tbn, 180k tbc
    Stream #0:1, 72, 1/8000: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Successfully opened the file.
Parsing a group of options: output url /usr/local/nginx/html/hls/mystream%01d.ts.
Applying option map (set input stream mapping) with argument 0.
Applying option c:v (codec name) with argument copy.
Applying option c:a (codec name) with argument aac.
Applying option f (force format) with argument segment.
Successfully parsed a group of options.
Opening an output file: /usr/local/nginx/html/hls/mystream%01d.ts.
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
detected 2 logical cores
[graph_0_in_0_1 @ 0x564b59439cc0] Setting 'time_base' to value '1/8000'
[graph_0_in_0_1 @ 0x564b59439cc0] Setting 'sample_rate' to value '8000'
[graph_0_in_0_1 @ 0x564b59439cc0] Setting 'sample_fmt' to value 's16'
[graph_0_in_0_1 @ 0x564b59439cc0] Setting 'channel_layout' to value '0x4'
[graph_0_in_0_1 @ 0x564b59439cc0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0x564b5943b040] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x564b5943b040] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[format_out_0_1 @ 0x564b5943b040] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[AVFilterGraph @ 0x564b5941e880] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto_resampler_0 @ 0x564b5957eb40] [SWR @ 0x564b59507740] Using s16p internally between filters
[auto_resampler_0 @ 0x564b5957eb40] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:fltp r:8000Hz
[aac @ 0x564b594200c0] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[segment @ 0x564b59403b80] Selected stream id:0 type:video
[segment @ 0x564b59403b80] Opening '/usr/local/nginx/html/hls/mystream0.ts' for writing
[file @ 0x564b59580b40] Setting default whitelist 'file,crypto'
[mpegts @ 0x564b59580480] muxrate VBR, pcr every 9000 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, segment, to '/usr/local/nginx/html/hls/mystream%01d.ts':
  Metadata:
    title           : 10
    encoder         : Lavf58.20.100
    Stream #0:0, 0, 1/90000: Video: h264 (Baseline), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1920x1080 (0x0), q=2-31, 29.97 tbr, 90k tbn, 90k tbc
    Stream #0:1, 0, 1/90000: Audio: aac (LC), 8000 Hz, mono, fltp, delay 1024, 48 kb/s
    Metadata:
      encoder         : Lavc58.35.100 aac
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[segment @ 0x564b59403b80] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[segment @ 0x564b59403b80] segment:'/usr/local/nginx/html/hls/mystream0.ts' starts with packet stream:1 pts:0 pts_time:0 frame:0
[segment @ 0x564b59403b80] stream:1 start_pts_time:0 pts:0 pts_time:0 dts:0 dts_time:0 -> pts:0 pts_time:0 dts:0 dts_time:0
[segment @ 0x564b59403b80] segment:'/usr/local/nginx/html/hls/mystream0.ts' starts with packet stream:0 pts:11520 pts_time:0.128 frame:0
[segment @ 0x564b59403b80] stream:0 start_pts_time:0 pts:11520 pts_time:0.128 dts:11520 dts_time:0.128 -> pts:11520 pts_time:0.128 dts:11520 dts_time:0.128
[segment @ 0x564b59403b80] Opening '/usr/local/nginx/html/hls/mystream.m3u8.tmp' for writing
[file @ 0x564b59530900] Setting default whitelist 'file,crypto'
[segment @ 0x564b59403b80] EXT-X-MEDIA-SEQUENCE:0
[AVIOContext @ 0x564b5959f440] Statistics: 0 seeks, 1 writeouts
[segment @ 0x564b59403b80] segment:'/usr/local/nginx/html/hls/mystream0.ts' count:0 ended
[AVIOContext @ 0x564b59591140] Statistics: 0 seeks, 2 writeouts
[segment @ 0x564b59403b80] Opening '/usr/local/nginx/html/hls/mystream1.ts' for writing
[file @ 0x564b5959c900] Setting default whitelist 'file,crypto'
[mpegts @ 0x564b595a1280] muxrate VBR, pcr every 9000 pkts, sdt every 200, pat/pmt every 40 pkts
[segment @ 0x564b59403b80] segment:'/usr/local/nginx/html/hls/mystream1.ts' starts with packet stream:0 pts:191700 pts_time:2.13 frame:40
Führen Sie mit aus -c:a aacund teilen Sie das vollständige Protokoll.
Vielen Dank für Ihren Kommentar Gian. Wie soll ich es teilen? einfach kopieren und hier einfügen? Es erzeugt Millionen von Linien.
Fügen Sie -t 30Ihrem Befehl hinzu. Es wird ein kurzer Prozess sein, dessen Protokoll Sie in Ihr Q einfügen können.
Ich habe einige aus diesem riesigen Protokoll in meine Frage kopiert, Gyan. Kannst du sagen, was da falsch ist?

Antworten (1)

Lassen Sie mich meine eigene Frage beantworten. Mein Code funktioniert gut und es gab einen kleinen Rechtschreibfehler. Gee ... dumm von mir. Manchmal müssen Sie jedoch nur die Frage stellen und alles schriftlich festhalten, um zu erkennen, wo das Problem liegt. Falls es jemanden interessiert, hier ist, wie die Theorie / Syntax aussieht:

„-a:c copy“ soll ohne Transcodierung kopieren, wenn „-a:c {codec} {zusätzliche Audioparameter}“ transcodieren soll.

Jetzt streamt mein Code problemlos über mehrere Browser hinweg. Möglicherweise möchten Sie die Bitraten anpassen und so anpassen, wie Sie es für richtig halten.

ffmpeg -rtsp_transport tcp -i rtsp://login:password@1.1.1.1:554/11 -map 0 -c:v copy - 
c:a aac -f segment -segment_list /usr/local/nginx/html/hls/mystream.m3u8 - 
segment_list_type hls - segment_list_size 10 -segment_list_flags +live 
 /usr/local/nginx/html/hls/mystream%01d.ts