ffmpeg error when I make TS file - ffmpeg

I use ffmpeg to make video from audio/image to mp4.
I want merge/concatenate two mp4 video.
I have this to make mp4 video:
ffmpeg -i "background.png" -i "audio.mp3" -y -r 30 -b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 "result.mp4"
This, it works!
To concatenate two mp4 video, I must pass by ts files.
ffmpeg -i "result.mp4" -codec copy -bsf:v hevc_mp4toannexb intermediate1.ts
But, I have this error:

Related

how to add .mp3 to .webm file?

I am trying to add audio(repeat it until the end of the video) to a .webm file. but getting an error-
code i am using is-
ffmpeg -i 1.webm -stream_loop -1 -i 1.mp3 -c copy -shortest -map 0:v:0 -map 1:a:0 output.webm
error i am getting is-
Only VP8 or VP9 or AV1 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
I have checked other posts before writing this post but those solutions did not work for me.
is there any way to make it work?
The WebM Container does not support the old MP3 audio codec.
Use Opus instead. You need less than half the bitrate for the same quality. Here I choose 96Kbit/s bitrate which should equal to roughly 200 in MP3. Adjust that param. -mapping_family 0 is required for ffmpeg to use most opus optimizations, standard -1 will deactivate most of them. Use mapping_family 1 if the input source has more than 2 channels.
ffmpeg -i 1.webm -stream_loop -1 -i 1.mp3 -vcodec copy -acodec libopus -mapping_family 0 -b:a 96k -shortest -map 0:v:0 -map 1:a:0 output.webm
If you really want to use old MP3 you can also just use the .mkv container. MKV nearly supports everything.
ffmpeg -i 1.webm -stream_loop -1 -i 1.mp3 -c copy -shortest -map 0:v:0 -map 1:a:0 output.mkv

Problems with modifying encoder metadata with FFMPEG

I'm trying to change FFMPEG encoder writing application with FFMPEG -metadata and for whatever reason, it's reading the input but not actually writing anything out.
-map_metadata -metadata:s:v:0 -metadata writing_application, basically every single stack overflow and stack exchange thread, but they all won't write to the file at all.
ffmpeg -i x.mp4 -s 1920x1080 -r 59.94 -c:v h264_nvenc -b:v 6000k -vf yadif=1 -preset fast -fflags +bitexact -flags:v +bitexact -flags:a +bitexact -ac 2 x.mp4
ffmpeg -i x.mp4 -c:v copy -c:a copy -metadata Encoder="TeXT Encoder" -fflags +bitexact -flags:v +bitexact -flags:a +bitexact test.mp4
ffmpeg -i x.mp4 -vcodec copy -acodec copy -map_metadata out.mp4
ffmpeg -i x.mp4 -vcodec copy -acodec copy -metadata encoder="Encoder" -metadata comment="XX" testmeta.mp4
ffmpeg -i x.ts -c:v copy -c:a copy -metadata:s:v:0 h264 ISFT='TeXT' x.mp4
ffmpeg -i x.mp4 -i FFMETADATAFILE -map_metadata 1 -codec copy testcopy.mp4
ffmpeg -i x.ts -f ffmetadata FF
METADATAFILE
I tried to extracting the data and rewrite it back with FFMETADATAFILE but it doesn't show up. Tried forcing ffmpeg to write without any emtadata and write it back but doesn't work. Was wondering if I can write my own encoder that writes the specific encoder name, like how Handbrake/Lavf writes the encoder application into the METADATA of the video file. Or just use FFMPEG and modify the METADATA natively.
To set the writing application (mediainfo) or encoder (ffmpeg) for MP4s, use
ffmpeg -i input {-encoding parameters} -metadata:g encoding_tool=myapp out.mp4

Convert TS with closed captions into MKV/MP4 with sub title

I am trying to convert a TS file ( with US closed captions ) into MKV ( or MP4 ). Currently I am doing using a three step approach.
Step-1 : Extract the subtitle in srt format.
ffmpeg -f lavfi -i "movie=test.ts[out0+subcc]" -map s output.srt
Step-2 : Transcode the TS into MKV
ffmpeg i test.ts -vcodec libx264 -acodec copy out.mkv
Step-3 : Add subtitle back to out.mkv
ffmpeg -i out.mkv -i output.srt -acodec copy -vcodec copy -scodec copy final.mkv.
I believe all these three steps can be combined in a single ffmeg command. Is there any way to do this?.
You can try
ffmpeg -i test.ts -f lavfi -i "movie=test.ts[out0+subcc]" -map 0 -map 1:s -c:a copy -c:s srt final.mkv
Hopefully, the timestamps for the subtitles will be in sync :)

FFmpeg PNG+MP3 = FLV

I need to create a FLV video from a MP3 file and a PNG image, and I tried the following ffmpeg command:
/usr/bin/ffmpeg -y -i file.png -i file.mp3 -acodec libmp3lame -vcodec flv -y -ac 1 -ab 32000 -ar 22050 file.flv
I obtained a FLV video file with the correct audio and the image, but it is not seekable in VLC, so I'm looking where I'm wrong.
Could you help me, please?
Thank you very much!

Transcoding with ffmpeg libfaac reduces the audio duration

I have to transcode a mpegts file: input.ts(H.264 and AAC)
So I use the following command line:
ffmpeg -y -i input.ts -acodec libfaac -vcodec copy out.ts
But I find that the duration of output.ts's audio is shorter than that of the input.ts!
If I do the following iterations, the output's audio will be shorter and shorter.
ffmpeg -y -i out.ts -acodec libfaac -vcodec copy out-iter1.ts
ffmpeg -y -i out-iter1.ts -acodec libfaac -vcodec copy out-iter2.ts
ffmpeg -y -i out-iter2.ts -acodec libfaac -vcodec copy out-iter3.ts
ffmpeg -y -i out-iter3.ts -acodec libfaac -vcodec copy out-iter4.ts
ffmpeg -y -i out-iter4.ts -acodec libfaac -vcodec copy out-iter5.ts
My ffmpeg's version is 0.6.6. libfaac's version is 1.28.
input.ts's audio duration is 10.432 seconds. out-iter5.ts's audio duration is 10.56 seconds
And I have also tried ffmpeg with version 0.11.
And it makes the audio longer than the original input.
So my question is: how to make sure the output's audio duration is same as the input's audio.
Since libfaac will make the audio shorter, how can I compensate for it?
(For some reason I can't use -acodec copy directly.) Any suggestions?

Resources