Open Randrianasulu opened 8 months ago
Hm, I am not sure what we can do here. In line https://github.com/anyc/avcut/blob/1d6f289a4dc1f9a244a28cfec194c900f44d5a28/avcut.c#L421C13-L421C33 we open the encoder based on the codec_id of the input codec which seems to denote the input format.
@anyc, may be examine returned AVCodec structure and replace mediacodec family with software ones?
V....D av1_mediacodec AV1 Android MediaCodec encoder (codec av1)
V....D h264_mediacodec H.264 Android MediaCodec encoder (codec h264)
V....D hevc_mediacodec H.265 Android MediaCodec encoder (codec hevc)
V....D mpeg4_mediacodec MPEG-4 Android MediaCodec encoder (codec mpeg4)
V....D vp8_mediacodec VP8 Android MediaCodec encoder (codec vp8)
V....D vp9_mediacodec VP9 Android MediaCodec encoder (codec vp9)
Hm, it looks like it is possible to replace the function avcodec_find_encoder() I referenced above with a combination of avcodec_descriptor_get_by_name() and avcodec_find_encoder_by_name() like implemented here: https://ffmpeg.org/doxygen/2.7/ffmpeg__opt_8c_source.html#l00535
I just added the possibility to select the video encoder by CLI argument. Let me know if this helps.
Better but stil segfault at the muxing stage ....
~/avcut $ gdb ./avcut
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-android".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./avcut...
(No debugging symbols found in ./avcut)
(gdb) r -i ~/f9518976.mp4 -o test.mp4 -e libx264 0 2
Starting program: /data/data/com.termux/files/home/avcut/avcut -i ~/f9518976.mp4 -o test.mp4 -e libx264 0 2
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/data/data/com.termux/files/usr/lib/libthread_db.so".
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/data/com.termux/files/home/f9518976.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2021-04-16T13:01:39.000000Z
com.android.version: 10
Duration: 00:00:24.40, start: 0.000000, bitrate: 17035 kb/s
Stream #0:0[0x1](eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown, progressive), 1920x1080, 16774 kb/s, SAR 1:1 DAR 16:9, 29.55 fps, 29.61 tbr, 90k tbn (default)
Metadata:
creation_time : 2021-04-16T13:01:39.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2021-04-16T13:01:39.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
[libx264 @ 0xb400007e231ab460] using cpu capabilities: ARMv8 NEON
[libx264 @ 0xb400007e231ab460] profile Constrained Baseline, level 4.1, 4:2:0, 8-bit
Program received signal SIGSEGV, Segmentation fault.
0x0000007fbd6b9a84 in ?? () from /data/data/com.termux/files/usr/lib/libavformat.so.60.16.100
(gdb) bt full
#0 0x0000007fbd6b9a84 in ?? () from /data/data/com.termux/files/usr/lib/libavformat.so.60.16.100
No symbol table info available.
#1 0x0000007fbd6e0378 in avformat_init_output ()
from /data/data/com.termux/files/usr/lib/libavformat.so.60.16.100
No symbol table info available.
#2 0x000000555555a908 in open_encoder ()
No symbol table info available.
#3 0x000000555555d89c in main ()
No symbol table info available.
(gdb)
As avcut just copies the codec config from the decoder to the encoder, there might be something incompatible in there. I guess you have to gather a backtrace with a ffmpeg library with debug symbols. Unfortunately, I am not really familiar with the details of the codecs and their settings.
(If I execute avcut with "-e libx264" it works normally with my test video.)
You could also try to setup a profile. That's maybe easier than getting ffmpeg with debug symbols.
@anyc I do have ffmpeg source (just compiled for unrelated reason of testing dvd pcm audio encoder, there is curious difference between decoder supporting 32/44.1 khz sampling and encoder not. So I altered encoder and mpv still plays sound, but no idea if hw dvd player will pick it up. mediainfo for sure is confused) on my termux install, just need to point avcut to there ...
On termux (Android 11, aarch64) :
It will be useful if there was way to filter out / blacklist some encoders?