lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
540 stars 24 forks source link

Suspected map issue with current ffmpeg #195

Closed loshlee closed 4 months ago

loshlee commented 9 months ago

Hi. I'm using version 12. If I use the following command, ffmpeg fails to convert my .m2ts file.

other-transcode --mp4 --crop auto doctor.m2ts

The ffmpeg command line generated by other_video_transcoding is:

ffmpeg -loglevel error -stats -i doctor.m2ts -map 0:0 -filter:v crop\=1920:1036:0:22 -c:v h264_videotoolbox -b:v 6000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -movflags disable_chpl doctor.mp4

The error reported when I run that ffmpeg command is:

[mp4 @ 0x105d04f00] sample rate not set
[out#0/mp4 @ 0x6000036500c0] Could not write header (incorrect codec parameters ?): Invalid argument
[vost#0:0/h264_videotoolbox @ 0x105d059b0] Error initializing output stream

However, all that is needed to make the ffmpeg command work is to use -c:a copy

instead of

-metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -movflags disable_chpl

in the command generated by other_video_transcoding. So the following command works just fine:

ffmpeg -loglevel error -stats -i doctor.m2ts -filter:v crop\=1920:1036:0:22 -c:v h264_videotoolbox -b:v 6000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -c:a copy doctor.mp4

Is this a bug in other_video_transcoding version 12?

Thanks.

loshlee commented 9 months ago

I forgot, I also had to remove -map 0:0 from the other_video_transoding version of the command.

loshlee commented 9 months ago

Oh, I was mistaken. The transcoding appears to progress without error, but there's no audio stream in the output. I don't yet have a workaround. Thanks.

loshlee commented 9 months ago

Sorry about the waste of time. Going back to the first broken ffmpeg command that I found:

ffmpeg -loglevel error -stats -i doctor.m2ts -map 0:0 -filter:v crop=1920:1036:0:22 -c:v h264_videotoolbox -b:v 6000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title= -disposition:a:0 default -sn -metadata:g title= -movflags disable_chpl doctor.mp4

To make it work, I finally found a suggestion to increase anylizeduration and probesize. Anyway, this one finally works (including audio):

ffmpeg -loglevel error -stats -analyzeduration 100M -probesize 100M -i doctor.m2ts -map 0:0 -filter:v crop=1920:1036:0:22 -c:v h264_videotoolbox -b:v 6000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title= -disposition:a:0 default -sn -metadata:g title= -movflags disable_chpl doctor.mp4