Answers.Body: <p>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: </p>
  
  <pre><code>$ ffmpeg -i &lt;input&gt; \
  -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 &lt;output.ts&gt;
  </code></pre>
  
  <p>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).<br><br> 
  The command for doing the same but with HEVC is the following: </p>
  
  <pre><code>ffmpeg -i &lt;input&gt; \
  -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 &lt;output.ts&gt;
  </code></pre>
  
  <p>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. <br>Please also note that the bitrate after <code>-x265-params</code> should be in Kbps. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-04T14:38:06.933Z
Answers.LastActivityDate: 2017-09-04T14:38:06.933Z
Answers.UserDisplayName: Georgi Stoyanov
Body: <p>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. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-01T13:31:05.540Z
Comments.Text: FFmpeg can produce CBR TS. What command did you try?
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-01T13:50:32.790Z
Comments.Text: @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.
Comments.UserDisplayName: Georgi Stoyanov
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T08:12:54.967Z
Comments.Text: 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.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T10:17:25.163Z
Comments.Text: @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?
Comments.UserDisplayName: Georgi Stoyanov
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T11:30:00.753Z
Comments.Text: For x265 `x265-params strict-cbr=1:vbv-bufsize=<x>:vbv=maxrate=<bitrate>` + muxrate
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T13:13:46.357Z
Comments.Text: @Mulvya, unfortunately the command line you send me is returning an error. I have used the following command line:
  `ffmpeg -i HD_Plus_Fussball25_FINISH_v06_R128_.mxf -c:v libx265 -x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000 -muxrate 30000 -c:a copy -f mpegts test.ts` and this is the error: `x265 [error]: Strict-cbr cannot be applied without specifying target bitrate or vbv bufsize`
Comments.UserDisplayName: Georgi Stoyanov
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T13:26:46.453Z
Comments.Text: Yes, you need to keep the bitrate  `-b:v`
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-09-04T13:59:31.970Z
Comments.Text: @Mulvya, yes, you are right, I have forgotten to add the video bitrate option `ffmpeg -i input.mxf -c:v libx265 -x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000:muxrate=30000:bitrate=25000 -c:a copy -f mpegts output.ts` The problem here is that the output TS file doesn't have any stuffing bits, which is creating a lot of CRC repetition errors on the VPID and the output is far from CBR, the bitrate is fluctuating between 18 and 30 Mbps. For comparison the command in x264 actually created a CBR TS mux and inside the MUX the stuffing bitrate was fluctuating but very little.
Comments.UserDisplayName: Georgi Stoyanov
Tags: <ffmpeg><file-formats><transcoding>
Title: Convert MXF files into CBR TS
UserDisplayName: Georgi Stoyanov
ThreadText: # Convert MXF files into CBR TS
  
  (Asked by: username_0 on 2017-09-01)
  
  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.
  
  **Tags:** ffmpeg, file-formats, transcoding
  
  > **Comments:**
  > **username_1**: FFmpeg can produce CBR TS. What command did you try?  
  > **username_0**: @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.  
  > **username_1**: 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.  
  > **username_0**: @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?  
  > **username_1**: For x265 `x265-params strict-cbr=1:vbv-bufsize=<x>:vbv=maxrate=<bitrate>` + muxrate  
  > **username_0**: @Mulvya, unfortunately the command line you send me is returning an error. I have used the following command line: `ffmpeg -i HD_Plus_Fussball25_FINISH_v06_R128_.mxf -c:v libx265 -x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000 -muxrate 30000 -c:a copy -f mpegts test.ts` and this is the error: `x265 [error]: Strict-cbr cannot be applied without specifying target bitrate or vbv bufsize`  
  > **username_1**: Yes, you need to keep the bitrate  `-b:v`  
  > **username_0**: @Mulvya, yes, you are right, I have forgotten to add the video bitrate option `ffmpeg -i input.mxf -c:v libx265 -x265-params strict-cbr=1:vbv-bufsize=25000:vbv-maxrate=25000:muxrate=30000:bitrate=25000 -c:a copy -f mpegts output.ts` The problem here is that the output TS file doesn't have any stuffing bits, which is creating a lot of CRC repetition errors on the VPID and the output is far from CBR, the bitrate is fluctuating between 18 and 30 Mbps. For comparison the command in x264 actually created a CBR TS mux and inside the MUX the stuffing bitrate was fluctuating but very little.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-09-04. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  