简体   繁体   中英

ffmpeg: recode transport stream (MPEG2 or h264) to another transport stream (h264)

currently, I'm struggling with a task I want to implement using a perl script on a Synology DiskStation. What I'm not sure about is the ffmpeg command to use. Actually, the DiskStation supports hardware encoding and it works quite well encoding to MKV files. The only thing that's missing: I don't want to encode to MKV as it's hard to work on these files with my other software for cutting. Therefore, I'd like to encode to a transport stream again. I'm using this command at the moment:

sudo ffmpeg -hide_banner -loglevel verbose -vaapi_device /dev/dri/renderD128 -i my_input_file.ts -map 0:v -map 0:a -c:v h264_vaapi -vf yadif,format=nv12,hwupload -y -b:v my_bitrate my_output_file.ts

Now, I always get an error:

Automatic encoder selection failed for output stream #0:1. Default encoder for format mpegts (codec mp2) is probably disabled. Please choose an encoder manually.
Error selecting an encoder for stream 0:1

To me it looks like it's not recognizing that I want to encode using h264 and not the default encoder for transport streams.

Any ideas on this?

Explanation:

  • The mapping is done to get rid of non-supported streams such as teletext and also reduce some streams as I get more than one language stream normally.
  • The sudo is needed as only root is allowed to use vaapi device on Synology (maybe on all systems)

It would be great if someone could give me a helping hand on this.

Thanks, Matthias

The error relates to the audio stream. Default encoder is mp2 but your build doesn't seem to have it. Add -c:a aac (safer) or -c:a copy . The latter will work if the input audio codec is supported by ffmpeg's MPEG-TS muxer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM