Encoding YUV to mP4 With qp to get max quality - ffmpeg

I am trying to encode my YUV420 Raw format file into mp4. Here is the ffmpeg command
ffmpeg -f s16le -ar 44100 -ac 1 -i "0.a" -f rawvideo -pix_fmt yuv420p -s 480x480 -r 30 -i "0.v" -vcodec libx264 -profile:v baseline -preset ultrafast -qp 0 -b:v 1024k -g 30 -acodec libfdk_aac -ar 44100 -ac 1 -b:a 64k -f mp4 -movflags faststart "1438947231095.mp4"
If i remove qp = 0; it works however the quality is very low not sure why. If i put qp = 0 it doesn't work, What is wrong?
Getting this error
Error while opening encoder for output stream #0:0 - maybe incorrect parameters

The baseline profile doesn't support lossless H.264. You must use the High 4:4:4 Predictive profile instead:
-profile:v high444

Related

AAC bitstream not in ADTS format and extradata missing in MPEG-TS output

I am using ffmpeg 5.1.2 stable version, and fdk-aac v0.1.6 .
I am trying to encapsulate a LATM/LOAS in an MPEGTS DVB standard output, using this cmdline:
ffmpeg -i <source> -af volume=volume=1dB:precision=fixed -c:a libfdk_aac -latm 1 -b:a 128k -c:v libx264 -pix_fmt yuv420p -preset veryfast -x264-params "nal-hrd=cbr:keyint=50:min-keyint=50" -b:v 3200k -minrate 3200k -maxrate 3200k -bufsize 6400k -flush_packets 0 -f mpegts -mpegts_original_network_id 1 -mpegts_transport_stream_id 1 -mpegts_service_id 1 -mpegts_service_type '0x19' -mpegts_flags 'latm' -mpegts_flags 'system_b' -mpegts_flags 'nit' -muxrate 4000000 -metadata service_provider='MyRTV' -metadata service_name='My TV' -tables_version 0 'udp://238.0.0.1:6000?ttl=1&pkt_size=1316&bitrate=4000000'
It logs and error:
[mpegts # 0x556dc3e6a840] AAC bitstream not in ADTS format and extradata missing
What am I missing ?
Thanks in advance and best regards
I am trying to encapsulate a LATM/LOAS in an MPEGTS DVB standard output, so expect to have a LOAS/LATM output, but I obtain an ADTS output.

Why ffmpeg ignores output fps?

I have the following ffmpeg command that streams an input to an RTMP endpoint :
ffmpeg
-re
-i -
-r 30
-vf scale=852:480
-c:v libx264
-pix_fmt yuv420p
-profile:v main
-preset veryfast
-x264opts "nal-hrd=cbr:no-scenecut"
-minrate 3000
-maxrate 3000
-g 60
-c:a aac
-b:a 160k
-ac 2
-ar 44100
-f flv
Some RTMPURL/ Some RTMPKey
This command works but the output frame rate is not respected. It drops to 6 fps.
I need it to be always 30 fps.
Does anyone know why it's not respected please ?
Thanks

How to change audio frame rate in FFMPEG?

I am trying to change audio frame from 43.066 FPS (1024 SPF) to 23.438 FPS (2048 SPF) but no luck.
code tried :
ffmpeg -i 1.mp4 -b:v 2000k -vcodec libx264 -x265-params keyint=50:scenecut=0 -preset fast -pix_fmt yuv420p -profile:v main -level 3.1 -r 25 -s:v 1280x720 -ac 2 -c:a aac -b:a 128k -ar 48000 -aframes 23.438 HD2_500_500.mp4
Error :
Expected int64 for frames:a
You can change the audio speed using the ​atempo audio filter. The filter accepts exactly one parameter, the audio tempo. If not specified then the filter will assume nominal 1.0 tempo. Tempo must be in the [0.5, 100.0] range.
Here a simple example on how to speed down the audio by half:
ffmpeg -i 1.mp4 -filter:a "atempo=0.5" -vn HD2_500_500.mp4

live streamming using ffmpeg for more than stream on the same time

I'm using this command to stream video in ffmpeg but when I stream more than 3 or 4 streams at the same time interruption happen although the process in my device doesn't exceed 50%
I tried to use ffmpeg lib for each stream but interruption still happened
this is my command :
ffmpeg -re -i test.mp4 -i logo.png -vcodec libx264 -pix_fmt yuv420p -vb 2000000 -g 60
-vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb
-strict experimental -filter_complex "[0][1]overlay=0:0"
-pass 1 -f mpegts udp://127.0.0.1:1234?pkt_size=1316

Video codec specs through ffmpeg (not being achieved)

The specs for the video format are the following:
Aspect Ratio: 1:1
H.264 video compression, high profile, square pixels, fixed frame rate, progressive scan
.mp4 container with leading mov atom, no edit lists
Audio: Stereo AAC audio compression, 128kbps +
Reading through posts and ffmpeg documentation I came up with the following (yeah, I run it on a Windows PC):
ffmpeg.exe -r 30 -i input.webm -vf scale=iw*sar:ih -c:v libx264 -preset slow -profile:v high -c:a aac -strict experimental -ar 44100 -aspect 1:1 output.mp4
But when the video is played within the app that asks for this specification, it only displays black moving pixels, all broken, but you an hear the audio.
I don't really know what else to change on the command, and I have no idea in regards to the ...with leading mov atom specification.
Thanks.
EDIT:
I've tried #Mulvya's answer:
ffmpeg.exe -i input.webm -vf scale=iw*sar:ih,setsar=1 -c:v libx264 -preset slow -profile:v high -pix_fmt yuv420p -r 30 -c:a aac -strict experimental -ar 44100 -ac 2 -b:a 128k -movflags +faststart output.mp4
But the effect is the same once given to the app:
This is the information that ffmpeg spews about the input.webm file:
Use
ffmpeg.exe -i input.webm -vf scale=iw*sar:ih,setsar=1 -c:v libx264 -preset slow -profile:v high -pix_fmt yuv420p -r 30 -c:a aac -strict experimental -ar 44100 -ac 2 -b:a 128k -movflags +faststart output.mp4
Depending on how strict the app is, you may need to check the precise framerate. Use -r 30000/1001 for 29.97. The -movflags +faststart moves the moov atom to the front of the file.
Based on info I found elsewhere, this seems to be what Instagram requires:
ffmpeg.exe -i input.webm -vf scale=640:640,setsar=1 -c:v libx264 -preset slow -profile:v main -level 3.1 -pix_fmt yuv420p -r 30000/1001 -c:a aac -strict experimental -ar 44100 -ac 1 -b:a 64k -t 15 -movflags +faststart output.mp4

Resources