#StackBounty: #ffmpeg How to go from .srt subtitles and a .ts video to a .ts video with dvb_subtitles?

Bounty: 100

I’m trying to get from a .srt subtitle file + a .ts video file => a .ts video file with a dvb_subtitle.

My .srt:

1
00:00:00,000 --> 00:00:05,000
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel hendrerit massa.

2
00:00:05,000 --> 00:00:10,000
Aliquam dolor sapien, molestie ac sagittis eu, tempus nec est.

3
00:00:10,000 --> 00:00:28,000
Morbi id sem eu sapien consectetur imperdiet. Morbi sed purus et sapien interdum placerat vitae quis orci.

My .ts: sample_1920x1080.ts from https://filesamples.com/formats/ts

SubtitleEdit command: .SubtitleEdit.exe /convert 'test_subtitles.srt' Blu-raysup /resolution:1920x1080 /overwrite.
This creates a test_subtitles.sup file as expected.

I then use ffmpeg to include the .sup subtitles, like this: .ffmpeg.exe -y -i 'sample_1920x1080.ts' -fix_sub_duration -i 'test_subtitles.sup' -map 0:v -map 1:s -vcodec copy -acodec copy -scodec dvbsub -copyts -muxdelay 0 -max_delay 0 'output.ts'. This works, but the results are sometimes not very readable. Here’s a screenshot:

Screenshot of VLC showing that the subtitles are hard to read

Do I have any other options here? Or options within subtitleedit/ffmpeg to f.ex. make the subtitles be bigger?

(I’ve posted this to the SubtitleEdit Github repository as well: https://github.com/SubtitleEdit/subtitleedit/issues/4539.)

UPDATE:

I learned from the author of SubtitleEdit that it’s indeed possible to increase the font size if using the graphical user interface of SubtitleEdit (see here. However, I wish to do this using a command line tool.


Get this bounty!!!

#StackBounty: #ffmpeg #vlc #hevc #interlacing HEVC/H.265 interlaced format support in ffmpeg or VLC

Bounty: 50

"Music Box Russia" channel over satellite transmits in HEVC 1920×1080 25fps interlaced – and after recording VLC recognizes file as 50 fps, and resolution 1920×540 – half a height. But on satellite tuner the player works fine – it plays a file as 1920×1080 25fps… When we can expect support for HEVC/H.265 interlaced? Here is recorded file (Garry Grey & Eva Miller). Also – a lot of lost frames in VLC player statistics..


Get this bounty!!!

#StackBounty: #audio #ffmpeg #conversion #mp3 #flac Windows: Recursively convert FLAC to MP3 w/ ffmpeg

Bounty: 100

I have ffmpeg installed and use batch files to convert MP4 h.264 to MKV x.265 successfully, but I have a problem with converting FLAC files to 320 kbps MP3 w/ no metadata needed. Although many posts explain how to do this in Linux, their scripts don’t solve this problem when run in the command prompt of Windows.

The command line script I have created to convert to MP3 has this line:

for %%A in (*.flac) do ffmpeg -i "%%~nA.flac" -c:v copy -b:a 320k "%%~nA.mp3"

Not being adept at Powershell, I am looking for a command line solution. I don’t care if metadata survives or not.

How may I modify that to convert all FLAC files in the current directory and all sub directories beneath it (as shown in the first link above for Linux)?


Get this bounty!!!

#StackBounty: #audio #video #ffmpeg #sync #video-editing ffmpeg – video and audio out of sync

Bounty: 50

This seems to be a common problem, but the answers I found don’t seem to apply to my situation.

I’m merging 6 videos (one of them is a short background that loops) into 1 output video, and the audio and video are off by a little bit (maybe a quarter second). Here’s my command line:

ffmpeg -y
-ss 0.2 -i "One.MOV"
-ss 3.2 -i "Two.MOV"
-i "Three.mp4"
-ss 1.9 -i "Four.mp4"
-ss 1.9 -i "Five.MOV"
-stream_loop 180 -i "Background.mp4"
-filter_complex "
   nullsrc=size=1920x1080 [back];
   [5:v] scale=1920x1080 [fred];
   [back][fred] overlay=shortest=1:x=0:y=0 [base];
   [0:v] crop=1312:1080:290:0,scale=576x474 [clip0];
   [0:a]volume=1.7[aud0];
   [1:v] crop=1080:1056:0:864,scale=497x486 [clip1];
   [1:a]volume=4.8,aresample=async=1:first_pts=0[aud1];
   [2:v] scale=576x324 [clip2];
   [2:a]volume=2.0,aresample=async=1:first_pts=0[aud2];
   [3:v] crop=673:720:322:0,scale=454x486 [clip3];
   [3:a]volume=6.9,aresample=async=1:first_pts=0[aud3];
   [4:v] crop=720:921:0:359,scale=380x486 [clip4];
   [4:a]volume=4.9,aresample=async=1:first_pts=0[aud4];
   [base][clip0] overlay=shortest=1:x=32:y=83 [tmp0];
   [tmp0][clip1] overlay=shortest=1:x=711:y=27 [tmp1];
   [tmp1][clip2] overlay=shortest=1:x=1312:y=158 [tmp2];
   [tmp2][clip3] overlay=shortest=1:x=93:y=567 [tmp3];
   [tmp3][clip4] overlay=shortest=1:x=770:y=567 [tmp4];
   [aud0][aud1][aud2][aud3][aud4]amix=inputs=5[a]
" -map "[tmp4]" -map "[a]" -c:v libx264 "Output.mp4"

I’m guessing it has to do with the aresample and first_pts but I’ve been reading the documentation and can’t figure out what I need to do differently.

How can I get my audio and video to synchronize?

EDIT

Note: "Three.mp4" is the piano accompaniment; the other tracks are individual singers, adding their voices to the piano.


Get this bounty!!!

#StackBounty: #ffmpeg Cursor blinks ffmpeg

Bounty: 50

ffmpeg -y -rtbufsize 200M -f gdigrab -thread_queue_size 1024 -probesize 10M -framerate 30 -draw_mouse 1 -video_size 1920x1080 -i desktop -f dshow -channel_layout stereo -thread_queue_size 1024 -i audio="Stereo mix (Realtek High Definition Audio)" -f dshow -channel_layout stereo -thread_queue_size 1024 -i audio="Microphone (Realtek High Definition Audio)" -c:v libx264 -preset ultrafast -tune zerolatency -crf 25 -c:a aac -ac 2 -b:a 128k -filter_complex "[0]format=yuv420p[v];[1][2]amix=inputs=2[a]" -map [v] -map [a] -movflags +faststart recording.mp4

That’s my command. It works fine, but have made some tests:

  1. I deleted Microphone input from my command and now i have only Stereo Mix input. And also i deleted this(-filter_complex "[0]format=yuv420p[v];[1][2]amix=inputs=2[a]" -map [v] -map [a]) from my command. And when i run my new command my cursor blinks, however i don’t get any errors from ffmpeg. My command works like early, but now cursor blinks. Log for 1)
  2. i just changed -video_size to 1536×864. And i have the same result(And when i run my new command my cursor blinks, however i don’t get any errors from ffmpeg. My command works like early, but now cursor blinks.)

UPD:
"Bug" for 2) gone.
I don’t why, but my command for 2) (ffmpeg -y -rtbufsize 200M -f gdigrab -thread_queue_size 1024 -probesize 10M -framerate 30 -draw_mouse 1 -video_size 1536x864 -i desktop -f dshow -channel_layout stereo -thread_queue_size 1024 -i audio="Stereo mix (Realtek High Definition Audio)" -f dshow -channel_layout stereo -thread_queue_size 1024 -i audio="Microphone (Realtek High Definition Audio)" -c:v libx264 -preset ultrafast -tune zerolatency -crf 25 -c:a aac -ac 2 -b:a 128k -filter_complex "[0]format=yuv420p[v];[1][2]amix=inputs=2[a]" -map [v] -map [a] -movflags +faststart recording.mp4) works normal, without any blinkings!

How can i fix it?
Thank u


Get this bounty!!!

#StackBounty: #ffmpeg How to fix "Could not run graph" error when recording the screen with audio using ffmpeg in Windows 10?

Bounty: 150

I want to record the screen with audio using ffmpeg in Windows 10.

The following command works but it does not record the audio:

 .ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv

To fix the issue, first I enable Audio Mix device from control panel > sounds

enter image description here

and then tried to find it in my audio devices with the follwing command:

 .ffmpeg -list_devices true -f dshow -i dummy

enter image description here

I try different syntaxes to add audio to the video in the first command:

.ffmpeg -f gdigrab -framerate 60 -video_size 1920x1080 -i desktop -f dshow -i audio="Stereo Mix (Realtek(R) Audio)" -vcodec libx264  -preset ultrafast -tune zerolatency -pix_fmt yuv422p -f mpegts udp://ip
   

.ffmpeg -f gdigrab -i desktop -f dshow -i audio="Stereo Mix (Realtek(R) Audio)" -vcodec libx264 muxed-video-file.mp4

but the error is always the same:

Could not run graph (sometimes caused by a device already in use by other application)
audio=Stereo Mix (Realtek(R) Audio): I/O error

enter image description here

Please let me know if you know a working solution or a hint 🙂


Get this bounty!!!

#StackBounty: #python-3.x #django #django-models #ffmpeg #django-rest-framework Encoded Video's path gets changed in database after…

Bounty: 50

Hey guys the I have this code to transcode video and it works well without celery. With celery, the path of the file in the database shows a different path and the video cannot be played in the browser, but it saves the file in the correct location in the pc.

If I don’t use celery, then the file path in database is media/videos/videos/<filename>.mp4 and file also gets saved here. This way the template is able to play the video. But if i use celery, the output gets saved in media/videos/videos/<filename>.mp4 but the path in database will be media/<filename>.mp4 somehow and thus template can’t play the video.

Is it because my page gets updated before the task? and not getting saved properly?

views.py

def post(self, *args, **kwargs):
    form = VideoPostForm(self.request.POST or None, self.request.FILES or None)
    if form.is_valid():
        video = form.save(commit=False)
        video.user = self.request.user
        video.save()
        form.save_m2m()
        # task_video_encoding(video.id)
        task_video_encoding.delay(video.id)
        return redirect(reverse('videos:my_video_home'))
    else:
        raise ValidationError('Check all form fields.')

encoding.py

def encode_video(video_id):
    video = VideoPost.objects.get(id = video_id)
    input_file_path = video.temp_file.path
    # print(input_file_path)
    input_file_name = video.title
    #get the filename (without extension)
    filename = os.path.basename(input_file_path)
    # print(filename)
    # path to the new file, change it according to where you want to put it
    output_file_name = os.path.join('{}.mp4'.format(filename))
    # print(output_file_name)
    # output_file_path = os.path.join(settings.MEDIA_ROOT, output_file_name)
    output_file_path = os.path.join(settings.MEDIA_ROOT, 'videos', 'videos', output_file_name)
    # print(output_file_path)

    for i in range(1):
        subprocess.call([settings.VIDEO_ENCODING_FFMPEG_PATH, '-i', input_file_path, '-codec:v', 'libx264', '-crf', '-preset', 'medium',
                    '-b:v', '3000k', '-maxrate', '-bufsize', '6000k', '-vf', 'scale=-2:720',
                    '-codec:a', 'aac', '-b:a', '128k', '-strict', '-2', output_file_path])
    # Save the new file in the database
    video.file = output_file_name
    video.save(update_fields=['file'])
    print(video.file)
    video.temp_file.delete()

models

class VideoPost(models.Model):
    user                = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
    title               = models.TextField(max_length=1000)
    temp_file           = models.FileField(upload_to='videos/temp_videos/', validators=[validate_file_extension], null=True)
    file                = models.FileField(upload_to='videos/videos/', validators=[validate_file_extension], blank=True, max_length=255)
    post_date           = models.DateTimeField(auto_now_add=True, verbose_name="Date Posted")
    updated             = models.DateTimeField(auto_now_add=True, verbose_name="Date Updated")
    slug                = models.SlugField(blank=True, unique=True, max_length=255)

Can anyone help me how to change this code in a way to show the converted video properly in the template.


Get this bounty!!!

#StackBounty: #ffmpeg #raspberry-pi How to build ffmpeg with hardware decoding support for raspberry pi? (cross compilation if possible)

Bounty: 250

Is it possible to build ffmpeg with decoding support for Raspberry Pi? I’ve read that mmal can do hardware accelerated decoding on the Raspberry Pi.

I’ve tried on debian 10 x86_64:

./configure 
    --prefix=${BUILD_DIR}/desktop/${FFMPEG_ARCH_FLAG} 
    --disable-doc 
    --enable-cross-compile 
    --cross-prefix=${CROSS_PREFIX} 
    --target-os=linux 
    --arch=${FFMPEG_ARCH_FLAG} 
    --extra-cflags="-O3 -fPIC $EXTRA_CFLAGS" 
    --enable-mmal 
    --enable-omx 
    --enable-omx-rpi 
    --enable-shared 
    --disable-debug 
    --disable-runtime-cpudetect 
    --disable-programs 
    --disable-muxers 
    --disable-encoders 
    --disable-bsfs 
    --disable-pthreads 
    --disable-avdevice 
    --disable-network 
    --disable-postproc 

where CROSS_PREFIX=aarch64-linux-gnu- and FFMPEG_ARCH_FLAG=aarch64 but obviously I get ERROR: mmal not found. I couldn’t find MMAL to compile and install.


Get this bounty!!!

#StackBounty: #windows #command-line #video #ffmpeg How to copy unsupported data streams with ffmpeg?

Bounty: 50

Briefing

I have some .wmv files (actually, my full batch file deals with multiple filetypes) with weird data streams that are needed for an external program to recognize them.

I’m trying to remove every stream that is not data or audio, which also needs to be reencoded.

My current command is

fmpeg -y -loglevel debug -flags global_header -err_detect ignore_err -fflags +igndts -copy_unknown -i "%%~fV" -f !ext! -c copy -map 0 -vn -sn -b:a 32k "%%~pnxV.tmpoutput"

Which works for other file types with the same type of data stream and will work with .wmv if I add -dn (even though my file is then not recognizable by the external program). The command above, as is, for .wmv files will output the error Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted.

From FFprobe (full output below), I can see the message Unsupported codec with id 0 for input stream 2, so I believe it’s beyond doubt that the cause is indeed the data stream.


Question

The thing is that I expected -copy_unknown to deal with this and it doesn’t. My question is: how do I copy this unsupported, not used anywhere else data stream? Are there other ways to approach the matter?

Thanks


Extra info

Full FFmpeg output (with -loglevel debug):

ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-flags' ... matched as AVOption 'flags' with argument 'global_header'.
Reading option '-err_detect' ...Routing option err_detect to both codec and muxer layer
 matched as AVOption 'err_detect' with argument 'ignore_err'.
Reading option '-fflags' ... matched as AVOption 'fflags' with argument '+igndts'.
Reading option '-copy_unknown' ... matched as option 'copy_unknown' (Copy unknown stream types) with argument '1'.
Reading option '-i' ... matched as input url with argument 'C:UsersFabioDesktopTestestesta.wmv'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'asf'.
Reading option '-c' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0'.
Reading option '-vn' ... matched as option 'vn' (disable video) with argument '1'.
Reading option '-sn' ... matched as option 'sn' (disable subtitle) with argument '1'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '32k'.
Reading option 'UsersFabioDesktopTestestesta.wmv.tmpoutput' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option copy_unknown (Copy unknown stream types) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url C:UsersFabioDesktopTestestesta.wmv.
Successfully parsed a group of options.
Opening an input file: C:UsersFabioDesktopTestestesta.wmv.
[NULL @ 0000025955e7af40] Opening 'C:UsersFabioDesktopTestestesta.wmv' for reading
[file @ 0000025955e7b740] Setting default whitelist 'file,crypto'
[asf @ 0000025955e7af40] Format asf probed with size=2048 and score=100
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=244
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=26
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=3295
[asf @ 0000025955e7af40] Payload extension 50 2
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=42
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=44
[asf @ 0000025955e7af40] gpos mismatch our pos=24, end=834
[asf @ 0000025955e7af40] Before avformat_find_stream_info() pos: 5793 bytes read:32768 seeks:0 nb_streams:3
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[wmv3 @ 0000025955eb4480] Header: 46690A01
[wmv3 @ 0000025955eb4480] Profile 1:
frmrtq_postproc=3, bitrtq_postproc=6
LoopFilter=1, MultiRes=0, FastUVMC=0, Extended MV=0
Rangered=0, VSTransform=1, Overlap=1, SyncMarker=0
DQuant=0, Quantizer mode=0, Max B-frames=0
[wmv3 @ 0000025955eb4480] Extra data: 8 bits left, value: 0
[wmv3 @ 0000025955eb4480] Format yuv420p chosen by get_format().
    Last message repeated 1 times
[asf @ 0000025955e7af40] parser not found for codec wmav2, packets or times may be invalid.
[asf @ 0000025955e7af40] All info found
[asf @ 0000025955e7af40] After avformat_find_stream_info() pos: 191671 bytes read:196608 seeks:0 frames:58
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'C:UsersFabioDesktopTestestesta.wmv':
  Metadata:
    copyright       : ChessBase GmbH
    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0, 17, 1/1000: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 96 kb/s
    Stream #0:1, 41, 1/1000: Video: wmv3 (Main), 1 reference frame (WMV3 / 0x33564D57), yuv420p(left), 640x480, 0/1, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2, 0, 1/1000: Data: none, 0/1, 10 kb/s
Successfully opened the file.
Parsing a group of options: output url UsersFabioDesktopTestestesta.wmv.tmpoutput.
Applying option f (force format) with argument asf.
Applying option c (codec name) with argument copy.
Applying option map (set input stream mapping) with argument 0.
Applying option vn (disable video) with argument 1.
Applying option sn (disable subtitle) with argument 1.
Applying option b:a (video bitrate (please use -b:v)) with argument 32k.
Successfully parsed a group of options.
Opening an output file: UsersFabioDesktopTestestesta.wmv.tmpoutput.
[file @ 0000025955eee200] Setting default whitelist 'file,crypto'
Successfully opened the file.
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:2 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0000025955eee2c0] Statistics: 0 seeks, 1 writeouts
[AVIOContext @ 0000025955e83980] Statistics: 196608 bytes read, 0 seeks

FFprobe on a sample file:

ffprobe version 4.3 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200621
  configuration: --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
[wmv3 @ 00000180012e1440] Extra data: 8 bits left, value: 0
Input #0, asf, from 'test/a.wmv':
  Metadata:

    WMFSDKVersion   : 12.0.9600.17415
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    DeviceConformanceTemplate: MP@ML
  Duration: 00:00:23.08, start: 0.000000, bitrate: 526 kb/s
    Stream #0:0: Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, 2 channels, fltp, 96 kb/s
    Stream #0:1: Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 640x480, 415 kb/s, 25 tbr, 1k tbn, 1k tbc
    Stream #0:2: Data: none, 10 kb/s
[wmv3 @ 0000018001324a80] Extra data: 8 bits left, value: 0
Unsupported codec with id 0 for input stream 2

Other

I chose to specify -f and .tmpoutput to facilitate other non-related parts of my flow.


Get this bounty!!!