Hello, I'm trying to get ffmpeg to compress a 440 Hz tone into an MPEG-2 transport stream. I generated a raw PCM tone with the following code. (Based on the examples provided with ffmpeg.) => 48 kHz sampling frequency, 16 bits per sample per channel, same samples on left and right channels. #define _GNU_SOURCE #include <unistd.h> #include <stdint.h> #include <fcntl.h> #include <math.h> int main(void) { const double pi = 3.14159265358979323846; const double incr = 2 * pi * 440 / 48000; double x = 0; int i, j, fd; int16_t samples[1152 * 2]; if ((fd = open("tone.sw", O_WRONLY | O_CREAT, 0644)) < 0) return 1; for (i=0; i < 2000; ++i) { for (j=0; j < 1152; ++j) { int16_t temp = lrint(12000*sin(x)); samples[2*j+0] = temp; samples[2*j+1] = temp; x += incr; } write(fd, samples, sizeof samples); } return 0; } My first test was to encode to MPEG-1 Audio layer II. $ ffmpeg -ar 48000 -ac 2 -i tone.sw -ab 128000 foo.mp2 FFmpeg version SVN-r11555 configuration: --enable-gpl --cpu=pentium3 --enable-debug libavutil version: 49.6.0 libavcodec version: 51.49.0 libavformat version: 52.4.0 libavdevice version: 52.0.0 built on Jan 24 2008 13:46:39, gcc: 3.4.6 Input #0, s16le, from 'tone.sw': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, mp2, to 'foo.mp2': Stream #0.0: Audio: mp2, 48000 Hz, stereo, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding size= 750kB time=48.0 bitrate= 128.0kbits/s video:0kB audio:750kB global headers:0kB muxing overhead 0.000000% (Did I provide the appropriate command line?) This seems to work as I can decode the file e.g. in Winamp. Then I tried to wrap the elementary stream in a transport stream. $ ffmpeg -ar 48000 -ac 2 -i tone.sw -ab 128000 foo.ts [...] Input #0, s16le, from 'tone.sw': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, mpegts, to 'foo.ts': Stream #0.0: Audio: mp2, 48000 Hz, stereo, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding size= 1043kB time=48.0 bitrate= 178.0kbits/s video:0kB audio:750kB global headers:0kB muxing overhead 39.041667% But when I load the resulting file in Tektronix's Transport Stream Compliance Analyzer (TSCA) it cannot even find the PAT... (Looking at the individual TS packets.) Packet 1: 47 40 00 11 00 00 b0 0d 00 01 c1 00 00 00 01 ef ff 36 90 e2 3d ff ff ff ff ff ff ff [...] I count 21 non-padding bytes (not a multiple of 4, hmmm). After the TS header (4 bytes) there should be 0x00 and the next nibble should be 1011 i.e. 0xb but in the above packet, it's 0x00 0x00 0xb... (i.e. an extra 0x00) I suppose I'm reading something wrong? What am I missing? Regards.
John Sigler wrote:
I'm trying to get ffmpeg to compress a 440 Hz tone into an MPEG-2 transport stream.
[snip PCM generation and MP2 encoding]
Then I tried to wrap the elementary stream in a transport stream.
$ ffmpeg -ar 48000 -ac 2 -i tone.sw -ab 128000 foo.ts [...] Input #0, s16le, from 'tone.sw': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, mpegts, to 'foo.ts': Stream #0.0: Audio: mp2, 48000 Hz, stereo, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding size= 1043kB time=48.0 bitrate= 178.0kbits/s video:0kB audio:750kB global headers:0kB muxing overhead 39.041667%
But when I load the resulting file in Tektronix's Transport Stream Compliance Analyzer (TSCA) it cannot even find the PAT...
It seems TSCA gets confused by the PCR values in the stream. I had to manually specify the transport stream bit rate. According to the analyzer, the transport stream complies with every test (there are 30+) except one, PCR accuracy. The problem /seems/ to be that the multiplexer writes the PCRs as if there are no Program Specific Information (PSI) metadata. Consequently, the analyzer "sees" a lot of PCR jitter. Am I making any sense or is it obvious I've lost my marbles long ago? Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant? Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries? http://www.videolan.org/developers/libdvbpsi.html http://scara.com/~schirmer/o/mplex13818/ Regards.
On Tuesday 29 January 2008 18:03:08 John Sigler wrote:
But when I load the resulting file in Tektronix's Transport Stream Compliance Analyzer (TSCA) it cannot even find the PAT...
It seems TSCA gets confused by the PCR values in the stream. I had to manually specify the transport stream bit rate.
According to the analyzer, the transport stream complies with every test (there are 30+) except one, PCR accuracy. The problem /seems/ to be that the multiplexer writes the PCRs as if there are no Program Specific Information (PSI) metadata. Consequently, the analyzer "sees" a lot of PCR jitter.
Am I making any sense or is it obvious I've lost my marbles long ago?
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries?
ffmpeg's TS muxer is known to be no better than a toy
Hi, John Sigler wrote:
John Sigler wrote:
I'm trying to get ffmpeg to compress a 440 Hz tone into an MPEG-2 transport stream.
[snip PCM generation and MP2 encoding]
Then I tried to wrap the elementary stream in a transport stream.
$ ffmpeg -ar 48000 -ac 2 -i tone.sw -ab 128000 foo.ts [...] Input #0, s16le, from 'tone.sw': Duration: N/A, start: 0.000000, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, mpegts, to 'foo.ts': Stream #0.0: Audio: mp2, 48000 Hz, stereo, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding size= 1043kB time=48.0 bitrate= 178.0kbits/s video:0kB audio:750kB global headers:0kB muxing overhead 39.041667%
But when I load the resulting file in Tektronix's Transport Stream Compliance Analyzer (TSCA) it cannot even find the PAT...
It seems TSCA gets confused by the PCR values in the stream. I had to manually specify the transport stream bit rate.
According to the analyzer, the transport stream complies with every test (there are 30+) except one, PCR accuracy. The problem /seems/ to be that the multiplexer writes the PCRs as if there are no Program Specific Information (PSI) metadata. Consequently, the analyzer "sees" a lot of PCR jitter.
Am I making any sense or is it obvious I've lost my marbles long ago?
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries?
Yes, there is the SOC FFmpeg TS multiplexer, for which I'd really have extensive tests and reports, email me if you want to test it, and have help compiling it. I think tests with TSCA would be great. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Hello Baptiste, Baptiste Coudurier wrote:
John Sigler wrote:
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries?
Yes, there is the SOC FFmpeg TS multiplexer,
Are you referring to the following? http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code#TS_Muxer * Student: Xiaohui Sun * Mentor: Baptiste Coudurier * Student Status: disappeared, project unfinished * Code Status: Changes requested during the review process for FFmpeg inclusion were never made. Is the description up to date?
for which I'd really have extensive tests and reports,
I don't understand this sentence. Could you rephrase?
email me if you want to test it, and have help compiling it. I think tests with TSCA would be great.
Would you say the code quality is alpha? beta? or release candidate material? Regards.
John Sigler wrote:
Hello Baptiste,
Baptiste Coudurier wrote:
John Sigler wrote:
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries? Yes, there is the SOC FFmpeg TS multiplexer,
Are you referring to the following? http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code#TS_Muxer * Student: Xiaohui Sun * Mentor: Baptiste Coudurier * Student Status: disappeared, project unfinished * Code Status: Changes requested during the review process for FFmpeg inclusion were never made.
Is the description up to date?
Yes, it is correct.
for which I'd really have extensive tests and reports,
I don't understand this sentence. Could you rephrase?
I'd really like to have extensive tests and detailed reports against TS generated by the SOC TS muxer.
email me if you want to test it, and have help compiling it. I think tests with TSCA would be great.
Would you say the code quality is alpha? beta? or release candidate material?
I would say code is beta, it is based on current FFmpeg PES muxing code which is prefectly working. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG S.A. http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
Baptiste Coudurier wrote:
John Sigler wrote:
Baptiste Coudurier wrote:
John Sigler wrote:
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries?
Yes, there is the SOC FFmpeg TS multiplexer
Are you referring to the following? http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code#TS_Muxer
* Student: Xiaohui Sun * Mentor: Baptiste Coudurier * Student Status: disappeared, project unfinished * Code Status: Changes requested during the review process for FFmpeg inclusion were never made.
Is the description up to date?
Yes, it is correct.
I'd really like to have extensive tests and detailed reports against TS generated by the SOC TS muxer.
Would you say the code quality is alpha? beta? or release candidate material?
I would say code is beta, it is based on current FFmpeg PES muxing code which is prefectly working.
Perhaps you could generate the transport stream with the new muxer? I'd then run it by the analyzer and report the results back here. I generated a 20-minute PCM tone using the following code. (The resulting file weighs 230 MB.) #define _GNU_SOURCE #include <unistd.h> #include <stdint.h> #include <fcntl.h> #include <math.h> int main(void) { const double pi = 3.14159265358979323846; const double incr = 2 * pi * 440 / 48000; double x = 0; int i, j, fd; int16_t samples[1152 * 2]; if ((fd = open("tone.sw", O_WRONLY | O_CREAT, 0644)) < 0) return 1; for (i=0; i < 50000; ++i) { for (j=0; j < 1152; ++j) { int16_t temp = lrint(12000*sin(x)); samples[2*j+0] = temp; samples[2*j+1] = temp; x += incr; } write(fd, samples, sizeof samples); } return 0; } I then asked ffmpeg to compress the audio with MP2 and wrap the result in a transport stream. $ ffmpeg -ar 48000 -ac 2 -i tone.sw -ab 128000 foo.ts Depending on the TS overhead, the resulting file weighs 25-35 MB. If you upload this file somewhere, I will test it, and post screen shots of the analysis in this thread. Regards.
Baptiste Coudurier wrote:
John Sigler wrote:
Has anyone used a professional TS analyzer to check ffmpeg's TS output, and found it to be DVB-compliant?
Would you suggest using a different TS multiplexer? (My very preliminary search turned up mplex13818 and libdvbpsi.) Are there other, better, open-source libraries?
(As far as I understand, libdvbpsi is not a TS muxer, it's a library to read and write PSI tables.) I used vlc's TS muxer(*) to mux a single CBR audio ES, and the resulting TS is considered DVB-compliant by the Tektro TS analyzer. (*) http://trac.videolan.org/vlc/browser/trunk/modules/mux/mpeg/ts.c My problem is that I can't figure out how to use vlc as a low-level library. Ideally, I'd use libavcodec to output elementary streams, and feed them to vlc's TS muxer, but this doesn't look possible... What people have suggested is for me to mux the ESs into a PS, then pipe the PS to vlc which would demux, then remux it into a TS. I don't like this solution.
Yes, there is the SOC FFmpeg TS multiplexer, for which I'd really like to have extensive tests and reports, email me if you want to test it, and have help compiling it. I think tests with TSCA would be great.
Did you get a chance to generate a TS I could analyze? (That would help speed up my evaluation.) I will take a look at the code, and try to compile it. Can the new muxer add NULL packets if need be to keep the bit rate constant? Can it smooth the bit rate over user-defined integration periods? and over periods defined by the arrival of I frames? Regards.
participants (3)
-
baptiste.coudurier@smartjog.com -
linux.kernel@free.fr -
Nicola.Sabbi@poste.it