0

I am trying to convert couple of rather large MXF files into TS files preserving the video and audio encoding. The output TS has to be CBR Mpeg-2 TS file, which I know is not possible with ffmpeg. Any idea for another preferably Linux command line tool which could handle this task? Windows is also an option, but I want to convert couple of files on a server, so that is why it would be better if it is Linux based.

  • 1
    FFmpeg can produce CBR TS. What command did you try? – Gyan Sep 1 '17 at 13:31
  • @mulvya ffmpeg -i input.mxf -copyts -c copy -muxrate 30M -f mpegts output.ts I only want to add the stuffing. I have also tried to transcode the video with the command: ffmpeg -i input.mxf -vcodec libx264 -b:v 20M -minrate:v 20M -maxrate:v 20M -bufsize:v 14M -acodec mp2 -ac 2 -b:a 192k -f mpegts output.ts. So I want the output to be completely flat. This could be done by setting the muxrate to a much higher value or by achieving completely CBR video bitrate. The ffmpeg version is 3.2.4. – Georgе Stoyanov Sep 1 '17 at 13:50
  • If transcoding using x264, add -x264opts nal-hrd=cbr and also muxrate. Provide a value about 10-12% above video+audio, or more precisely, sum of stream bitrates. – Gyan Sep 4 '17 at 8:12
  • @Mulvya, it works, even though the size of the stuffing is quite big the output file is indeed CBR. I have noticed that after a certain size of the video bitrate the output starts to look not so uniform, but this option should be fine for anything up to 250-300Mbps video bitrate. Do you happen to know the same command but this time for HEVC? Or just how to re-wrap the container from mxf to ts and setting the bitrate of the TS? – Georgе Stoyanov Sep 4 '17 at 10:17
  • For x265 x265-params strict-cbr=1:vbv-bufsize=<x>:vbv=maxrate=<bitrate> + muxrate – Gyan Sep 4 '17 at 11:30
1

Okay thanks to @Mulvya I have found a solution how I can create CBR MPEG-2 TS with stuffing and constant constant bitrate and inside of it VBR VPID. The command for H.264 is:

$ ffmpeg -i <input> \
-c:v libx264 -x264opts nal-hrd=cbr \
-b:v 30M -minrate:v 30M -maxrate:v 30M -muxrate 35M -bufsize:v 25M \
-c:a aac -ac 2 -b:a 128k \
-f mpegts <output.ts>

This will create 35Mbps CBR TS and inside the TS the bitrate of the VPID will fluctuate a bit around 30Mbps, and also the bitrate of PID 8191 (null PIDs).

The command for doing the same but with HEVC is the following:

ffmpeg -i <input> \
-c:v libx265 -b:v 25M -muxrate 30M \
-x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000 \
-c:a aac -ac 2 -b:a 128k \
-f mpegts <output.ts>

Here the TS will be with 30Mbps bitrate and the VPID will be around 25Mbps, this command will create also stuffing (null PIDs) around 5Mbps.
Please also note that the bitrate after -x265-params should be in Kbps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.