ffmpeg transcoding move to mp4 - ffmpeg

I currently use windows free software called: AnyVideoConverter to convert my iPhone huge MOV files to MP4s that can be played on other devices via my plex server.
I want to automate that process so it runs in the background on one of my linux machines.
However I am struggling to get it working. Here is what I have so far.
Original file details:
Duration: 00:00:13.53
Original Video: 40MB
Video details: Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160, 23453 kb/s, 30 fps, 30 tbr, 600 tbn, 600 tbc (default)
AnyVideoConverted file:
File Size: 5MB
Video Details: Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 3840x2160, 2870 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
This format works great on all my devices
So far the closes I managed to get to that is this ffmpeg command:
ffmpeg -i original.mov -c:v libx264 -profile:v baseline -maxrate 3M -bufsize 3M -c:a aac -b:a 128k x264.mp4
File size:5MB
Video details: Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 2160x3840, 3063 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
problem is that when I try to play it via plex I get:
Playback Error: This server is not powerful enough to convert video
What am I doing wrong here?
My knowledge of ffmpeg or video encoding/transcoding is zero. Can someone advise me how to get my mov files converted to mp4 so they can be played via plex without additional transcoding by plex and without reducing the resolution size of the converted video.
Any pointers ?
Thanks

Transcoding depends on the type of Plex client that is requesting the movie. You have two options here:
Set video streaming quality to maximum in all of your Plex clients. This way a transcoding is not necessary in most of the cases.
Disable video transcoding in your Plex server (there is an option for that in your server settings). If your server is not capable of transcoding a normal video at all (like you described above), then it makes no sense to leave it enabled.

Related

How to check if a MPEG transport stream file contains sound or not?

I have the following .ts file. I don't hear any sound when I open it in a video player. But I am not sure what is wrong with it. Is it that the file does not contain any sound? Or it is because my video player does not understand the sound info it?
https://easyupload.io/109ixb
ffprobe -hide_banner -i your_filename
This shows all streams contained;
in your case, output of ffprobe -hide_banner -i 0.ts shows that there is only video data:
Input #0, mpegts, from '0.ts': Duration: 00:00:10.01, start: 0.083422, bitrate: 3940 kb/s
Program 1
Stream #0:0[0x102]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc

ffmpeg concatenate two video files with same aspect ratio and fps still gives missed up output

I need to concatenate two clips which had the following encoding
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 4:3 DAR 16:9], 100 kb/s, 23.98 fps, 23.98 tbr, 19184 tbn, 47.96 tbc (default)
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 261 kb/s, 23.98 fps, 23.98 tbr, 48k tbn, 47.95 tbc (default)
using the normal concat method spoils the second clip video stream
ffmpeg -y -f concat -safe 0 -i filesname.txt -vcodec copy -acodec copy 1.mp4
What is the required encoding I need to apply to the first clip to make it easily join-able with the the first?
Note:
The first clip was of the following specs and I encoded it using the following command to match the specs of the second clip.
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 4:3 DAR 16:9], 61 kb/s, 23.98 fps, 23.98 tbr, 19184 tbn, 47.96 tbc (default)
ffmpeg -i 1_original.mp4 -c:v libx264 -preset slow -profile:v baseline -vf scale=320x240 -r 23.98 -c:a aac -ar 44100 1.mp4
Problem
Your timebase varies between inputs, but the timebase must be the same to concatenate. The second input has a frame rate of 24000/1001. (Unfortunately the console output shows a rounded value, but you can refer to ffprobe -v error -show_streams input.mp4). However, you re-encoded the other video to a frame rate of 23.98. This resulted in a timescale difference of 19184 tbn vs 48k tbn.
Solution
Use -r 24000/1001 (or the alias -r ntsc-film):
ffmpeg -i 1_original.mp4 -c:v libx264 -preset slow -profile:v baseline -vf setsar=1 -r 24000/1001 -c:a aac -ar 44100 1.mp4
I replaced the scale filter with setsar to fix the aspect ratio difference, although the difference won't stop the concat demuxer.
If your frame rates are actually the same, but the timescale differs, then you can remux instead with -c copy and -video_track_timescale. There are several examples of using this option on this site.

How to process a video to mp4 with ffmpeg for quality and compatibility?

I am beginning to be more serious about video. I am processing my videos with ffmpeg in a fully updated Linux into mp4 to use it in HTML5 directly.
Now, I have old AVI videos that I want to convert to mp4 with ffmpeg for use with HTML5. In particular, I have this one:
http://luis.impa.br/photo/1101_aves_ce/caneleiro-de-chapeu-preto_femea_Quixada-CE-110126-E_05662+7a.avi
(I know, terrible quality... sorry). According to ffprobe:
Duration: 00:01:35.30, start: 0.000000, bitrate: 1284 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (DX50 / 0x30355844), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1144 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
That seems perfect: mpeg4 video and mp3 audio. So I tried:
ffmpeg -i input.avi -acodec copy -vcodec copy output.mp4
It generates a file that plays nicely in mplayer, but not in firefox getting an error:
Video format or MIME type not supported.
Chrome plays the audio, but no video is shown... Now, if I do:
ffmpeg -i input.avi output.mp4
firefox works, but the video is reencoded in another one with half the size (half the bitrate). This is what ffprobe says about the reencoded video:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:01:35.30, start: 0.000000, bitrate: 685 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 548 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
I suppose that I am loosing lots of quality (and time processing the video). So, my questions:
Why are browsers not playing my video with the copy codecs ?
Can I work with ffmpeg in this particular file without reencoding? If yes, how?
If I need to reencode, which are "reasonable" parameters to keep close to the original quality? Would something like
ffmpeg -i input.avi -b:v 1024k -bufsize 1024k output.mp4
suffice for this video? This generates a new video with size closer to the original one.
Thanks!
According to ffprobe and if I see it correctly, you have a DivX (5) video file. Do not use it for web!! ;)
mpeg4 (Simple Profile) (DX50 / 0x30355844)
So I don't see any chance to use this video without reencoding. Not if you wish to support firefox.
Use WebM or h264: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
UPDATE
Good settings for reencode depends on your input (bitrate, resolution, fps, kind of material ...), so there is no standard answer.
But you have to specify a codec or ffmpeg choose one depending on your output file extension (so it can be the wrong one).
You can try this:
ffmpeg -i input.avi -c:v libx264 -preset slow -crf 22 -c:a copy output.mkv
Presets and tunes can help to find the best choice: https://trac.ffmpeg.org/wiki/Encode/H.264

Trying to tonemap 14-bit grayscale video

I'm trying to generate h.264 video from raw 2-byte gray video (14-bit range encoded in 16-bit values). I can do something like:
ffmpeg -f rawvideo -pix_fmt gray16le -s:v 1280x720 -r 60 -i input.raw -c:v libx264 output.mp4
And I get video but it's pretty dark, not sure if it's clipping, doing a linear remap, or storing the 16-bit data and VLC is doing the remap. ffprobe is reporting Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 1280x720, 108 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc
I was figuring I'd use the tonemap filter to make a better mapping. I added a filter before the output file with -vf.
tonemap=hable errors Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
zscale=transfer=linear,tonemap=hable errors Impossible to convert between the formats supported by the filter 'Parsed_tonemap_1' and the filter 'auto_scaler_1'
zscale=transfer=linear,tonemap=hable,zscale=transfer=bt709,format=yuvj444p errors code 3074: no path between colorspaces
I'm not sure where to proceed from here...

ffmpeg - extract subtitles (which are unencrypted) when video is encrypted

I have a .wtv file, recorded from Windows Media Center, that I'd like to extract the subtitles from. The video is encrypted, but the subtitles are not (something I've been able to verify by using CCExtractor with it). FFMpeg lists the video as such:
Duration: 00:07:01.72, start: 2.214551, bitrate: 9154 kb/s
Stream #0:0[0xcc](eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream #0:1[0xcd]: Video: mpeg2video (Main), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, max. 25000 kb/s, 29.97 fps, 29.97 tbr, 10000k tbn, 59.94 tbc
Stream #0:2[0xce]: Subtitle: eia_608
When I try to run
ffmpeg -i myvideofile.wtv -an -vn -map 0:2 -c:s:0 srt test.srt
I see a lot of the following errors:
[wtv # 0x7fef79806e00] encrypted stream detected (st:1), decoding will likely fail
Last message repeated 8 times
[Closed caption Decoder # 0x7fef7982cc00] Data Ignored since exceeding screen width
and eventually:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
I don't mind it being able to decode the video stream, but is that causing the closed caption error? If it can't decode the video it doesn't know the screen width, perhaps? Is it possible to set the closed caption decoder to ignore such errors and output anyway (it's just in text format after all)?

Resources